Questions for best practices for writing high quality code.

learn more… | top users | synonyms

25
votes
13answers
2k views

Fix bugs, or wait for the customer to find them?

Do other people fix bugs when they see them, or do they wait until there's crashes/data loss/people die before fixing it? Example 1 Customer customer = null; ... customer.Save(); The code is ...
25
votes
10answers
3k views

Are flag variables an absolute evil?

I remember doing a couple of projects where I totally neglected using flags and ended up with better architecture/code; however, it is a common practice in other projects I work at, and when code ...
24
votes
15answers
2k views

Does simplicity always improve Readability?

Recently, I was developing a set of coding standards for our company. (We're a new team branching out into a new language for the company.) On my first draft, I set the purpose of our coding ...
23
votes
17answers
6k views

What are useful metrics for source code? [closed]

What are useful metrics to capture for source code? How can metrics, like for example (Executable?) Lines of Code or Cyclomatic Complexity help with quality assurance or how are they beneficial in ...
22
votes
8answers
1k views

Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth) [duplicate]

The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]: Use comments sparingly! (I bet that's welcome.) Remember that program you looked through - the ...
22
votes
15answers
949 views

How do I convince my team to use smaller classes/methods?

Disclaimer: I'm a newcomer (this is my third day of work), and most of my teammates are more experienced than me. When I look at our code, I see some code smells and bad engineering practices, like ...
22
votes
17answers
962 views

Dealing with co-workers who do not have a consistent coding style?

What do you when you're working with someone who tends to write stylistically bad code? The code I'm talking about is usually technically correct, reasonably structured, and may even be ...
22
votes
5answers
1k views

What is the politically correct way of refactoring other's code?

I'm currently working in a geographically distributed team in a big company. Everybody is just focused on today's tasks and getting things done, however this means sometimes things have to be done the ...
22
votes
9answers
2k views

My coworker is a nice guy, but his performance is sub-par. Do I tell my boss?

I was placed on a project about three months ago that was until then under development by a single, newly hired developer because it was falling behind. To be fair, the project is an interface to a ...
21
votes
16answers
2k views

What is the hardest bug to find? [closed]

If possible write how to avoid this kind of bug (besides testing, of course, please write a specific technique)
21
votes
14answers
836 views

How do you overcome your own coding biases when handed legacy code?

As programmers, we often take incredible pride in our skills and hold very strong opinions about what is 'good' code and 'bad' code. At any given point in our careers, we've probably had some legacy ...
21
votes
14answers
2k views

Why do so many developers believe performance, readability, and maintainability cannot coexist?

While responding to this question, I began to wonder why so many developers believe a good design should not account for performance because doing so would affect readability and/or maintainability. ...
21
votes
7answers
1k views

Quality of Code in unit tests?

When writing unit tests, is it worth spending the extra time to make the code have good quality and readability? When writing tests I often break the Law of Demeter, for faster writing and to avoid ...
21
votes
13answers
1k views

How do you ascertain the quality of a potential employer's code before you take a position?

In my experience before you start working for a company you have no opportunity to look at the code-base (I've asked and for reasons of confidentiality everyone has always said no, I think that is ...
21
votes
5answers
1k views

Is code ownership a code smell?

This is something I've been thinking about ever since I read this answer in the controversial programming opinions thread: Your job is to put yourself out of work. When you're writing ...
21
votes
6answers
519 views

How to encourage version control adoption

I have recently started working in a team where there is no version control. Most of the team members are not used to any kind of version control. I've been using mercurial privately to track my work. ...
20
votes
11answers
3k views

How much Code Coverage is “enough”?

We are starting a push for code coverage here at my work, and it has got me to thinking.... How much code coverage is enough? When do you get to the point of diminishing returns on code coverage? ...
20
votes
8answers
1k views

What are the disadvantages of writing code before writing unit tests?

I have always seen the recommendation that we should first write unit tests and then start writing code. But I feel that going the other way is much more comfortable (for me) - write code and then the ...
20
votes
8answers
1k views

How to justify rewriting/revamping legacy software in a business case? [duplicate]

I work for a great little software company which makes good revenue from our main software package. The problem for me is that it's almost unmaintainable. It's written in Delphi 7 (has upgraded ...
20
votes
8answers
1k views

Organizing uncommented, dirty code?

I would like to ask you some questions about dirty code. There are some beginners who coded on a medium project. The code is a very huge ball of mud. They are not advanced programmers. They just know ...
20
votes
9answers
776 views

Is it better to use pre-existing bad practices, or good practices that don't fit well with old code?

I was thinking of this because I was trying to write an extension for an existing 3rd party software, and their database is horribly denormalized. I needed to use their existing tables and add a bunch ...
20
votes
3answers
995 views

How does office bureaucracy affect code quality

I'm interested in stories where office bureaucracy has had direct effect on the final code quality result. For example, a friend just told me that at his previous work place the version control ...
19
votes
8answers
1k views

Adding complexity to remove duplicate code

I have several classes that all inherit from a generic base class. The base class contains a collection of several objects of type T. Each child class needs to be able to calculate interpolated ...
19
votes
7answers
884 views

Can working with bad code erode your programming skills?

Can working with bad code erode your programming skills?
19
votes
9answers
1k views

What exactly makes code “clean”? [duplicate]

I am an intern at a small software company, doing typical grunt work. Many tasks that the actual developers are doing are above my head however I finally got to see some real "action" and write some ...
18
votes
9answers
3k views

Is there any reason to use “plain old data” classes?

In legacy code I occasionally see classes that are nothing but wrappers for data. something like: class Bottle { int height; int diameter; Cap capType; getters/setters, maybe a ...
18
votes
5answers
697 views

Keep it simple now, or program with the future in mind?

I'm currently coding a new application for my company that is rather involved. To meet the deadline, the functionality has been toned down quite a bit so that we can have something ready to go for ...
17
votes
8answers
912 views

Do you prefer conciseness or readability in your code?

Language shortcuts can often be used to make code more concise. For example, ternary and null coalescing operators can reduce the amount of code, but arguably to the detriment of readability: In C#: ...
17
votes
11answers
2k views

How to address the concerns of the software architect but still maintain collective code ownership? [duplicate]

The quality of the code in our software is indeed lacking. When you change a line of code in one component it usually breaks code in other components. Our software architect blames this on collective ...
17
votes
10answers
2k views

Is 100% code coverage a pipe dream?

Is it feasible to expect 100% code coverage in heavy jquery/backbonejs web applications? Is it reasonable to fail a sprint due to 100% coverage not being met when actual code coverage hovers around ...
17
votes
4answers
2k views

Why is test driven development missing from Joel's Test?

I was reading this blog by Joel Spolsky about 12 steps to better code. The absence of Test Driven Development really surprised me. So I want to throw the question to the Gurus. Is TDD not really worth ...
17
votes
5answers
1k views

Descriptive naming vs. 80 character lines [closed]

I frequently hear these two valuable programming practices: (1) lines of code should be 80 characters or less and (2) use descriptive names for variables, methods, classes, etc. I understand the ...
17
votes
15answers
1k views

What simple techniques do you use to improve performance?

I'm talking about the way we write simple routines in order to improve performance without making your code harder to read... for instance, this is the typical for we learned: for(int i = 0; i < ...
17
votes
9answers
1k views

How can I sell a legacy program rewrite to the business?

We have a legacy classic ASP application that's been around since 2001. It badly needs to be re-written, but it's working fine from an end user perspective. The reason I feel like a rewrite is ...
17
votes
8answers
701 views

Does anyone else have a refactoring problem? [closed]

It seems like after I've written a significant amount of code I get this anxious feeling like I haven't done it in the best possible way, and I end up continuously refactoring and spending way too ...
17
votes
6answers
901 views

Any success stories continuously using commercial static analysis tools for C++?

I can't decide whether an offer of a commercial static analysis tool is worth spending the resources. We tried the tool on several million lines of our C++ code and it found something like 50 real ...
17
votes
5answers
1k views

Is it OK for a function to modify a parameter

We have a data layer that wraps Linq To SQL. In this datalayer we have this method (simplified) int InsertReport(Report report) { db.Reports.InsertOnSubmit(report); db.SubmitChanges(); ...
17
votes
8answers
1k views

Releasing poorly written software [closed]

I've made a poorly written, yet fully functioning website, in (shock, horror, shock) PHP. Everything works as expected, I've implemented the necessary security measures: ...
16
votes
16answers
2k views

Do Programmers sometimes intentionally over complicate code? [closed]

It seems alot of times on stackoverflow, that people (programmers especially) tend to over complicate a solution to a problem to where the solution is vastly much more complicated then the original ...
16
votes
10answers
2k views

How can I quickly weed out “copy & paste” coders?

I need a way to filter out resumes of folks who just copy-and-paste code then hope it works, and check it in if it does. All this happens without having an understanding (or care) to understand the ...
16
votes
11answers
1k views

Why are we supposed to use short functions to sectionalize our code? [duplicate]

I've seen an increasing trend in the programming world saying that it is good practice to separate code blocks into their own functions. Obviously, if that code block is reusable, you should do that. ...
16
votes
10answers
3k views

Should a method validate its parameters? [duplicate]

Say you are designing a Square root method sqrt. Do you prefer to validate the parameter passed is not a negative number or do you leave it up to the caller to make sure the param passed is valid. How ...
16
votes
9answers
1k views

Are too many assertions code smell?

I've really fallen in love with unit testing and TDD - I am test infected. However, unit testing is normally used for public methods. Sometimes though I do have to test some assumptions-assertions ...
16
votes
7answers
464 views

Could an internal rep, voting and badges encourage good programming practices?

Just thinking out aloud - we programmers love all this voting/badges/rep stuff so could a scheme like this be introduced into a companies code review process to encourage better coding. Something ...
16
votes
13answers
256 views

How to name parts of your program as a non native English speaker [duplicate]

Possible Duplicate: Do people in non-English-speaking countries code in English? I am from the Netherlands and we speak Dutch. I have worked on quite a few projects now in various ...
15
votes
9answers
1k views

Dealing with a developer continuously ignoring edge cases in his work

I have an interesting, fairly common I guess, issue with one of the developers in my team. The guy is a great developer, work fast and productive, produces fairly good quality code and all. Good ...
15
votes
11answers
1k views

How should I manage a team with different skill levels?

I'll be working on a software project with some friends of mine, and I've been appointed technical lead. None of these guys is a bad programmer at all, but I do have significantly more experience than ...
15
votes
5answers
854 views

Is this pattern bad? [duplicate]

I notice that when I code I often use a pattern that calls a class method and that method will call a number of private functions in the same class to do the work. The private functions do one thing ...
14
votes
10answers
3k views

Do ALL your variables need to be declared private? [duplicate]

Possible Duplicate: Why do we need private variables? I know that it's best practice to stay safe, and that we should always prevent others from directly accessing a class' properties. I ...
14
votes
8answers
480 views

Methodologies of a high class development team

I've recently been tasked with increasing standards and efficiency within a development team. I've read similar posts about the makings of a good development team but these often discuss the human ...