Questions for best practices for writing high quality code.

learn more… | top users | synonyms

0
votes
1answer
50 views

Should I always use prefix private methods with an underscore in Python?

Prefixing methods and members with an underscore indicates internal use. For simple classes, I sometimes find the easier reading and typing of self.foo outweighing the indent of self._foo. Especially ...
2
votes
2answers
61 views

How to avoid code duplication or cascaded changes and major refactoring in business logic layer?

Let's say, I have created a business logic layer service (or a handler in Command/Query pattern) with a method DoSomething which processes a bunch of entities and stores them in database. Later on, ...
5
votes
2answers
124 views

Create a new variable to shorten code

I have often wondered about the implications of shortening code by assigning temporary variables with shorter names to data accesses with long names. It's best illustrated by an example (in Ruby, but ...
7
votes
7answers
1k views

Why would an employer ask for a 'long' code sample? [closed]

What would a large project that spanned multiple files and >1000 lines show to an employer that a few individual files and a couple hundred lines couldn't capture?
2
votes
3answers
1k views

Recommended guidelines for declaring bash/sh variables

I have been programming in BASH for a while now and the scripts that I write are starting to get more complicated. I realized that I started to bring in some habits from C/C++ and wanted to get ...
17
votes
7answers
618 views

Peer / Code Review Frustrations

I wouldn't call myself a superstar dev, but a relatively experienced one. I try to keep code quality to a high level, and am always looking to make improvements to my coding style, try to make code ...
165
votes
20answers
20k views

A large part of my code has a major design flaw. Finish it off or fix it now?

I am a high school student working on a C# project with a friend of mine with about the same skill level as me. So far, we have written roughly 3,000 lines of code and 250 lines of test code in a span ...
28
votes
13answers
1k views

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

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

Is nesting try-catch statements still a code smell if nested within a loop?

I have heard that nesting try-catch statements can often be a code smell, so I'm wondering whether this situation is an exception. If not, what would be some good ways to refactor? My code looks like ...
0
votes
1answer
38 views

Static analysis criteria different for various parts of solution

We have quite a large project where and tend to apply risk based approach to stringency of unit tests and code reviews. E.g. components classified as A need to have higher coverage than components ...
-2
votes
1answer
100 views

Duplicate code to avoid performance decrease due to function calls? [closed]

I have a simple list in Java that I need to search using one of two methods. The first method simply returns the position in the list of the first matching element. The second filters out any elements ...
21
votes
7answers
24k views

Avoid too complex method - Cyclomatic Complexity

Not sure how to go about this method to reduce Cyclomatic Complexity. Sonar reports 13 whereas 10 is expected. I am sure nothing harm in leaving this method as it is, however, just challenging me how ...
12
votes
8answers
965 views

Do you believe it's a good idea for Software Engineers to have to work as Quality Assurance Engineers for some period of time? [closed]

I believe it is. Why? I've encountered many Software Engineers who believe they are somehow superior to QA engineers. I think it may help quench this belief if they do the job of a QA engineer for ...
245
votes
7answers
20k views

Does using == in JavaScript ever make sense?

In JavaScript, the Good Parts, Douglas Crockford wrote: JavaScript has two sets of equality operators: === and !==, and their evil twins == and !=. The good ones work the way you would expect. ...
7
votes
4answers
235 views

Code design: Duplicate code or good implementation

I'm working on application in C#, where I need to serialize and deserialize some classes into/from XML. This operations will be implemented in Class Library. I chose XMLSerialization class to ...
1
vote
2answers
108 views

Get variable with accessor method or just use dot notation?

So, I recently noticed something on some code I was writing. I could get a variable for a different class/object using dot notation to get the variable: object.someVarable or I could do it the way I ...
1
vote
1answer
63 views

how to measure defects per KLOC

I have been reading on the internet about the metric "number of bugs per 1000 lines of code" and what would be a good number. However, I wonder how someone would compute such a metric? The reason a ...
0
votes
0answers
32 views

What is the common practice of calculating average length of identifiers

Quoted from Ian Sommerville's Software Engineering(9th ed), page 673: This is a measure of the average length of identifiers (names for variables, classes, methods, etc.) in a program. The ...
-2
votes
1answer
147 views

Is this unprofessional when “Wappalyzer” sees all my technology? [closed]

After I installed "Wappalyzer", extension wich display technology, wich site using. I checked many sites and in most of cool projects, like "Youtube", "Github","stackoverflow" etc, wappalyzer display ...
8
votes
6answers
1k views

Code ownership with multiple Scrum teams

If two Scrum teams use the same software component, who is responsible for providing a clear architectural vision of that component and maintain/develop this vision as the code base evolves? In Scrum ...
27
votes
17answers
1k 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 ...
4
votes
1answer
249 views

Help in writing more generic code

I'm doing a php MVC project using code igniter. I have two models, a and b. Each class contains four functions (insert, delete, update and view) and their implementations are almost the same with ...
4
votes
6answers
462 views

When is it right to edit the code written by a co-worker? [duplicate]

For which issues is it right to edit the code written by a co-worker? For which issues is it wrong?
22
votes
9answers
3k views

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

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

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

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 ...
3
votes
8answers
3k views

Declaring functions in order to avoid explicit nested loops

