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

learn more… | top users | synonyms

5
votes
3answers
753 views

Style for control flow with validation checks

I find myself writing a lot of code like this: int myFunction(Person* person) { int personIsValid = !(person==NULL); if (personIsValid) { // do some stuff; might be lengthy int myresult ...
73
votes
19answers
27k views

Are `break` and `continue` bad programming practices?

My boss keeps mentioning nonchalantly that bad programmers use break and continue in loops. I use them all the time because they make sense; let me show you the inspiration: function verify(object) ...
21
votes
6answers
2k views

Methodology for documenting existing code base

I work as part of a team on an existing application that has no inline documentation, nor does it have technical documentation. As I've been working on various bug reports on the application, I've ...
19
votes
5answers
3k views

Data input validation - Where? How much? [closed]

Data input validation always was quite an internal struggle to me. On the verge of adding a real security framework and code to our legacy application rewrite project (which so far pretty much keeps ...
8
votes
9answers
425 views

Internationalization : What things to think about?

I was listening to Jon Skeet's talk at the last StackOverflow Dev Days and he piqued my curiousity regarding internationalization. Suppose I have a waffle-making program, either complete, or still in ...
210
votes
25answers
21k views

How do you know you're writing good code? [duplicate]

Serious question here. I love programming. I've been messing around with code since I was a kid. I never went the professional route, but I have coded several in-house apps for various employers, ...
7
votes
5answers
639 views

Do Diversified Skills Foster or Hinder Specialization?

Since I started working I tried to focus on web development, but because of different needs and situations in the companies I worked I have had to work in different areas (Back-end, Database, etc...) ...
45
votes
4answers
4k views

What should I do to be language-agnostic?

By now I work with asp.net and C#. I have done a decent work in Java as well. I am planning my career in such a way I should be language-agnostic someday. What are the things that I need to learn? ...
87
votes
11answers
11k views

The modern way to perform error handling…

I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: Favour exceptions ...
55
votes
17answers
4k views

How to train yourself to avoid writing “clever” code?

Do you know that feeling when you just need to show off that new trick with Expressions or generalize three different procedures? This does not have to be on Architecture Astronaut scale and in fact ...
23
votes
5answers
1k views

Beginner's guide to writing comments?

Is there a definitive guide to writing code comments, aimed at budding developers? Ideally, it would cover when comments should (and should not) be used, and what comments should contain. This ...
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": ...
36
votes
12answers
3k views

Is there ever a reason to do all an object's work in a constructor?

Let me preface this by saying this is not my code nor my coworkers' code. Years ago when our company was smaller, we had some projects we needed done that we did not have the capacity for, so they ...
6
votes
3answers
3k views

When is method overloading appropriate?

Suppose I am working on an existing, reasonably large system. I have an object, myObject of class MyClass (for the example's sake, suppose I'm working in Java). myObject is a composition containing a ...
12
votes
8answers
2k views

Why do most programming languages not nest block comments?

A few do, but not any of the popular ones as far as I know. Is there something bad about nesting comments? I plan to have block comments nest in the (small) language I'm working on, but I would like ...
27
votes
12answers
2k views

Techniques for getting off the ground in any language

When I start learning a new language, I have a couple of simple implementations that I like to complete to familiarise myself with the language. Currently, I write: Fibonacci and/or factorial to get ...
35
votes
8answers
5k 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 ...
41
votes
17answers
5k views

Why Use !boolean_variable Over boolean_variable == false

A comment on this question: Calling A Method that returns a boolean value inside a conditional statement says that you should use !boolean instead of boolean == false when testing conditions. Why? To ...
21
votes
9answers
4k views

Able to read Code but struggling majorly to write it [closed]

I had my first programming exam recently...and well I pretty much flopped it. Did not do great at all. I have only myself to blame as outside of college time, I pretty much did nothing. Now I have ...
16
votes
11answers
3k views

is OOP the dominant programming model in real world?

Objects Never? Well, Hardly Ever In the VIEWPOINT section of Communications of The ACM, I found an interesting article entitled "Objects Never? Well, Hardly Ever". It’s a radically different ...
17
votes
14answers
1k views

What Impact Do Scripting Languages Have on Junior Programmers?

I had a discussion with one of my teachers the other day. We debated the impact that simpler scripting languages (like Python or Ruby) have on junior programmers. He argued that scripting ...
26
votes
4answers
2k 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 ...
21
votes
8answers
5k 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 ...
32
votes
15answers
4k 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 ...
19
votes
7answers
2k views

while(true) and loop-breaking - anti-pattern?

Consider the following code: public void doSomething(int input) { while(true) { TransformInSomeWay(input); if(ProcessingComplete(input)) break; ...
15
votes
4answers
2k views

Is code like this a “train wreck” (in violation of Law of Demeter)?

Browsing through some code I've written, I came across the following construct which got me thinking. At a first glance, it seems clean enough. Yes, in the actual code the getLocation() method has a ...
7
votes
2answers
129 views

What do you do when working with multiple languages with different capitalization schemes?

I'm making a webapp using Django. The Python convention for naming variables is lowercase_with_underscores, but the Javascript convention is camelCase. In addition, I've seen many people use ...
6
votes
6answers
1k 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
2k views

Should I refactor a F class from code climate? [closed]

According to code climate (static quality analysis), a class is F, aka the worst mark you could be granted. I did submit a pull request to rearrange it here Which has been refused because the new ...
67
votes
13answers
5k views

Why don't we store the syntax tree instead of the source code?

We have a lot of programming languages. Every language is parsed and syntax checked before being translated into code so an abstract syntax tree (AST) is built. We have this abstract syntax tree, why ...
42
votes
24answers
4k views

Most common “Y2K-style” bugs today? [closed]

I don't specifically mean date-related issues like 2038, but more generally, bugs that fit the pattern: A generation ago, programmers tended to write code that ass-u-me-d X, which was reasonable at ...
16
votes
6answers
908 views

How did we get saddled with the (hierarchical) filesystem as the basic data structure?

I'm self-taught and I don't have a CS degree. The more I've been learning about data structure, the more I wonder, in this day and age, how are we still saddled with the filesystem, with directories ...
6
votes
5answers
2k views

Becoming a polyglot programmer

I know a few programming languages. The most marketable ones being Java, Javascript, as well as non-trival stored procedures. I also know some Python, Actionscript and a few dinosaurs language. I ...
19
votes
9answers
672 views

What are good techniques for keeping your place in code?

I understand using bookmarks to remember a single point in your code. However, how does one keep track of the flow of the code they are investigating? Eg: multiple bookmarks and the order in which ...
15
votes
9answers
893 views

What is your go-to application when you start learning a new language? [closed]

What "application" do you write to understand a programming language? I have used a calculator (regular + equation solver). But I think it's too easy. I am planning to learn Haskell and was curious, ...
42
votes
21answers
7k views

Is it true that once you learn one language most of the rest come easy?

I was told by someone that I should start with Python and then, once I'm fluent in Python, the rest of the languages will be learned quickly. Is there any truth to this?
13
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 ...
13
votes
1answer
1k views

How do I test a file reader?

I am working on a project with a few file formats. Some formats are specified by .xsds, others by documentation on their respective websites, and some are custom in-house formats that have no ...
13
votes
5answers
2k views

What is the good explanation of Tennent's Correspondence Principle?

I found myself struggling to see what is this principle about and why is it so important for language design. Basically, it states, that for every expression expr in language should be exactly the ...
12
votes
10answers
2k views

What's the next level of abstraction? [closed]

Since programming languages initially only used lines of code executed sequentially, and it evolved into including functions which were one of the first levels of abstraction, and then classes and ...
11
votes
6answers
795 views

What are the differences between a website and a web application?

How do you differentiate a web application from websites? It's language/platform agnostic.
26
votes
9answers
2k views

Scientific evidence that supports using long variable names instead of abbreviations?

Is there any scientific evidence that the human brain can read and understand fully written variable names better/faster than abbreviated ones? Like PersistenceManager persistenceManager; in ...
22
votes
7answers
1k 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 ...
19
votes
2answers
1k views

What is the advantage of wrapping exceptions [duplicate]

It's very common in .NET for an exception to be wrapped in several layers of "outer exceptions" which give marginally more contextual data. For example, in EF if your update fails, you get exceptions ...
11
votes
2answers
508 views

How does event bubbling generally work and is it synonym to event propagation?

I'm trying to wrap my head around the general workings and principles of event dispatching in event-driven (sub-)systems. Although I have used it on quite a few occasions in for instance Javascript, ...
22
votes
14answers
1k views

How managers choose programming languages

It's not a secret to anyone that managers can and often will impose the programming language that will be used for a project. Being a programmer myself, I have never been able to understand this. ...
9
votes
17answers
2k views

What programming languages have you taught your children? [closed]

I'm a C# developer by trade but have had exposure to many languages (including Java, C++, and multiple scripting languages) over the course of my education and career. Since I code in the MS world ...
8
votes
5answers
470 views

Language-agnostic libs every programmer should consider learning? [closed]

Assuming the language provides it, what are some things to do or libs to use that every programmer should know? My list would be Regular Expressions Named Pipes standard IO (std in/out/error) ...
7
votes
9answers
899 views

How are we supposed to deal with Customers who don't give a damn? [closed]

I have some customers who expect everything for next to nothing. They also want things to behave a certain way, or look a certain way, but when explaining to them why it's not a good idea to implement ...
6
votes
3answers
408 views

Strategy for backwards compatibility of persistent storage

In my experience, trying to ensure that new versions of an application retain compatibility with data storage from previous versions can often be a painful process. What I currently do is to save a ...