Questions for best practices for writing high quality code.

learn more… | top users | synonyms

10
votes
3answers
1k views

What is the pattern name for using method chaining to build an object?

I frequently use a pattern where I using method chaining to setup an object, similar to a Builder or Prototype pattern, but not creating new objects with each method call, instead modifying the ...
4
votes
3answers
1k views

Should a method do one thing and be good at it? [duplicate]

"Extract Till You Drop" is someting I've read in Uncle Bob's blog, meaning that a method should do one thing alone be good at it. What is that one thing? When should you stop extracting methods? ...
13
votes
14answers
2k views

how to find out if spelling mistakes in source code are a serious issue or not?

I find very troubling amount of spelling mistakes I see everyday in our codebase, from which I will reproduce a very short but representative example: ArgumnetCount Timeount Gor message from queue ...
7
votes
5answers
303 views

Splitting 1 large object into 2 tightly-coupled ones - good, bad?

I have a complex object (call it BusinessLogic) which provides an RPC interface to semi-trusted users. The functions in the RPC interface have to decide which procedure to call, check authorisation ...
3
votes
5answers
458 views

What is considered best practice for printing usage / help (--help)?

When writing tools for the CLI of UNIX, how should I make the program print out help and/or usage? I usually use fprintf(stderr, "help text here");, but there are several issues with that. First, ...
-3
votes
4answers
288 views

What are good strategies in C for dealing with pointer errors of this type?

In C, I often come across errors with code like this prio_queue->head[index] = newEntry; Yields a " "Cannot assign Entry** to Entry* " How do you prevent/debug errors of this type, in general? ...
3
votes
2answers
226 views

How to go about bring up the topic of bad programming practices with colleague [duplicate]

Possible Duplicate: How do I approach a coworker about his or her code quality? My development colleague is producing numerous blocks of code which I am a bit concerned doesn't really make ...
2
votes
2answers
193 views

How do you handle minor change in source code causing discontinuity in version tree?

For instance, I have a file with poor indentation (at least incoherant with the rest of the project). If I correct the indentation and commit, there will be a serious change in the file at a certain ...
36
votes
10answers
3k views

How can I quantify the amount of technical debt that exists in a project?

Does anyone know if there is some kind of tool to put a number on technical debt of a code base, as a kind of code metric? If not, is anyone aware of an algorithm or set of heuristics for it? If ...
55
votes
16answers
2k views

Do We Have a Responsiblity to Improve Old Code?

I was looking over some old code that I wrote. It works, but it's not great code. I know more now than I did at the time, so I could improve it. It's not a current project, but it's current, ...
10
votes
6answers
1k views

Need to make my code more readable to the other programers in my team

