Most Popular

1500 questions
68
votes
14 answers

What is best practice on ordering parameters in a function?

Sometimes (rarely), it seems that creating a function that takes a decent amount of parameters is the best route. However, when I do, I feel like I'm often choosing the ordering of the parameters at random. I usually go by "order of importance",…
Casey Patton
  • 5,241
67
votes
13 answers

How to avoid comments about one line of code for cleanliness

I'm trying to clean up some of my code using some best practices, and read that comments are almost always a bad idea for future maintainability. I've managed to get rid of most of them by refactoring to methods with good names. However, there are…
Adam B
  • 1,595
  • 2
  • 12
  • 20
67
votes
7 answers

How to name something when the logical option is a reserved keyword?

Occasionally, the most logical name for something (e.g. a variable) is a reserved keyword in the language or environment of choice. When there is no equally appropriate synonym, how does one name it? I imagine there are best practice heuristics for…
67
votes
8 answers

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 can't speak for other systems (although to me it's…
67
votes
5 answers

When should I use event-based programming?

I have been passing callbacks or just triggering the functions from other function in my programs to make things happen once tasks complete. When something finishes, I trigger the function directly: var ground = 'clean'; function shovelSnow(){ …
J.Todd
  • 3,823
67
votes
4 answers

Why do VMs need to be "stack machines" or "register machines" etc.?

(This is an extremely newbie-ish question). I've been studying a little about Virtual Machines. Turns out a lot of them are designed very similarly to physical or theoretical computers. I read that the JVM for example, is a 'stack machine'. What…
Aviv Cohn
  • 21,388
67
votes
2 answers

Should I always use "is" as prefix for boolean variables?

Should I always use is as prefix for boolean variables? What about booleans that indicate something in past? Should I write isInitialized or wasInitialized? Should I write for properties IsManyMembers or HasManyMembers? Is there any best practices?…
67
votes
16 answers

How much freedom should a programmer have in choosing a language and framework?

I started working at a company that is primarily C# oriented. We have a few people who like Java and JRuby, but a majority of programmers here like C#. I was hired because I have a lot of experience building web applications and because I lean…
Spencer
  • 395
67
votes
7 answers

Why is there no 'finally' construct in C++?

Exception handling in C++ is limited to try/throw/catch. Unlike Object Pascal, Java, C# and Python, even in C++ 11, the finally construct has not been implemented. I have seen an awful lot of C++ literature discussing "exception safe code". Lippman…
Vector
  • 3,180
  • 3
  • 22
  • 25
67
votes
14 answers

How to prevent code from leaking outside work?

Possible Duplicate: How to manage a Closed Source High-Risk Project? I'm working on an institution that has a really strong sense of "possession" - each line of software we write should be only ours. Ironically, I'm the only programmer (ATM), but…
AeroCross
  • 871
67
votes
14 answers

Isn't MVC anti OOP?

The main idea behind OOP is to unify data and behavior in a single entity - the object. In procedural programming there is data and separately algorithms modifying the data. In the Model-View-Controller pattern the data and the logic/algorithms are…
Random42
  • 10,440
67
votes
10 answers

Is it worth making a commit solely to resolve non-critical typos?

If I come across a non-critical typo in code (say, an errant apostrophe in a print(error) statement), is it worth making a commit to resolve that error, or should it simply be left alone? Specifically, I'm curious about weighing the gumming-up of…
67
votes
9 answers

Is committing/checking in code everyday a good practice?

I've been reading Martin Fowler's note on Continuous Integration and he lists as a must "Everyone Commits To the Mainline Every Day". I do not like to commit code unless the section I'm working on is complete and that in practice I commit my code…
Sled
  • 1,868
  • 3
  • 17
  • 24
67
votes
10 answers

At what point can I say I've "learned" a language?

In my few years of programming, I've toyed with everything from Ruby to C++. I've done everything from just learning basic syntax (Ruby) to completing several major (for me) projects that stretched my abilities with the language. Given this…
SomeKittens
  • 4,240
67
votes
15 answers

I'm going to quit my job because of our platform: how can I leave a productive explanation of this?

I'm planning on leaving my current job because we're locked into using Blub, with an enterprise Blub framework and a Blub-level web server, on mediocre shared hosting. My coworkers are friendly and my boss is an average small business owner - I want…