Questions for best practices for writing high quality code.

learn more… | top users | synonyms

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
217 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
536 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.
37
votes
8answers
7k 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
522 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
269 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
305 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 ...
28
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
7k 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 ...
17
votes
13answers
303 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
2k 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 ...
66
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
343 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
823 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
722 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
342 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> ...
8
votes
6answers
2k 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 ...
23
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
2k 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
3k 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 ...
3
votes
1answer
9k views

What is the best way to comment a deprecated class in Java?

I would like to know the best way to add a comment to identify a deprecated class in Java. Should I remove the previous comment added to the top of the class that helps another programmer to know what ...
7
votes
0answers
681 views

Website for code review [duplicate]

I know that we all are trying to improve our structure and style of our code, striving to be truly agile. Websites like Stack Overflow are great when you want an answer to a specific question but ...
6
votes
6answers
344 views

Formatting 'Complex' Math

Note: by 'complex' math I mean an equation with many steps involved and a wide mix of operators. A programmer should know the order that operators are evaluated in an equation. However it can be a ...
66
votes
14answers
4k views

Why is DRY important?

Quite simple, why would I want to write code that works for all cases and scalable data when all I need to do is repeat the same process a few times with a few minor tweaks? I'm unlikely to need to ...
5
votes
14answers
974 views

Are software developers who ignore quality/standards better for the company?

Do software developers who choose not to put code optimization, standards and best practices as top priority, create more useful code than those developers who choose to worry about optimization, ...
13
votes
12answers
1k views

What to do with a not well organized application? [duplicate]

I'm a newly graduate programmer and just got hired before my graduation. In the office, I used to create and revise modules of some applications developed by other programmers in our company. The ...
11
votes
3answers
244 views

Do I need to deal with the situation where private methods are called through reflection?

When creating a library, must I ensure that the private methods must work as expected when called not by other methods of the same class, but by another library through reflection? For example, if a ...
42
votes
12answers
4k views

Are there problems with using Reflection?

I don't know why, but I always feel like I am "cheating" when I use reflection - maybe it is because of the performance hit I know I am taking. Part of me says, if it is part of the language you are ...
17
votes
6answers
1k views

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

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 ...
9
votes
8answers
712 views

How to balance code quality vs strong developer personalities

On code reviews at work I have been seeing code & patterns that I consider "clever" though not necessarily adding to the overall quality or maintainability of the code base. I point this out on my ...
41
votes
12answers
3k views

Develop fast and buggy, then correct errors or be slow, careful for each line of code? [duplicate]

Possible Duplicates: Frankly, do you prefer Cowboy coding? Prototyping vs. Clean Code at the early stages Good design: How much hackyness is acceptable? Does craftsmanship pay off? ...
114
votes
30answers
10k views

Is micro-optimisation important when coding?

I recently asked a question on Stack Overflow to find out why isset() was faster than strlen() in PHP. This raised questions around the importance of readable code and whether performance improvements ...
3
votes
1answer
146 views

Ideas about how to prevent malicious code to go into production especially in case of SAAS environments

As nowadays SAAS is becoming popular way of developing and deploying the applications, and I have just started working at a company providing SaaS solution for payment authorization services. Since ...
28
votes
18answers
3k views

Why would a company develop an atmosphere which discourage code comments?

I was taught in university to write comments for our programs. As I write comments, I feel like I have a better organization and understand the programs better. However, I am in a company where most ...
3
votes
5answers
493 views

Minimising little coding mistakes [closed]

I make a fair amount of small mistakes when I code (things such as getting an angle bracket to the wrong direction). It adds a fair amount of time to my coding because I have to debug several times ...
66
votes
22answers
24k views

How do you define elegant code? [duplicate]

Possible Duplicate: What does it mean to write “good code”? In a discussion on coding quality, and how you identify it, I came across a discussion on testing people's coding ...
1
vote
6answers
553 views

What information should a good (method- / class-) comment contain?

This is something that has bothering me for a while now. I guess there are a couple of obvious important things that should go into a comment, such as: The author(s) A description of the parameters ...
8
votes
5answers
385 views

When developing on an old code base, should I use Best Practices or go for Consistency [duplicate]

Possible Duplicate: Code maintenance: keeping a bad pattern when extending new code for being consistent, or not ? As my experience in programming increases with each project, I look back ...
3
votes
5answers
827 views

How to convince my boss to switch to OOP PHP? [closed]

We have been trying for months to convince my boss to switch to OOP php, but each time, he takes out his previous experience with programming and convinces us other wise. i need to talk like a boss ...
2
votes
2answers
142 views

Should I update this code or continue with current design

I am working with ASP.NET Application. The application is great and works fine but it a few flaws. To give you an example, Every control uses an absolute position layout. This makes working with ...
10
votes
7answers
2k views

Is it beneficial to read old Java programming books? [closed]

Many of my Java books are 5 - 10 years old. Does it still help to read them, or should I use something within 2 years.
21
votes
6answers
581 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. ...
3
votes
3answers
389 views

Code mapping in .NET (or in general)

Does there exist a software solution of some form that has the ability to map out the actions of calling a function. So what I mean is, let's say that we have the following class. public class Foo ...
9
votes
7answers
3k views

What is beautiful code in C++, and why do most programmers care that much?

As most projects use a C++ API, they deal with constraints of the API and constraints of the project itself. I'm a beginner at programming, I don't like to use OOP at all because nobody clearly ...
62
votes
10answers
7k views

I'm forced to write bad code. How do I save my face? [closed]

I'm only a junior developer but my job forces me to work with really terrible PHP code (think about the worst PHP code you've seen; then think about code twice as bad). I usually try to fix bugs and ...
5
votes
6answers
310 views

How to keep a project easy to understand and intutive?

I am working on this project, which will soon contain loads of packages, projects etc. (Java). So, from the start I need to keep track of the high level package and class structure, monitor which ...
2
votes
6answers
334 views

C: What is a good source to teach standard/basic code conventions to someone newly learning the language? [closed]

I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single ...
153
votes
25answers
13k views

How to convince my boss that quality is a good thing to have in code? [duplicate]

My boss came to me today to ask me if we could implement a certain feature in 1.5 days. I had a look at it and told him that 2 to 3 days would be more realistic. He then asked me: "And what if we do ...