Questions for best practices for writing high quality code.

learn more… | top users | synonyms

2
votes
2answers
48 views

How to reduce redundancy in a service implemented using multilayer architecture while maintaining consistency across the system?

Currently our service is implemented using a multilayer architecture dividing the whole service into three: API Business Persistence However this introduces a lot of redundancy within our system. ...
0
votes
1answer
108 views

How to define dependent function in node js?

I have a nodejs project in which a sample.js include two function function A depends on function B's callback . // smaple.js Both function are included in the same file function B ( ...
6
votes
3answers
348 views

Fine Line: Readability Vs Speed [duplicate]

Is there a line between readability vs compile or processing speed? Aside from the extreme cases, I wouldn't think it would be even worth saving that little bit extra in favor of legibility... For ...
4
votes
1answer
57 views

Should a web service return an error message if it receives unknown parameters?

I have a web service which allows to retrieve users: http://example.com/users. It returns a list of users. That service accepts a number of parameters (age, gender) to select which users to retrieve. ...
101
votes
15answers
7k views

How can I convince management to deal with technical debt?

This is a question that I often ask myself when working with developers. I've worked at four companies so far and I've become aware of a lack of attention to keeping code clean and dealing with ...
8
votes
2answers
1k views

What does Uncle Bob mean by 'noun phrase names'?

I am reading Clean Code by Uncle Bob. Because I am not a native-English speaker, I couldn't understand following statement: Classes and objects should have noun or noun phrase names like ...
1
vote
1answer
36 views

SDK/DB isDeleted vs Integration Testing

((Using "users" as an example to represent one of many record types)) An application with user tracking typically has a User table. Many, if not all, companies mandate that a User record should ...
1
vote
1answer
150 views

Right-aligning code [closed]

