Coding standards, or coding conventions, are sets of rules or guidelines designed to govern the process of code production in a software project. They're usually based on industry best practices or generally accepted conventions. They include naming conventions, style, prohibited features, and more.
1
vote
1answer
56 views
How bad is it that my index.php in a Zend Framework MVC application mixes definitions and side effects?
I'm introducing some more coding quality standards and checks via a new project - in particular, the PHP-FIG recommendations.
This project using Zend Framework 2, and I have a fairly simple entry ...
0
votes
3answers
63 views
Handling source code table alignment
Sometimes there is need to have tables (big or small) in source code.
ItemType const SomeTable[] = {
// id name min max
ITEM( 3, "Foo", 70, 180),
ITEM(13, "Bar", 30, 50),
...
0
votes
1answer
71 views
Objective-c anonymous property coding style
If I have an interface defined like
@interface MyClass
@property (nonatomic, copy, readonly) NSString *myString;
@end
so that myString is externally visible but can't be written, what would be ...
3
votes
3answers
345 views
No exceptions C++ and partially constructed objects
Looking over Joint Strike Fighter Air Vehicle C++ Coding Standard, rule AV 73 states something on the lines: Default c++ constructors should be avoided if that means leaving object in a partially ...
0
votes
2answers
35 views
SQL - for some attributes specific to different clients' users, how to handle schema?
I have clients, each of whom have an app with a bunch of users.
Their user data could be pretty different, but there is also a lot of overlap. Ex: all their users have "gender" and "age" and plenty ...
1
vote
3answers
148 views
Are project naming conventions more important than language naming conventions? [closed]
I'm working on a project with a senior developer and he doesn't really abide by the naming conventions of the language that we're using. The project is in Go and he uses underscores for everything. ...
0
votes
7answers
205 views
In ifs inside for loops, prefer checking for true, or for false and continue?
I'm discussing this with a work colleague.
Say we want to sum the numbers from 0 to 9 skipping 5.
He prefers this:
int sum = 0;
for(int i = 0; i < 10; ++i)
{
if(i == 5)
{
continue;
...
2
votes
1answer
211 views
Reducing the complexity of over-designed code
I have just started working at a company where I have inherited a C# codebase from a previous developer. I know programming well, have an engineering degree + an (unfinished, several year long) PhD ...
0
votes
0answers
71 views
Is there any necessity to pass a variable parameter to a method while the variable declared global? [duplicate]
I am writing a class in java of Monte-Carlo algorithm. Here is the written code -
public class MonteCarlo {
int[][] matrix;
public void monteCarlo(List<Node> nodeList) {
matrix ...
2
votes
2answers
101 views
Typedefs to convey relations between classes
I'm wondering if the following use of typedefs is any good practice, or if there are any downsides to it.
Basically I have alot of "data"-structs, which are intended to be used in (globally unique) ...
0
votes
2answers
71 views
Why should a HashMap be used(in functions) to determine which value to return(for a key) when an if else construct can do the job in better time?
While I was recently working at a big company, I noticed that the programmers there followed this coding style:
Suppose I have a function that returns 12 if the input is A, 21 if the input is B, and ...
1
vote
2answers
298 views
How should I compare two database tables - with SQL or using Java? [closed]
I have two tables with different structure. I should compare ID from 1st table with ID of the intermediate table and then comapre TXT field of the intermediate table with TXT field of the 2nd table.
...
1
vote
6answers
217 views
What to use instead of IDs in selectors in CSS
I recently installed a csslint package for my Atom text editor. I keep getting warnings saying "Don't use IDs in selectors." I found this weird since I've always been using IDs in selectors in CSS, ...
1
vote
2answers
84 views
Helping to avoid first time implementation mistakes [closed]
I am getting close to "finishing" my first major, non-trivial PHP/MySQL website project, and while the code is generally fine and works properly, there are many problems with it considering the fact I ...
0
votes
1answer
98 views
Where does the Liskov Substitution Principle generally lie in different constructor parameter lists?
There are two other questions I've posted that dealt with specific cases of this:
Where does the Liskov Substitution Principle lie in a subclass passing extra arguments to similar, tightly-related ...
3
votes
4answers
442 views
Are `switch` statements generally used wrong? [closed]
I see most developers using switch statements with breaks in each and every case. Is this usage of switch statements inappropriate since a simple set of if-else statements would suffice?
Is it OK for ...
0
votes
2answers
48 views
Capitalizing custom methods in a SDK based project [closed]
In projects which need heavy SDK usage, like Android and iOS development, I want the methods/functions I write to be obvious and since the whole framework is written with lower case method names I ...
2
votes
2answers
330 views
Should we refactor our existing codebase to use functional programming, especially streams? [closed]
We have a large project written in PHP. It almost exclusively uses imperative operations, as in example 1. Should we refactor our existing code to use functional operations? Do you think that the code ...
2
votes
2answers
131 views
Is embedding data in a executable considered a good practice?
Embedding data (such as images) in a executable seems to have a few advantages, like easier distribution of the executable and easier compatibility with different OSes.
But, is it a good practice? ...
3
votes
3answers
195 views
Easy way to make old javascript files conform to new quoting standard?
We've just started putting linting in place at my workplace, and a lot of the devs didn't realize our standards called for double-quotes everywhere. About 50% of the codebase uses single-quotes, so ...
0
votes
1answer
150 views
What do you call classes that do arbitrary work in your project? [closed]
I work on a lot of projects with different teams. Every project has its own conventions, including what to call arbitrary classes that don't lend themselves to obvious names.
As a counter-example, ...
0
votes
1answer
127 views
What are the key areas to evaluate software (codebase) on? [closed]
I have been asked to do a code review of about 50 applications over a period of 6 weeks. (Management has changed and the new CTO asked for an full internal software audit)
I am wondering, what are ...
3
votes
2answers
161 views
Are there any widely accepted sets of standards/practices for secure coding? [closed]
The title should be fairly self-explanatory.
We need to update our coding standards, and as part of this process we've been asked to try and follow an industry standard from a ...
5
votes
1answer
220 views
Why is the use of JavaScript in HREF attributes discouraged?
Disclaimer: I came to Programmers.SE to ask this question because I understand this is the place to ask this type of question, and not necessarily stackoverflow. If I am wrong, please close the ...
2
votes
3answers
425 views
Should one value simpler code over performance when returning multiple values?
I'm too often facing situations where I need to get several types of information from a method. I usually think long and hard to circumvent these situations but I'm thinking it's pointless work that ...
0
votes
1answer
940 views
Project directory structure
Actually i'm using this project directory structure http://framework.zend.com/manual/1.12/en/project-structure.project.html
But recently i started using namespaces in all my php-classes like:
...
0
votes
2answers
222 views
C Linked List Implementation Pointer vs. Pointer-to-Pointer Consistency
To get some practice in C, I'm writing some basic functions for operating on a linked list of ints. I started out with functions that accepted as a "list" a pointer to the head node. Now, I find ...
0
votes
1answer
125 views
Method Parameters Ordering [closed]
I was recently changing a method to add in an additional parameter, and I couldn't help but wonder if there were "best practices" or "generally accepted rules" in deciding what order parameters of a ...
0
votes
1answer
134 views
Is there a particular coding standard with comments between function name and body?
I'm integrating with a shipping API built in php.
They have a strange coding standard where the comments are between the function name and the first curly bracket.. which - subjectively - makes the ...
0
votes
1answer
59 views
How to format Android view IDs
I struggle with this every time I work on a project. I am not entirely sure what the standard conventions are for creating view ids. I usually use something like
view_more_button
but then if we ...
16
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.. ...
0
votes
2answers
135 views
At what point should you start putting functions in a new file? [closed]
I'm currently writing a python script. It's currently about 400 lines long, and it seems like it's getting a bit long, as when I'm trying to scroll through it with eclipse it takes a bit to get from ...
0
votes
1answer
166 views
Should I continue stressing development standards? [closed]
I've been with my software team for about three years now, and just recently I brought up the concept of variable naming conventions (across all languages, but C#/VB.Net specifically).
We really ...
16
votes
5answers
2k views
What does it mean when some technology is a “standard”?
I started learning Java EE 7 and I am frequently coming across this term "standard", and I don't understand what it means.
So, for example, here is a quotation from this book:
Contrary to SOAP ...
2
votes
2answers
98 views
Generic Repositories with DI & Data Intensive Controllers
Usually, I consider a large number of parameters as an alarm bell that there may be a design problem somewhere. I am using a Generic Repository for an ASP.NET application and have a Controller with a ...
0
votes
2answers
105 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 ...
1
vote
2answers
225 views
Is a try-catch-finally clause appropriate for production code?
While browsing around on SO, I came across an answer that suggested using a try-catch-finally clause to fix the problem he was having. (A rare bug that sometimes happened to his users). Someone ...
2
votes
1answer
346 views
Things developers do before the coding phase [closed]
I'm a new software developer, and in my internship my boss asked me to develop an application that allows him to manage his inventory. Something small but, for me, very enriching.
The application is ...
15
votes
12answers
3k views
Why use getters only as opposed to marking things final? [duplicate]
I'm working in a java role after working a couple years in functional programming. Our company was bought by google and I took a java role after the acquisition.
Coming back to java as a polyglot ...
3
votes
3answers
483 views
Refactoring previous intern's noodle code with future interns in mind [duplicate]
Background
I've run across this problem as I am currently an intern at a large company's local software division. I have been given the task of extending a project that several previous interns have ...
16
votes
14answers
4k 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
3answers
105 views
Is it bad to use the same class or idiom names as in a third-party API that you're using?
FlashPunk is a third-party graphics API for simple game development in AS3, and they take what are effectively sprites or display objects of some sort and refer to them as "Entities". Entity is the ...
2
votes
3answers
631 views
invoking methods within a conditional expression
In an oft-cited (if dated) reference for C# coding standards (pdf; from Lance Hunt), the statement is made,
33. Avoid invoking methods within a conditional expression.
I've not seen this ...
0
votes
1answer
72 views
Matching the superclass's constructor's parameter list, is treating a null default value as a non-null value within a constructor a violation of LSP? [duplicate]
I kind of ran into this when messing around with FlashPunk, and I'm going to use it as an example.
Essentially the main sprite class is pretty much class Entity. Entity's constructor has four ...
0
votes
1answer
280 views
What is the proper way to extract and pass parameters to call javascript functionality from my PHP page?
This is my situation: I have a search results page in PHP where most of the logic resides in a javascript file in order to avoid refreshing the page every time an action is performed. The first thing ...
1
vote
1answer
149 views
How much functionality needed to create a new class?
Right now I am working on my own small project of a WPF file back up application. I have come to a point where I want to create a method that will copy files recursively from one place to another.
...
74
votes
8answers
8k views
Is it okay to not completely understand code functionality? [duplicate]
As I am currently struggling with learning WCF for a project at work, for the past several days I have been looking at online tutorials and examples on the best way to make a WCF client; and today, ...
29
votes
1answer
1k views
How to deal with a misnamed function in production code?
I've recently come across a Python library on GitHub. The library is great, but contains one glaring typo in a function name. Let's call it dummy_fuction() while it should be dummy_function(). This ...
2
votes
2answers
143 views
Enforcing coding standards: What are the trade-offs of different methods?
Our team has recently agreed on some very light coding standards, and that we need a means of enforcing them. We already have a mature Continuous Integration practice including frequent, small ...
3
votes
2answers
189 views
Which do you code first, MVC? [closed]
I have been coding for a good bit, and I found a project I want to work on -- a python web app using django + mongodb.
I know what I want my web app to do. When you are in this circumstance (just ...