This tag is for questions that aren't specific to a programming language or environment.

learn more… | top users | synonyms

0
votes
1answer
141 views

Exception handling class: static or object-oriented?

I am working in a windows service (using VB.Net) for internal use of my department. When ever a certain type of exception (FooException for now on) is captured, I follow the same logic: Log the ...
21
votes
6answers
2k views

How can I say that programming language compiles to other languages?

How can I say in english, that programming language can be compiled to other programming languages? The example can be Haxe. On the website the language is decribed as "Multiplatform": ...
3
votes
4answers
1k views

How to determine most challenging test-cases to test any algorithm?

While solving any problem, we write algorithms. Some efficient, some not, some work, some fail. But sometimes we end up writing something which is mostly a success when we do a dry test run, perhaps, ...
1
vote
2answers
2k views

How to find local maxima in matrices?

I need to develop an algorithm for finding all the local maxima in a two-dimensional array: how to search for local maxima in the the most efficient way? Are there algorithms about it? Moreover, the ...
3
votes
2answers
266 views

How can you provide a public writeable API and not get spammed?

So say you had a site like StackExchange. Now imagine you created a machine-writeable API capable of posting questions and comments and doing everything your browser can do. Of course, about 5 ...
1
vote
3answers
261 views

Should methods always be closed for modification?

Say I have a method called 'functionA' that is called by a service and carries out a single piece of functionality, it is easy to unit test as it is does one thing only. If a few months later an new ...
7
votes
2answers
483 views

When is it inappropriate to make objects immutable?

