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

learn more… | top users | synonyms

3
votes
2answers
528 views

Confusion with Factory pattern regarding Liskov's Substitution Principle, code maintainability and Unit Testing?

I have a confusion regarding Factory Pattern there are basically two ways You can implement that. Approach 1: public interface IProductFactory { IProduct GetProductA(); IProduct ...
2
votes
3answers
341 views

Why is float the default in the majority of languages?

In programming languages, for represent numbers you have (mainly) two types: Int(s) and floats. The us of Int is very easy. However floats cause a lot of unexpected surprises: ...
2
votes
1answer
164 views

Strategy for normalising and interpreting location data

I'm a bit stuck with a problem involving the normalisation of location input data from the user (which comes from a third party). Aim To logically breakdown and interpret the user location input ...
0
votes
2answers
643 views

Why don't we have a non-turing complete general purpose language yet? [duplicate]

Non-turing complete languages can solve every practical problem that a turing-complete language can. Also, they are much more analyzable than turing complete languages. The compiler can comprehend the ...
2
votes
0answers
119 views

Are there non-turing complete dynamic languages which can be used to create useful programs? [duplicate]

While it takes a turing complete language to create any imaginable program, is it possible to compute most "useful" programs with a non-turing complete dynamically typed language? For example, is ...
9
votes
3answers
421 views

I have to compromise: DRY, or Command-Query-Separation?

I was recently refactoring a method that was both a command and a query method. After separating it into a one command method and one query method, I found that there are now multiple places in the ...
5
votes
3answers
330 views

Where to load and store settings from a file?

I think this question should apply to most programs that load settings from a file. My question is from a programming point of view, and it is really how to deal with the loading of settings from a ...
1
vote
2answers
238 views

is there a programming language designed to express data combinations? [closed]

Very often, when using the command line or just programming, you want to express some kind of combination that you end up using a for - which is often verbose. for (int i = 0; i<10; ++i) ...
0
votes
2answers
96 views

Creating documents from snippets

From time to time I create whole documents (e.g. XML or proprietary) programmatically. If it easy enough, I just write something like stringbuilder.append("<blah>"); ...
2
votes
1answer
167 views

Representing floating-point numbers in bytecode

How do interpreted languages typically go about representing floating-point numbers in their bytecode? For example, suppose I've got a Java program with the line double a = 3.0; What does 3.0 look ...
3
votes
3answers
289 views

Can we reduce confusion in line-based diff tools by annotating the code with some unique tokens?

Let's say I have procedure1() { --body of first procedure-- } Then I rename it into procedure2 and create a procedure1 above it: procedure1() { --body of second procedure-- } procedure2() ...
8
votes
5answers
203 views

Gathering all data in single iteration vs using functions for readable code

Say I have an array of runners with which I need to find the tallest runner, the fastest runner, and the lightest runner. It seems like the most readable solution would be: runners = getRunners(); ...
2
votes
1answer
189 views

Algorithm in undirected BFS graph

I'm trying to put together an algorithm that will display the node degree for every node in a breadth first tree graph (assume BFS was called). Assume it's an undirected graph. I'm not sure how to ...
2
votes
6answers
349 views

Should all classes have a default constructor as part of good coding convention

From the texts I have read so far, the conventions talk about organizing constructors, starting with the default, if any. I am wondering, should all classes have a default constructor anyway. This ...
-1
votes
3answers
188 views

Is there a core set of language agnostic problems? [closed]

I would like to design a programming language by solving a specific set of problems. I am looking for a core set of programming problems that are language agnostic. It seems that there are a number ...
7
votes
6answers
928 views

If the model is validating the data, shouldn't it throw exceptions on bad input?

Reading this SO question it seems that throwing exceptions for validating user input is frowned upon. But who should validate this data? In my applications, all validations are done in the business ...
5
votes
3answers
318 views

Why is it rare to collect analytics/usage data in open source software?

So, I've been developing some analytic software at my work and also have started to take more notice to analytics in general. For instance, I recently installed Google Analytics on my blog(which is ...
3
votes
5answers
238 views

Testing From A Developer's Perspective [closed]

I have a book which mentions: "There are many types of testing, including unit testing, integration testing, functional testing, system testing, performance testing, and acceptance testing". It ...
2
votes
2answers
725 views

How to write a HTTP server?

As the title says, I would like to write a HTTP server. My question is this, how do I do this? I know this sounds VERY general and too "high level", but there is a method to my madness. An answer to ...
29
votes
6answers
15k views

What is early and late binding?

In many interviews I've been asked this question. I found the following answer: Early binding refers to assignment of values to variables during design time whereas late binding refers to ...
6
votes
7answers
1k views

Making Simple IF Statements Shorter

If we assume we have this little snippet of code: string str = "checked"; bool test1; if (str == "checked") { test1 = true; } else { test1 = false; } Is it bad practice to change a simple ...
12
votes
5answers
863 views

Strengthening code with possibly useless exception handling

Is it a good practice to implement useless exception handling, just in case another part of the code is not coded correctly? Basic example A simple one, so I don't loose everybody :). Let's say I'm ...
2
votes
1answer
132 views

What are the pros and cons of temporary variables vs multiple returns [duplicate]

Take the following examples: public static String returnOnce() { String resultString = null; if (someCondition) { resultString = "condition is true"; } else { resultString ...
2
votes
5answers
363 views

Other than XML, what are some examples of “coding” a GUI design?

I've been trying to think outside of the box as to how desktop GUIs can be designed in code(not a graphical designer!). I've come across basically three ways this is done: XML Raw code (create a ...
3
votes
2answers
121 views

Prevent anomalies caused by signal propagation time

In electrical engineering class we learned that signal lines are not ideal, so it takes time for the signal to reach the other end of the cable, and if we doesn't take this into account, it can lead ...
1
vote
2answers
365 views

Fundamental TDD: stuck with writing a test so I can write code that I want

I have a Season class. This Season has a few properties: among them, a list of Games. This should be populated from the same source that populated the rest of the Season properties. I have a test ...
1
vote
1answer
159 views

Where does UI fit in a Multi Agent system

tl;dr How would I represent GUI as agents in a multi agent system. I am learning more about Multi Agent Systems. I like the concepts of such systems, it makes a lot of sense and it sounds very ...
2
votes
3answers
252 views

Dependency injection and ease of use

I'm writing a handy library (we'll call it Thinger) that goes off and fetches an XML document, does some X-Path query on it and does something helpful with the result of that. (What I'm actually doing ...
2
votes
5answers
243 views

Best practice to sort then reverse, or write “backwards” comparator?

I wrote a comparator for a custom class of mine and when I ran my code I realised the output of my list of these objects was in the reverse order as to what I wanted. It was "ascending" as opposed to ...
0
votes
3answers
271 views

How do I tell a user that bps means bits per second or bytes per second?

I'm writing an application that deals with the network and the hard drive. For the network portion, the application measures in bits per second, while the disk portion measures in bytes per second. ...
1
vote
2answers
386 views

Can we create a program that writes out its source code?

Can we create a program that print out its source code what if we (or the program itself) compile than the new program would have the same exact functionality what the original program has? So somehow ...
0
votes
1answer
130 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
1k 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
755 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, ...
0
votes
2answers
955 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 ...
1
vote
2answers
297 views

Learning new concepts is an infinite loop. How do I go about it? [duplicate]

Yes, practice, practice, practice. I know the drill people suggest that helps learning new programming concepts. But that's only theoretical. For me, even a line of code like this is new (Java) and ...
3
votes
2answers
245 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
258 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 ...
5
votes
2answers
407 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
720 views

Benefits of combining programming languages

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
2answers
286 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
475 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
394 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 ...
3
votes
2answers
213 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 ...
12
votes
4answers
1k 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 ...
-2
votes
2answers
250 views

What topics/abilities are critical to learning a programming language? [closed]

What topics/abilities are generally accepted as vital-to-know of any programming language? (Can be answered through either language-specific or non-specific suggestions, however) For example, I ...
3
votes
2answers
136 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
255 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
240 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 ...
22
votes
8answers
3k views

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

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 ...