I recently was looking for a CSS solution to vertically-align elements, and I found one here. One thing that I thought was nice was the right-justified code; example: .vertical-center { // ... ...
7
votes
1answer
162 views

Do we need to validate entire module usage or just arguments of public methods?

I've heard that it is recommended to validate arguments of public methods: Should one check for null if he does not expect null? Should a method validate its parameters? MSDN - CA1062: Validate ...
0
votes
1answer
32 views

Dealing with data containing integer overflow, rollover

I am writing a small matlab function to analyze data from a laser probe. The data to be analyzed is basically: x-data: Position. y-data: Laser (light) intensity. ...
176
votes
17answers
18k views

How would you know if you've written readable and easily maintainable code?

How would one know if the code one has created is easily readable, understandable, and maintainable? Of course from the author's point of view the code is readable and maintainable, because the author ...
2
votes
3answers
62 views

Order of terms in a conditional expression [duplicate]

Consider the following loop (in Swift - but my question is language independent): var index = standardizedTimeSpans.count - 1 while index >= 0 && timeSpan < ...
2
votes
0answers
62 views

Is a long XSLT file a code smell? [closed]

Is a long XSLT file a code smell? In imperative programming languages it's generally acknowledged that very large classes and/or sub-routines are an indication of possible problems, e.g. a class ...
0
votes
2answers
141 views

Is cyclomatic complexity density a good software quality metric? [duplicate]

Where I define Cyclomatic complexity density as: Cyclomatic complexity density = Cyclomatic complexity / Lines of code I was reading previous discussions about cyclomatic complexity and there seems ...
2
votes
2answers
133 views

What is the proper way to handle this workflow in TFS

A client of mine is using TFS and asks people to operate in this manner: The developer in India writes the first draft of code The code is published to a workspace (eg 10.1.1.1\TFSName ...
0
votes
2answers
52 views

Built-in the separate thread execution inside of the method or wrap the method by the thread

Let assume, I have some resource and time-consuming code, which I want to arrange as a separate method. In order to optimize the performance, this code should be executed in the separate thread. Now ...
15
votes
6answers
680 views

How can I judge whether a project is particularly complex or if I'm just slow in picking it up?

I'm making little progress on a major project. The source is massive, many layers of objects, macaroni code, double-diamond graphs of multiple inheritance, half-baked features frozen when the ...
14
votes
14answers
2k views

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

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 ...
47
votes
7answers
5k views

What is the actual value of a consistent code style

I am part of a consultant team implementing a new solution for a customer. I am responsible for the majority of code reviews on the client-side codebase (React and javascript). I have noticed that ...
7
votes
6answers
563 views

What can go wrong with composing a method name out of a string?

I have a piece of code that composes method name to call from a string parameter. I don't feel it's a good thing to do but I'm not sure what can go wrong with this. Here is a simplified snippet of ...
1
vote
0answers
46 views

Managing interdependent project reference in solution file

Context for question I am working on a legacy product, that has multiple projects - Class libraries, websites, windows services, web services etc.. I have a single solution file that contains all ...
1
vote
2answers
158 views

What about source code homogeneity?

As time passes I think that one valuable aspect of maintenable and escalable software is to be homogeneous. The same problem should be solved in the same way everywhere in the application. If there is ...
8
votes
3answers
521 views

Cleanest way to write logically procedural software in an OO language

I'm an electrical engineer and I don't know what the hell I'm doing. Please save the future maintainers of my code. Recently I've been working on a number of smaller programs (in C#) whose ...
0
votes
1answer
64 views

Is a number used only once and directly bound to a function parameter a magic number? [duplicate]

I want to avoid numbers used directly in expressions without obvious meaning. However, if a number is used only once, as an argument passed into a function, and that number can be easily changed ...
23
votes
9answers
2k 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 ...
12
votes
7answers
517 views

Where do you draw the line between quantity and quality? [duplicate]

My manager has talked with me and says that the quality of my work is excellent, but I need to step up the quantity of how much I crank out. I've only been working for a couple of years, so I still ...
162
votes
25answers
15k 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 ...
6
votes
6answers
704 views

What are the most used pattern to manage a lot of interconnected parameters?

I recently start to work on an application that drive different measurement device. Before the user start a measure, she sets the parameters of it. Actually, considering all measurements type there ...
1
vote
2answers
435 views

Class becoming God Object what pattern to use

I am developing Android app and my MainActivity is becoming God Object. By the way native Activity class implementation is some sort of God Object already. The problem is that my activity class is ...
34
votes
6answers
4k views

How can I write unit tests that simplify feature implementation? [duplicate]

I'm a newbie to working in software development and I read a lot about how cool unit tests are. Now, I've made my first steps into a project where I'm working with a number of equally unexperienced ...
10
votes
6answers
877 views

Which is more maintainable — boolean assignment via if/else or boolean expression?

Which would be considered more maintainable? if (a == b) c = true; else c = false; or c = (a == b); I've tried looking in Code Complete, but can't find an answer. I think the first is more ...
58
votes
18answers
5k views

How to tell your boss that his programming style is really bad? [duplicate]

I'm a student and in my spare time I'm working for a big enterprise as Java developer. The job is good, but the problem is, my boss writes very strange code. I don't want to complain, but some issues ...
13
votes
2answers
1k views

Is an NPath complexity of over sixteen octillion realistic? Or have I broken the tool?

I have just measured a large chunk of PHP code (1153 lines) using PHPMD (http://phpmd.org/) and it tells me the code has an NPath complexity of 16244818757303403077832757824. That looks like a ...
34
votes
9answers
2k views

At what point does “constructive” criticism of your code become unhelpful?

I recently started as a junior developer. As well as being one of the least experienced people on the team, I'm also a woman, which comes with all sorts of its own challenges working in a ...
0
votes
0answers
33 views

Defensive Programming - “Return” placement [duplicate]

Sometimes I see myself writing code in the following way: if(value == null) return null; //... I will have here as many defensive conditions (and returns) as I need //... Continue to execute method ...
54
votes
9answers
10k views

Bad sign if nobody can comprehend one's code? [duplicate]

If a coder writes code that nobody other than he can understand, and code reviews always end with the reviewer scratching his head or holding their head in their hands, is this a clear sign that the ...
-1
votes
2answers
96 views

Personalization of code: Personalized debugging message, personalized strings and project tags [closed]

I was given a code review today by a coworker. 1) I'm told not to use personalized tags to aid in searching for important portions of the code. For example: Personalized Strings, for example ...
165
votes
24answers
18k views

When is a BIG Rewrite the answer?

Just read the question about the Big Rewrites and I remembered a question that I've been wanting answered myself. I have a horrible project passed down to me, written in old Java, using Struts 1.0, ...
72
votes
15answers
19k views

What's wrong with circular references?

I was involved in a programming discussion today where I made some statements that basically assumed axiomatically that circular references (between modules, classes, whatever) are generally bad. ...
0
votes
1answer
83 views

Multiple if in comparison function vs chain of || or && [duplicate]

I'm writing a function (or operator==() in C++), comparing two objects. The code looks like this: bool operator==(const Obj& copy1, const Obj& copy2) { if(copy1.a!=copy2.a) return ...
0
votes
1answer
111 views

Passing same argument to multiple small functions versus doing everything in one big function?

I have inherited a class method from another developer, which looks like below: (Note: Class:X means X is a member of Class in the OOP paradigm.) Class:BigFunction() { ImportantValue = ...
89
votes
16answers
7k 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 ...
122
votes
30answers
12k 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 ...
29
votes
11answers
3k views

What factors should influence how I determine when to abandon a small project with a friend? [closed]

I've found myself in a tough spot as of late. Been working on a game with a programming buddy for nearly 8 months now. We both started off as newcomers to programming around August of last year, he is ...
2
votes
2answers
194 views

Is there a software industry for converting old, outdated code to new standards? [duplicate]

There still are developers building and extending applications using languages like COBOL, since banks and other such organizations rely on ancient systems to power their day to day businesses. Some ...
3
votes
1answer
125 views

Including standard library headers only once across multiple program headers

I am writing a program with multiple headers and code files, as so: message.h message.cpp option.h option.cpp main.cpp message.h includes option.h as message.cpp requires the definition of the ...
18
votes
7answers
11k views

What should my “code sample” look like? [closed]

I've just had quite a good phone interview (for a CakePHP-related position, not that it's especially important to the question). The interviewer seemed to be impressed with my resume and personality. ...
0
votes
0answers
67 views

GMP Core Dump while using mpz_clear in C

I'm working on a prime factorization program written in C using the GMP library through cygwin. The algorithm that I have now works fine, but has memory leaks from not using the mpz_clear function on ...
5
votes
3answers
2k 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? ...
112
votes
10answers
12k views

On developing deep programming knowledge

Occasionally I see questions about edge cases and other weirdness on Stack Overflow that are easily answered by the likes of Jon Skeet and Eric Lippert, demonstrating a deep knowledge of the language ...