I have a class which represents an entity object in our system (for sake of argument, a Customer object) public class Customer() { private int id; private String name; ... // 30+ fields ...
2
votes
8answers
1k views

Benefits of combining programming languages [closed]

I know there are different ways to combine programming languages (Haskell's FFI, Boost with C++ and Python, etc...). I have an odd interest in combining programming languages; however, I have only ...
1
vote
1answer
454 views

Should I use a formal grammar for my interpreted scripting language

I have a scripting engine I just published as an open source project. It's been sitting on my harddrive waiting for about a year. My engine of course isn't complete in any way, but it does work for ...
1
vote
2answers
915 views

Writing an API that is syntactically valid in multiple programming languages

I'm planning to write a single API that is syntactically valid in most major programming languages (to the greatest extent possible, so that only minimal amounts of code will need to be re-written ...
2
votes
2answers
406 views

I need some help with defining a shell syntax

I'm trying to understand more about shells. I'm looking to implement one and want to look at what's been done in the past. In a regular shell, you have features like aliases and relative paths, and ...
9
votes
9answers
1k views

Why is (position < size) such a prevalent pattern in conditionals?

In a condition statement (IF) everyone uses (position < size), but why? Only convention or there is a good reason for that? Found in the wild: if (pos < array.length) { // do some with ...
2
votes
2answers
235 views

Are there any practical uses of allowing recursive inclusion of a file?

I am currently implementing NASM-like preprocessor for my assembler, and I am wondering what is the correct way of handling recursively included files. From what I see, there are two ways to deal with ...
14
votes
4answers
2k views

Is garbage collection needed for implementing safe closures?

I recently attended an online course on programming languages in which, among other concepts, closures were presented. I write down two examples inspired by this course to give some context before ...
3
votes
2answers
146 views

Randomness of wrapped RNG

There are plenty of questions around regarding random number generation, but I couldn't find anything that exactly matched my question. Apologies if I missed one. Most random number generators in ...
3
votes
1answer
285 views

Addition vs multiplication on algorithm performance

I am studying about optimizing alogrithms.(Prof. Skiena's Algorithm Guide book) One of the exercises asks us to optimize an algorithm: Suppose the following algorithm is used to evaluate the ...
1
vote
3answers
244 views

About classes and their valid states

I get stuck each time I need to write a constructor for any class I design. The reason is that I am not sure what should go into a constructor and what should not. On googling for this, I got the ...
25
votes
8answers
10k views

Is the average number of bugs per loc the same for different programming languages? [closed]

I have been told that the average number of bugs/defects per line of code is "constant" for different programming languages. 10 KLOC of Ruby would have the same number of bugs as 10 KLOC of c++. The ...
1
vote
1answer
120 views

Are “conditional” caching policies ever actually useful?

I'm designing an abstraction over ASP.Net's built in caching to make it not so horrible to use. One design decision I'm having to look at is if I should restrict people to using just one cache policy ...
1
vote
1answer
80 views

Need some input on storing stdin, stdout, stderr information for debugging

I am working with a legacy system that is not too bad, but I thought of making some improvements to it, and I wanted to solicit your feedback to help me make good decisions. The platform is Linix ...
7
votes
2answers
4k views

What are the pros and cons of Inter process communication done via sockets vs shared memory?

I understand that two of the many more options for inter process communication can be : Shared memory Sockets Actually I saw these two options being exposed by Intellij Idea for debugging a Java ...
2
votes
1answer
162 views

How to share common methods if objects have different roles?

If 2 classes have the following in common: part of how their state is represented (both have a linear container) multiple identical methods (identical code, not just signature) But are not ...
7
votes
1answer
525 views

Loop fusion example using aspect-oriented framework

I had recently read a paper 'Aspect-Oriented Programming' by Gregor Kiczales and others, and found there the loop fusion example. Here is a definition of the loop fusion from the paper …the loop ...
7
votes
2answers
660 views

Best Practice to Avoid “Playing Telephone” with Constructor Arguments

I find that the encapsulation required by OO has me frequently passing paramenters down the line from parent to child to great grandchild to second grand nephew once removed (not actually that bad). ...
6
votes
4answers
1k views

Evaluate math expressions without a stack

How do you evaluate arbitrary math expressions using temporary variables instead of a stack? What I'm talking about is translating an expression into an array of simple operations- each that change ...
26
votes
11answers
2k views

Maintenance wise, is `else while` without intervening braces considered safe?

Is else while without intervening braces considered "safe" maintenance wise? Writing if-else code without braces like below... if (blah) foo(); else bar(); ...carries a risk because the ...
5
votes
4answers
465 views

What is thread safety? [closed]

What is it? I was reading Effective STL and came across it. I have also Googled it, but couldn't get any helpful info.
1
vote
3answers
957 views

When should one use “out” parameters?

In Objective-C, there are several methods like initWithContentsOfFile:encoding:error: where one passes in a reference to an NSError object for the error: parameter. In this example, the value of the ...
0
votes
1answer
711 views

Client-Server connection response timeout issues

User creates a folder in client and in the client-side code I hit an API to the server to make this persistent for that user. But in some cases, my server is so busy that the request timesout. The ...
4
votes
4answers
336 views

Is code that terminates on a random condition guaranteed to terminate?

If I had a code which terminated based on if a random number generator returned a result (as follows), would it be 100% certain that the code would terminate if it was allowed to run forever. while ...
6
votes
3answers
1k views

Looking for a real-world example illustrating that composition can be superior to inheritance [closed]

I watched a bunch of lectures on Clojure and functional programming by Rich Hickey as well as some of the SICP lectures, and I am sold on many concepts of functional programming. I incorporated some ...
40
votes
8answers
9k views

What should be allowed inside getters and setters?

I got into an interesting internet argument about getter and setter methods and encapsulation. Someone said that all they should do is an assignment (setters) or a variable access (getters) to keep ...
115
votes
17answers
25k views

Is there an excuse for short variable names?

This has become a large frustration with the codebase I'm currently working in; many of our variable names are short and undescriptive. I'm the only developer left on the project, and there isn't ...
22
votes
7answers
3k views

What does it mean that “language A is written in language B”?

I often hear the term that language A is written in language B. For example, PHP has been written C, C# is written in C++. Can someone please explain what does that mean and if it is even correct? ...
0
votes
2answers
85 views

Looking for terminology for the relation of a subject and a predicate [closed]

While writing some predicates for collection filtering I have stumbled over the choice of the right words for the relation of the subject and the predicate (English is a foreign language for me). What ...
22
votes
7answers
2k views

Pattern for a class that does only one thing

Let's say I have a procedure that does stuff: void doStuff(initalParams) { ... } Now I discover that "doing stuff" is quite a compex operation. The procedure becomes large, I split it up into ...
0
votes
2answers
210 views

When modeling a virtual circuit board, what is the best design pattern to check for cycles?

To make it simple assume you have only AND and OR gates. Each has two inputs and one output. The output of two inputs can be used as an input for the next gate For example: A AND B -> E C AND D -> F ...
23
votes
8answers
2k views

Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth) [duplicate]

The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]: Use comments sparingly! (I bet that's welcome.) Remember that program you looked through - the ...
2
votes
2answers
108 views

How does one handle an incorrect resource file?

I'm starting the parser that will handle one of the key features of my app and realizing exactly who easy it would be for me to screw up a resource file that is provided to the application. For ...
26
votes
4answers
3k views

Can you use Pi as a crude random number generator?

I recently saw this question over at math.SE. It got me thinking. Could Pi be used as a crude random number generator? I mean the results are well known(how long has pi been computed to now?) but, Pi ...
33
votes
15answers
5k views

Why use other number bases when programming

My coworkers and I have been bending our minds to figuring out why anyone would go out of their way to program numbers in a base other than base 10. I suggested that perhaps you could optimize longer ...
4
votes
3answers
333 views

Is Reading the Spec Enough? [closed]

This question is centered around Scheme but really could be applied to any LISP or programming language in general. Background So I recently picked up Scheme again having toyed with it once or twice ...
5
votes
3answers
295 views

In dependency injection, is there a simple name for the counterpart of the injected object? [closed]

In tutorials and books, I have never seen a single word describing the object that the injected object is injected into. Instead, other terms are used, like "injection point" which don't denote the ...
-4
votes
3answers
307 views

In what practical ways is it good to remember the memory/pointers model? [closed]

A variable refers to a value. A variable is also stored in a memory address. People say that it's good to have this memory model in mind. Is that true? What is some sample code that shows this as ...
4
votes
4answers
2k views

Why should one use a single-use temporary variable?

Let's say we have a class called 'Automobile' and we have an instance of that class called 'myCar'. I would like to ask why do we need to put the values that our methods return in a variable? Why ...
0
votes
2answers
248 views

What is the standard for describing functions and objects?

What is the standard for describing functions/methods (function name, number of arguments, argument type, return type, etc...) in a manner that is language independent? EDIT: More specifically, how ...
2
votes
1answer
89 views

String patterns that can be used to filter and group files

One of our application filters files in certain directory, extract some data from it and export a document from the extracted data. The algorithm for extracting the data depends on the file, and so ...
14
votes
5answers
2k views

Why are invariants important in Computer Science

I understand 'invariant' in its literal sense. I also recognize them when I type code. But I don't think I understand the importance of this term in the context of computer science. Whenever I read ...
3
votes
2answers
465 views

Questions about identifying the components in MVC

I'm currently developing an client-server application in node.js, Express, mustache and MySQL. However, I believe this question should be mostly language and framework agnostic. This is the first ...
2
votes
2answers
2k views

Relationship between SOA and OOA

Thomas Erl defines SOA as follows in his site: Service-oriented computing represents a new generation distributed computing platform. As such, it encompasses many things, including its own ...