Most Popular

1500 questions
282
votes
7 answers

How to write a very basic compiler

Advanced compilers like gcc compile code into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of the code according to library and functions of the…
Googlebot
  • 3,173
  • 5
  • 19
  • 14
282
votes
6 answers

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: myProject/ +-- gui +-- core +-- api +--…
Johan Sjöberg
  • 3,007
  • 4
  • 16
  • 7
280
votes
6 answers

Can I use GPL software in a commercial application

I have 3 questions about the GPL here: If I use GPL software in my application, but don't modify or distribute it, do I have to release my application under the GPL? What if I modify some software that my application uses. Then do I have to release…
Petah
  • 3,351
  • 3
  • 18
  • 21
278
votes
25 answers

How do you know you're writing good code?

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 applications for various employers, including a project I got roped into where I built an internal…
Jim
  • 1,997
  • 3
  • 20
  • 25
276
votes
17 answers

Why have private fields, isn't protected enough?

Is the visibility private of class fields/properties/attributes useful? In OOP, sooner or later, you are going to make a subclass of a class and in that case, it is good to understand and be able to modify the implementation completely. One of the…
Adam Libuša
  • 2,067
  • 2
  • 10
  • 14
275
votes
14 answers

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 the purpose of object oriented programming. If we…
Slamice
  • 2,647
  • 3
  • 14
  • 10
266
votes
10 answers

Should images be stored in a git repository?

For a distributed team that uses Git and GitHub as version control, should images also be stored in the git repository? The images in question are small/medium-sized web-friendly images. For the most part, the images won't be changed. The folder…
spong
  • 9,361
  • 6
  • 44
  • 58
265
votes
33 answers

How do you tell if advice from a senior developer is bad?

Recently, I started my first job as a junior developer and I have a more senior developer in charge of mentoring me in this small company. However, there are several times when he would give me advice on things that I just couldn't agree with (it…
learnjourney
  • 301
  • 2
  • 4
  • 10
264
votes
22 answers

How are globals any different from a database?

I just ran across this old question asking what's so evil about global state, and the top-voted, accepted answer asserts that you can't trust any code that works with global variables, because some other code somewhere else might come along and…
Mason Wheeler
  • 82,151
  • 24
  • 234
  • 309
262
votes
7 answers

What does the Spring framework do? Should I use it? Why or why not?

So, I'm starting a brand-new project in Java, and am considering using Spring. Why am I considering Spring? Because lots of people tell me I should use Spring! Seriously, any time I've tried to get people to explain what exactly Spring is or what…
sangfroid
  • 3,219
  • 4
  • 17
  • 12
259
votes
21 answers

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) { if (object->value < 0) return false; if…
257
votes
137 answers

Perks for new programmers

I intend on hiring 2-3 junior programmers right out of college. Aside from cash, what is the most important perk for a young programmer? Is it games at work? I want to be creative... I want some good ideas
Autobyte
256
votes
33 answers

How can I deal with the cargo-cult programming attitude?

I have some computer science students in a compulsory introductory programming course who see a programming language as a set of magic spells, which must be cast in order to achieve some effect (instead of seeing it as a flexible medium for…
Aivar
  • 301
  • 2
  • 4
  • 12
252
votes
11 answers

Why do many exception messages not contain useful details?

It seems there is a certain amount of agreement that exception messages should contain useful details. Why is it that many common exceptions from system components do not contain useful details? A few examples: .NET List index access…
Martin Ba
  • 7,578
  • 7
  • 34
  • 56
250
votes
16 answers

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 my own words) often "comments are apologies for…
Aviv Cohn
  • 21,190
  • 31
  • 118
  • 178