Questions for best practices for writing high quality code.

learn more… | top users | synonyms

2
votes
1answer
189 views

The most effective arguments in favor of improving code quality, for a manager [closed]

My employer's legacy system started off (in 1997) as very structured procedural code (with a smidgeon of OO), and it was luckily one of the 10% of software projects that was successful. It may look a ...
-3
votes
0answers
29 views

How do you tidy up and maintain your code in JavaScript (jQuery)? [duplicate]

How do you tidy up and maintain your code in JavaScript (jQuery) while keeping it simple? I've been wanting to ask this for a while now but I never get around to it so I usually use websites like ...
3
votes
6answers
232 views

Explicitly define enum values, even if the default value is the same?

There are times when an enum's values are important: it is not necessary for them to be unique, they also need to have specific values. In such cases, should the values be explicitly defined, even if ...
0
votes
0answers
13 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 ( ...
0
votes
1answer
53 views

How to keep class parameters visible while using generic argument passing

After writing some classes where class initialization requires multiple options, instead of writing several parameters into constructors or setters, I started passing an associative array of ...
0
votes
2answers
78 views

What is the normative (best) use of Javascript arguments object [closed]

JS offers the 'arguments' object inside of functions to represent all passed arguments. Is there any broadly accepted concept for when/where this should be used? I've seen items like this in the ...
1
vote
1answer
257 views

Complexity vs simplicity? [closed]

Been a developer for over 7 years already. Not sure if I might be called a senior, but know one or two things. Last night was trying to solve some issues with Mockito and InjectMocks, and dig into ...
1
vote
4answers
89 views

How to measure (and improve) quality of bug-fixes? [closed]

I have the suspicion that many bug-fixes carried out by our developers sooner or later cause another bug, simply because the product is too complex. I'd like to improve the quality of bug-fixes, ...
19
votes
6answers
1k views

The importance of duplicate code removal [duplicate]

I tried to explain to a coworker the gravity of having duplicate code in a project, on this piece of code: + (void)createIapInParse:(SKPaymentTransaction *)transaction { Reachability *reach = ...
2
votes
1answer
115 views

How do I avoid duplicating utility functions across modules?

I've seen this question but it doesn't help me because I'm writing functional code (Standard ML) and the answers there are heavily focused towards OOP (the OP is advised to use the Facade pattern, to ...
2
votes
4answers
165 views

What can be done when you are the only person to care about consistency? [closed]

After reading this question I may have a partial answer to the issue at hand, but I'd like to explore the issue further. I seem to be the only person on my team (a team of 6 people working on an ...
3
votes
4answers
195 views

Wrap all external calls with flag to fight against recursion and double-entry?

Producing predictable output for each possible input is the responsibility of each module. For example (in C#): class Logger { public ITextWriter Writer { get; set; } private uint counter; ...
15
votes
16answers
1k 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.. ...
1
vote
2answers
181 views

How to know whether to create a general system or to hack a solution

I'm new to coding , learning it since last year actually. One of my worst habits is the following: Often I'm trying to create a solution that is too big , too complex and doesn't achieve what needs ...
1
vote
3answers
612 views

Should we enforce code style in our large codebase? [duplicate]

By "code style" I mean 2 things: Style, eg. // bad if(foo){ ... } // good if (foo) { ... } Conventions and idiomaticity, where two ways of writing the same thing are functionally equivalent, but ...
0
votes
2answers
70 views

Erlang return value conventions

Should functions that return tuples, always return tuples? For example, I have a function is_user_name_allowed that returns a tuple in this he form if the username is not allowed: {false, ["Reason ...
2
votes
1answer
67 views

Erlang function naming conventions

I understand the general Erlang conventions for functions are using snake case or camel case, but what about exported functions? For example, say I have a gen_server module that defines a check to ...
1
vote
1answer
188 views

Equal or less than 15 lines per method(function) principle? [duplicate]

Some books or master told us this principle: Equal or less than 15 lines per method(function), and the perfect is under(or equal) 8 lines. Does the principle make sense for most conditions? There ...
5
votes
4answers
2k views

Should you ever use private on fields and methods in C#?

I am somewhat new to C# and just found out that: in C# all of the fields and methods in a class are default private. Meaning that this: class MyClass { string myString } is the same as: class ...
4
votes
8answers
837 views

Customer is “deeply disappointed” in software because of one bug. How to reply? [duplicate]

We have been building custom software for one of our customer for a few years now. Everything is going well so far. However the customer always has an attitude that when they find a bug in the ...
1
vote
2answers
375 views

Best practices / reasons for String constants in JavaScript [closed]

In static languages like Java/C#, I commonly make use of constants for strings or numbers, rather than insert them into the code alone. However, I tend to avoid this practice in JavaScript. More ...
0
votes
2answers
273 views

Preventing ip resolvers in a skype-like program

I'm currently in the process of creating a Skype-like program, that uses a hybrid peer to peer system to communicate between users (i.e. server contains all users IPs, a client that wants to connect ...
0
votes
1answer
123 views

What design pattern should I use for import, update, export

I need to create a simple payments validator. On the following class diagram, I tried to present the model of payments. As you can see, each payment type inherits from Payments class. Now I want ...
3
votes
2answers
206 views

Minimizability or readability?

I am authoring a lot of plugins for the content management system that I am writing. I believe it to be of utmost importance that script files (especially if they're plugins) should load quickly, ...
2
votes
1answer
163 views

Will this “wireless” syntax for my framework make for good code structure / design?

I'm at the point where I'm getting into the freelance development of some complex web apps, and I would like to develop a light weight framework for my personal use, but I'd like to get some advice ...
1
vote
1answer
123 views

OpenSSL Client model for half duplex communication over socket

I have read in this SO question that OpenSSL socket communication can be only half duplex in a single thread. Assuming what I have read is true, I am wondering if I can apply philosopher's dining ...
16
votes
14answers
3k views

How many mistakes does a good software developer make? [closed]

I am currently in a situation where a lot of people criticized me for making bugs (on my first local try - the first time I run the code for the first locally done test - , not on a committed repo ...
3
votes
2answers
191 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 ...
0
votes
4answers
393 views

File exists vs. File does not exist. Is there a difference in performance?

Let's say I am checking a directory for the existence of a file, and then depending on whether or not the file exists, I act accordingly. For example, see the two Python snippets below. if ...
4
votes
1answer
520 views

In Java, why use bit hacks when non-bitwise technique it is more readable?

Is there any legitimate use for bit manipulation hacks in higher-level languages such as Java? I can see them being useful in speed-sensitive low-level and computation-intensive programs, e.g. ...
0
votes
2answers
201 views

Working with Javascript classes the right way

Comparable questions have surely been asked before but I'd like to hear some words about my specific way of implementing Javascript classes. Let me first start with a Javascript example taken from a ...
1
vote
2answers
109 views

Apply filter only if not null

My function takes an optional parameter, type, which is used to filter through a collection. However, the filter should only apply if the parameter is passed in (in other words, non-null). If the ...
1
vote
0answers
115 views

Diagram to show code responsibility

Does anyone know how to visually diagram the ways in which the flow of control in code passes between code produced by different groups and how that affects the amount of code that needs to be ...
1
vote
3answers
239 views

Software architecture for two similar classes which require different input parameters for the same method

I am writing Java code to simulate a supply chain. The supply chain can be simulated in either an intermediate stocking or a cross-docking configuration. So, I wrote two simulator objects ...
1
vote
1answer
143 views

Is it good practice to analyse who introduced each bug? [duplicate]

I used to analyse performance of programmers in my team by looking at the issues they have closed. Many of the issues are of course bugs. And here another important performance aspect comes - who ...
1
vote
3answers
78 views

Modelling highly specific business requirements

How can one go about modelling highly specific business requirements, which have no precedent in the system? Take for example the following requirement: When a purchase order contains N lines, is ...
2
votes
4answers
250 views

Is it normal needing time to understand code I wrote recently [closed]

By recently I mean some weeks ago. I am trying to continue a project I left 2 weeks ago and I need time to understand some functions I wrote (not copied from somewhere) and it takes me time. Normally ...
2
votes
2answers
137 views

Checking program robustness using static code analysis

(Building on this question) If you have a static code analyser such as Checkstyle, is it possible to to relate any of the stuff that it checks for to actual robustness? Some of the things that ...
38
votes
12answers
5k 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 ...
-1
votes
1answer
159 views

How to code efficiently? [duplicate]

I often compare my code to others and I find their solution more efficient and shorter than mine. Although both solutions work, I can't help it but wonder if mine is not adequate enough. As a result, ...
7
votes
4answers
473 views

Does “write quality code” advice apply to companies of any scale? [duplicate]

I carefully followed the "always write quality code, unless you're writing a prototype" advice during my career as freelancer and software developer. I was convinced pretty early that avoiding to do ...
27
votes
10answers
4k views

Getting coders to do code review [duplicate]

I am running a project where I pay developers to contribute to my semi open source project. My problem is that it is easy to hire developers, but it is very difficult to get anyone to do code ...
0
votes
1answer
148 views

Is it a good practice to decouple the membership system?

Currently I'm developing a project that basically is built with ASP.NET Web API. The membership system I'm using is ASP.NET Identity. The only problem I'm seeing with this is that the membership ...
0
votes
0answers
80 views

Creating New Wrapper Objects and Extension Classes and Keeping it Organized

Here's my situation: I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different ...
4
votes
1answer
271 views

If TDD is design, how do you know your TDD is well designed? [duplicate]

Given a large group (50+) of programmers: All given the same problem, All using Test-Driven Development (TDD), All pair programming, All doing group-based code review, I have personally seen the ...
1
vote
1answer
162 views

Java code quality in methods calling methods

I am currently working with an "interesting" code-base and see the following type of thing alot in the code. public Object doSomething() { Object obj = new Object(); // Do some stuff to the ...
0
votes
0answers
49 views

Algorithm to Select Sequential Subarrays from an Array

I solved my problem by using simple nested loops and comparisons but I'm wondering if there is a well known Selection Algorithm to solve my problem. Let's say I have an array such as [1, 10, 250, 9, ...
3
votes
2answers
146 views

Reflecting on finished project with no other technical criticisms?

I'm a coop (in college but I work 3 months, then do classes for 3 months, work again for 3 months, etc until I graduate) at a company in their IT department. My job usually has to do with writing ...
0
votes
1answer
138 views

What should be the minimal quantity of code production per week? [duplicate]

I'll try to further explain what I mean. Imagine you are the boss of a company. You have to deal with the tradeoff between the quality of the code and the speed of producing it. Let's assume to ...
2
votes
3answers
154 views

When to use python function nesting?

I am writing a program that creates backup of directories. Which of the following approach is better for code organization? Create separate class for Backup and Zip logic - class BackupUtil: ...