I am working a project in delphi 7 and I am creating a installer for the application, there are Three main parts. PostgreSQL installation/uninstallation myapplication ( setup of myapplication is ...
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 ...
0
votes
2answers
1k views

What are the things that you consider in reviewing an iOS source code? [closed]

We're going to do some peer reviews for our iOS projects. We're kind of inexperienced at reviewing each other's codes. The iOS developers attending the reviews will be from other projects, since ...
1
vote
1answer
237 views

How to quantify benefits from a programming training?

I'm conducting a programming training for 3 months. Details in this link - Programming Training Details. My question is "How do we quantify benefits from such training?". I think the two important ...
18
votes
5answers
726 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 ...
7
votes
2answers
512 views

Are there any opensource APIs that help analyze code?

As an example, let's say that I need to check for a certain usage of C# code and warn the user that that is a bad pratice. There are multiple usages that I want to detect, such as: Resource not ...
1
vote
5answers
148 views

Automatic sorting of class/module members and its possible impact on productivity and code quality

Recently I saw some possibilities of some IDEs (via plugins) to sort members of their classes/modules based on some criteria, sou you could have everything sorted automaticaly no matter where you ...
37
votes
12answers
3k views

How do I approach a coworker about his or her code quality?

I work on a new venture at a large enterprise software company (3000+ programmers). In my group, we have a bunch of projects and people usually work on several projects over the course of a year. I ...
5
votes
5answers
911 views

Example bad code project to motivate refactoring / good design [closed]

This is sort of the opposite of Is there an open-source project that can be an example of well-written code?. I am teaching software engineering to undergraduates and I would like a blob of object ...
35
votes
11answers
4k views

What does a code review look like? [duplicate]

I'm writing a code review process document for our team; we've never had a formal process in place although we do do some code review. I've found lots of articles talking about how important code ...
7
votes
10answers
1k views

Overcome clumsiness in writing code

I believe this is a little related with this question: How to be a zero-bug programmer?. But I believe this is more regarding clumsiness in programming because I know it is impossible to become a zero ...
8
votes
4answers
181 views

Advice/Approach for distilling homogenous code and building common code for a team

I work for the State of California. Our programming team in my opinion is not really a 'team' in that we usually work solo on projects throughout the application/systems complete life-cycle. The end ...
9
votes
7answers
2k views

Keep my classes and methods as small as possible?

A few days ago, I was talking to a Software Engineering PhD candidate and at some point she said to me: Keep your classes and methods as small as possible And I wonder if this is always a good ...
2
votes
2answers
271 views

SONAR and DesignForExtensionCheck Rule

When enabling SONAR on an in-house Java project, there are a large number of violations being reported due to the rule DesignForExtensionCheck. Whilst I agree with the theory that all classes/methods ...
2
votes
3answers
278 views

in doubt of using code generators

I am now entering the world of java ee 6. And I am supposed to used different technologies like jsf, jpa, different kinds of beans and all that stuff. I am learning using the netbeans IDE, which is, ...
10
votes
3answers
2k views

How can I define and measure simplicity in code?

There are many answers in my previous question about simplicity relating to readability that helped me see my definition and understanding of simplicity in code was, quite possibly, incorrect. How ...
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 ...
10
votes
7answers
521 views

How do I go from being able to write code to being a good developer?

I'm frustrated by the lack of concrete explanations on how to go from being able to script (bash, awk) and write simple applications (c, php, python) to designing and developing larger, more ...
10
votes
3answers
1k views

How to write manageable code with functional programming?

I just started with functional programming (with JavaScript and Node.js) and from the look of things it looks as if the code I am writing would grow to be one hell of a code base to manage, when ...
3
votes
2answers
213 views

Getting solutions off the internet. Bad or Good? [closed]

I was looking on the internet for common interview questions. I came upon one that was about finding the occurrences of certain characters in an array. The solution written right below it was in my ...
3
votes
3answers
487 views

How can I convince my managers to enforce documentation standards?

I'm trying to convince another group in my company— that's about to hand code off to my group—that they need to provide more documentation in their source code, but they're treating it as a "nice to ...
13
votes
10answers
2k views

About empty line of code

Why do my colleagues hate it when I add an empty line of code? Sometimes I add a few lines to see when a method ends and another one starts more easily.
35
votes
8answers
5k views

How can I learn to effectively write Pythonic code?

Doing a google search for "pythonic" reveals a wide range of interpretations. The wikipedia page says: A common neologism in the Python community is pythonic, which can have a wide range of ...
5
votes
5answers
519 views

Is it OK to use dynamic typing to reduce the amount of variables in scope?

Often, when I am initializing something I have to use a temporary variable, for example: file_str = "path/to/file" file_file = open(file) or regexp_parts = ['foo', 'bar'] regexp = new ...
3
votes
7answers
266 views

How best to prevent having to revisit a change after check in

Normally what happens is that I work on something for a while and then when I am done I check it in(After the test/review process of course). Sometimes I have to go back and fix something that I got ...
3
votes
1answer
278 views

Is there an industry standard for structuring code and comments?

I've worked with a number of professional teams and it seems that class code structure ranges from highly organized to completely cluttered. I did a project with the State of California recently and ...
27
votes
9answers
2k views

How clean should new code be? [duplicate]

I'm the lead designer in our team, which means I'm responsible for the quality of the code; functionality, maintainability and readability. How clean should I require my team members' code to be if ...
42
votes
11answers
6k views

Should I reuse variables?

Should I reuse variables? I know that many best practice say you should not do it, however later when different developer is debugging the code and have 3 variables that look a like and only ...
16
votes
13answers
275 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 ...
5
votes
1answer
86 views

To Press Onward or Not?

In the past week I've been meeting and speaking with someone who's interested in finding help on developing a game (built using php and mysql, with a little bit of javascript). I agreed to help out, ...
1
vote
3answers
1k views

What is the acceptable failure rate for software?

Say I produce some software with a genetic algorithm. In order to be certain that the software works correctly in all situations, I would need to test all situations, which could be prohibitively (or ...
65
votes
14answers
4k views

How can I tactfully suggest improvements to others' badly designed code during review?

I'm a great believer in clean code and code craftsmanship, though I'm currently at a job where this isn't regarded as a top priority. I sometimes find myself in a situation where a peer's code is ...
2
votes
1answer
331 views

Is @staticmethod proliferation a code smell?

Consider a Python class with a number of @staticmethod methods and few instance methods. The static methods don't accept an instance of the defining class as parameters. Do you think that all these ...
19
votes
9answers
811 views

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

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 ...
5
votes
3answers
633 views

Handling false positives and legacy code warnings in static-analysis of C++ code? [closed]

We have a large "legacy" C++ code base on which no static analysis is run at the moment. Every now and then, we are thinking about at least using cppcheck, maybe via Visual Lint. (I've also briefly ...
2
votes
5answers
341 views

What is a better word for aligning your nesting?

I was taught by an old-time programmer who called this nested code if(condition){ <div> <b>text <u>text</u></b><br/> <table> <tr> ...
7
votes
6answers
1k views

Prefer class members or passing arguments between internal methods?

Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...
21
votes
14answers
3k 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. ...
2
votes
5answers
1k views

Are ASP.NET MVC automated code good enough to be used in real live applications [closed]

I have been trying to get my hands dirty with ASP.NET MVC which looks pretty good (I am not certain, but some users say that even StackOverflow and other StackExchange websites made use of it). The ...
2
votes
3answers
2k views

General checklist before releasing software [closed]

I'm currently building a tool that my company intends to sell. I'm the sole developer on the project and it is being developed outside our normal code base and to a certain extent outside our normal ...