My programming professor has told me that it is a good programming practice (at least in C/C++) to declare a function with the inner loop when nesting loops (not for loops, since when, i.e. looping ...
6
votes
4answers
260 views

Is using nested function calls a bad thing?

In a recent homework assignment I ended up calling my functions in an ugly way uglyReceipt(cashParser(cashInput())) the program itself worked perfectly but I still felt like I was doing something ...
58
votes
5answers
7k views

Why are large amounts of magic numbers acceptable in CSS and SVGs?

Often times I see questions on the Hot Network Questions list like this that basically ask "how do I draw this arbitrary shape in CSS". Invariably the answer is a couple of blocks of CSS or SVG data ...
99
votes
16answers
15k views

Should I add redundant code now just in case it may be needed in the future?

Rightly or wrongly, I'm currently of the belief that I should always try to make my code as robust as possible, even if this means adding in redundant code / checks that I know won't be of any use ...
4
votes
1answer
133 views

Define “Refactoring”

Everyone has heard this term thrown around, and most people, I would imagine, have a conceptual idea of the meaning. I, myself, am in that latter group. However, I feel that the definition Google/...
15
votes
10answers
3k views

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

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 ...
-1
votes
4answers
219 views

Emphasize Some Comments - but not Dirty the Code

I'm having trouble structuring my comments at the moment. I have major sections of the code that, when scrolling through the document, I want to be able to see those stand out. Examples: This is ...
22
votes
4answers
7k views

code review with git-flow and github

With regular git and github I can do a code review by simply creating a pull request of the feature branch I'm working on to the master branch. How would I do code reviews with git-flow? With workflow ...
5
votes
2answers
248 views

The concept of “quality gates” in software testing

We are using SonarQube for code quality testing. It tests the quality of code, and not the function of code. It has the concept of quality gates, so you can set for instance a 90% quality gate, ...
8
votes
9answers
1k views

How can I promote clean coding at my workplace?

I work with a lot of legacy Java and RPG code on an internal company application. As you might expect, a lot of the code is written in many different styles, and often is difficult to read because of ...
53
votes
12answers
3k views

How to take a step back and look at code with fresh eyes? [closed]

I've spent the last year as a one-man team developing a rich-client application (35,000+ LoC, for what it's worth). It's currently stable and in production. However, I know that my skills were rusty ...
2
votes
1answer
178 views

How to respond to bizarre requests in code reviews? [closed]

I think that code reviews are great and very helpful for everyone. With that being said, from time to time I've received feedback on a pull request (leading to the PR being delayed for at least as ...
4
votes
2answers
695 views

In terms of Software, what constitutes a quality control plan for ISO 9001 compliance?

I am bidding on a government contract (my first) and there is a section requesting that I provide a high-level outline of a quality control plan that would ensure that the end product is ISO-9001 ...
35
votes
13answers
11k views

Is commented out code really always bad? [duplicate]

Practically every text on code quality I've read agrees that commented out code is a bad thing. The usual example is that someone changed a line of code and left the old line there as a comment, ...
17
votes
16answers
2k views

Do else blocks increase code complexity? [closed]

Here is a very simplified example. This isn't necessarily a language-specific question, and I ask that you ignore the many other ways the function can be written, and changes that can be made to it.. ...
96
votes
13answers
16k views

Should we avoid language features that C++ has but Java doesn't to increase maintainability?

Suppose I am limited to use C++ by the environment in the project. Is it good to prevent the use of some language features that C++ has but Java doesn't have (e.g.: multiple inheritance, operator ...
1
vote
1answer
196 views

Is defining only one method against S in S.O.L.I.D

The first version of pseudo code I consider a code smell because of (I think) the Command Query Separation principle and/or the S in S.O.L.I.D. What I like to see is in the 2nd version. Should I keep ...
10
votes
15answers
1k views

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

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, ...
3
votes
1answer
324 views

Bad c++ code design? [closed]

This is bothering me a long time. I feel like I am doing mistakes on the code design relative to the performance. I never had any teacher to indicate my mistakes so its hard to me to make it right in ...
42
votes
13answers
6k views

I am making 4-5x more story points than average, but producing bugs at half the rate. Graphs say it's 2x more bugs, how to deal with that?

So it is generally accepted that top tier programmers can produce an order of magnitude more/better code than their more average peers. It's also generally accepted that the rate of errors made in ...
6
votes
3answers
1k views

Is break a code smell?

I'm asking in terms of a loop, obviously break is important in switch statements. Whether or not switch statements themselves are code smells is a separate issue. So consider the following use cases ...
1
vote
2answers
114 views

Does an interface including several methods that return instances of Object make sense?

I am in the process of writing my first true API. In the process, I am defining an interface for mapping complex data structures onto other complex data structures. At the moment, the interface ...
1
vote
1answer
774 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 ( ...
28
votes
8answers
6k views

Is it acceptable to copy and paste long but straightforward code instead of wrapping them into a class or function?

Suppose I have a segment of code to connect to internet and show connection results like it: HttpRequest* httpRequest=new HttpRequest(); httpRequest->setUrl("(some domain .com)"); httpRequest->...
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 and I am creating a installer for the application, there are Three main parts. PostgreSQL installation/uninstallation myapplication ( setup of myapplication is ...