Programming Practices are the commonly or not so commonly used practices in development of software. These can include things like Agile Development, Kanban, Coding shortcuts, etc.

learn more… | top users | synonyms

266
votes
16answers
60k views

Why are shortcuts like x += y considered good practice?

I have no idea what these are actually called, but I see them all the time. The Python implementation is something like: x += 5 as a shorthand notation for x = x + 5. But why is this considered good ...
238
votes
17answers
89k views

Torvalds' quote about good programmer [closed]

Accidentally I've stumbled upon the following quote by Linus Torvalds: "Bad programmers worry about the code. Good programmers worry about data structures and their relationships." I've ...
226
votes
16answers
17k views

Project is nearly done, but procedural spaghetti code. Do I rewrite or just keep trying to ship it? [closed]

I'm a beginner web developer (one year of experience). A couple of weeks after graduating, I got offered a job to build a web application for a company whose owner is not much of a tech guy. He ...
201
votes
17answers
23k views

How would you know if you've written readable and easily maintainable code?

How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view the code is readable and maintainable, because the author ...
195
votes
16answers
34k views

What's wrong with comments that explain complex code?

A lot of people claim that "comments should explain 'why', but not 'how'". Others say that "code should be self-documenting" and comments should be scarce. Robert C. Martin claims that (rephrased to ...
181
votes
13answers
52k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
173
votes
17answers
11k views

How do you balance between “do it right” and “do it ASAP” in your daily work? [closed]

I find myself pondering over this question from time to time, again and again. I want to do things the right way: to write clean, understandable and correct code that is easy to maintain. However, ...
167
votes
17answers
16k views

Is there a benefit in compiling your code as you go along?

I recently had a job interview in which they gave me an hour to write some real code. It wasn't a huge amount, probably less than 100 lines. After about 45 minutes, I compiled, ran it, and got it to ...
166
votes
14answers
28k views

Why are the sizes of programs so large?

If we look at the vintage program Netscape Navigator or an early version of Microsoft Word, those programs were less than 50 MB in size. Now when I install google chrome it is 200 MB and desktop ...
140
votes
5answers
55k views

Choosing between Single or multiple projects in a git repository?

In a git environment, where we have modularized most projects, we're facing the one project per repository or multiple projects per repository design issue. Let's consider a modularized project: ...
137
votes
22answers
23k views

Stuck due to “knowing too much” [closed]

Note more discussion at http://news.ycombinator.com/item?id=4037794 I have a relatively simple development task, but every time I try to attack it, I end up spiraling in deep thoughts - how could it ...
126
votes
27answers
8k views

What are the worst false economies in software development? [closed]

What are the worst false economies (that is ways of saving money that ultimately cost more than they save) prevalent in the software industry and how do you combat them?
124
votes
11answers
31k views

How has an increase in the complexity of systems affected successive generations of programmers?

As a "new" programmer (I first wrote a line of code in 2009), I've noticed it's relatively easy to create a program that exhibits quite complex elements today with things like .NET framework for ...
112
votes
18answers
10k views

Can a function be too short?

Whenever I find myself writing the same logic more than once, I usually stick it in a function so there is only one place in my application I have to maintain that logic. A side effect is that I ...
111
votes
15answers
18k views

Are single-character constants better than literals?

I recently encountered a class which provides pretty much every single-character as a constant; everything from COMMA to BRACKET_OPEN. Wondering whether this was necessary; I read an "article" which ...
106
votes
15answers
83k views

Why are data structures so important in interviews? [closed]

I must confess that I was not so strong in data structures when I graduated out of college. Throughout the campus placements during my graduation, I've witnessed that most of the biggie tech companies ...
105
votes
47answers
23k views

Make a big deal out of == true?

There is a colleague of mine who constantly writes: if (someBool == true) It drives me up the wall! Should I make a big deal of it or just drop it?
100
votes
45answers
18k views

What popular “best practices” are not always best, and why? [closed]

"Best practices" are everywhere in our industry. A Google search on "coding best practices" turns up nearly 1.5 million results. The idea seems to bring comfort to many; just follow the instructions,...
99
votes
16answers
15k views

Should I add redundant code now just in case it may be needed in the future?

Rightly or wrongly, I'm currently of the belief that I should always try to make my code as robust as possible, even if this means adding in redundant code / checks that I know won't be of any use ...
97
votes
53answers
7k views

Harmful temptations in programming

Just curious, what kinds of temptations in programming turned out to be really harmful in your projects? Like when you really feel the urge to do something and you believe it's going to benefit the ...
91
votes
17answers
31k views

How to visualize code? [closed]

I've mostly only had to read my own code. As such, I've had no need to visualize the code as I already know how each and every class and module communicate with one another. But the few times I've ...
89
votes
10answers
31k views

Why do most of us use 'i' as a loop counter variable?

Has anyone thought about why so many of us repeat this same pattern using the same variable names? for (int i = 0; i < foo; i++) { // ... } It seems most code I've ever looked at uses i, j, ...
88
votes
13answers
12k views

How to warn other programmers of class implementation

I'm writing classes that "must be used in a specific way" (I guess all classes must...). For example, I create the fooManager class, which requires a call to, say, Initialize(string,string). And, to ...
88
votes
5answers
80k views

Two HTML elements with same id attribute: How bad is it really?

Just browsing the google maps source code. In their header, they have 2 divs with id="search" one contains the other, and also has jstrack="1" attribute. There is a form separating them like so: <...
86
votes
22answers
68k views

Automatic programming: write code that writes code [closed]

After reading the book The Pragmatic Programmer, one of the arguments I found most interesting was "write code that writes code". I tried searching over the net for some more explanations or articles ...
85
votes
12answers
7k views

How big does my project need to be for me to unit test it? [closed]

I assume that my project is decoupled enough to allow for unit testing. But how big, exactly, in terms of clases and functions does my project need to be to make unit testing worthwhile? We all make ...
83
votes
17answers
5k views

Are my negative internship experiences representative of the real world? [closed]

I'm curious if my current experiences as an intern are representative of actual industry. As background, I'm through the better part of two computing majors and a math major at a major university; I'...
81
votes
7answers
8k views

Short circuit evaluation, is it bad practice?

Something that I've known for a while but never considered is that in most languages it is possible to give priority to operators in an if statement based on their order. I often use this as a way to ...
79
votes
9answers
10k views

Over thinking development

I've been working as an app developer for a year and a half now (not long I know), and I've just been given my first big project. Needless to say it didn't go very smoothly, so I sought advice from a ...
77
votes
11answers
9k views

Does programming in general become easier to read, write and understand as you gain experience?

I'm a beginner in programming and I've been reading books, studying, reading articles, and whatnot. I'm getting great results since I've started learning programming, and when I was a beginner I used ...
76
votes
8answers
9k views

Is it okay to not completely understand code functionality? [duplicate]

As I am currently struggling with learning WCF for a project at work, for the past several days I have been looking at online tutorials and examples on the best way to make a WCF client; and today, ...
69
votes
17answers
7k views

How to train yourself to avoid writing “clever” code? [closed]

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 ...
63
votes
2answers
47k views

Git branching and tagging best practices

I am currently learning to use Git by reading Pro Git. Right now I'm learning about branching and tags. My question is when should I use a branch and when should I use a tag? For example, say I ...
62
votes
7answers
9k views

Code First vs. Database First

When I design and create the software I work on, I typically design and create the back-end SQL tables first and then move on to the actual programming. The project I'm currently working on has me ...
62
votes
9answers
4k views

How can I get things right at the beginning of a software project? [closed]

I am programmer with 1 year experience, recently I realized I seldom start a project correctly (most of my side project), normally the project cycle goes like Start with a few use-cases Start coding ...
61
votes
16answers
9k views

Is the creation of brand new software generally a major part of most programming jobs? [closed]

I have worked in software development for over 10 years now, and it's dawning on me that I rarely get to create anything "new". I realize that "new" is a vague term, but I would define it as anything ...
60
votes
11answers
7k views

Is it a bad practice to modify code strictly for testing purposes

I have a debate with a programmer colleague about whether it is a good or bad practice to modify a working piece of code only to make it testable (via unit tests for example). My opinion is that it ...
58
votes
22answers
5k views

Why do some programmers think there is a contrast between theory and practice? [closed]

Comparing software engineering with civil engineering, I was surprised to observe a different way of thinking: any civil engineer knows that if you want to build a small hut in the garden you can just ...
58
votes
8answers
6k views

If I need to use a piece of memory throughout the lifespan of my program, is it really necessary to free it right before program termination?

In many books and tutorials, I've heard the practice of memory management stressed and felt that some mysterious and terrible things would happen if I didn't free memory after I'm done using it. I ...
57
votes
12answers
21k views

What kind of problems does MapReduce solve?

I have been reading about MapReduce for a while -- but what I can't understand is how someone would make a decision to use (or not use) MapReduce. I mean, what are the problem patterns that signal ...
56
votes
17answers
5k views

Alternatives to Professional Version Control [closed]

We're teaming up with some non programmers (writers) who need to contribute to one of our projects. Now they just don't like the idea of using Git (or anything for that matter) for version ...
56
votes
8answers
7k views

How can we be certain that the lower components of computer programming like compilers, assemblers, machine instructions, etc. are flawless?

Since we are becoming more and more reliant on computing, including very critical tasks of day-to-day life, I was just wondering how those vital components are tested. More technically, how are the ...
54
votes
17answers
4k views

How to deal with tautology in comments? [closed]

Sometimes I find myself in situations when the part of code that I am writing is (or seems to be) so self-evident that its name would be basically repeated as a comment: class Example { /// <...
53
votes
6answers
39k views

Method vs Function vs Procedure

Simple question, but I often hear these three terms defined with such ferocity, but which have been known to me to mean different things over the years. What are the "correct" definitions of "...
52
votes
90answers
24k views

What should every programmer know about programming?

Please, stay on technical issues, avoid behavior, cultural, career or political issues.
51
votes
16answers
4k views

Should I take care of race conditions which almost certainly has no chance of occuring?

Let's consider something like a GUI application where main thread is updating the UI almost instantaneously, and some other thread is polling data over the network or something that is guaranteed to ...
51
votes
6answers
4k views

Is making a small change, testing it, then “rinse and repeat”, a bad habit?

I am a programmer with a number of years of experience. I realized I got a certain habit. I'm not sure whether it's really a bad habit or not. I get a list of tasks to perform for a solution, even ...
51
votes
11answers
5k views

How do I avoid cascading refactorings?

I've got a project. In this project I wished to refactor it to add a feature, and I refactored the project to add the feature. The problem is that when I was done, it turned out that I needed to make ...
50
votes
8answers
7k views

Is it good that testers are competing to see who opens more bugs?

I'm a software developer. There is a team of testers who follow and run test cases written by the analyst, but also perform exploratory testing. It seems like the testers have been competing to see ...
47
votes
14answers
9k views

Differences between programming in school vs programming in industry? [closed]

A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college. What are some of the ...