Coding standards a set of conventions and practices used in software, such as naming classes, variables, and files.

learn more… | top users | synonyms (1)

15
votes
12answers
2k 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 ...
5
votes
3answers
361 views

Refactoring previous intern's noodle code with future interns in mind

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
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
3answers
85 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 ...
0
votes
1answer
56 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
121 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
135 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. ...
73
votes
8answers
7k 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, ...
28
votes
1answer
956 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
110 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
176 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 ...
0
votes
1answer
41 views

How using tab affects commands like diff

In the page at http://pear.php.net/manual/en/standards.indenting.php, it is advised to use space instead of tab as it causes issue with diff, patches. Here is the excerpt from the page. Use an ...
3
votes
3answers
405 views

Is it common to use code you don't understand? [closed]

I have been working on a project recently that uses a pretty comprehensive framework built by someone else. The framework is free to use commercially and privately as anybody sees fit, so there are no ...
1
vote
1answer
87 views

Are there any standards for separating different kinds of comments (explanatory, debug, to-do, etc.)?

For a while now I've been in the habit of differentiating different kinds of comments in my code. //this is an explanatory comment //!this line was commented out for debug purposes, DO NOT SHIP WITH ...
0
votes
3answers
103 views

Long vs short scripts? Big vs small scripts? [closed]

As a programmer, I have always wondered whether it is preferable to write (a) short modular functions that are each stored in their own script (i.e., file) or (b) long comprehensive scripts that ...
1
vote
1answer
252 views

HTML DOM in .NET: following specification vs. following language standards [closed]

Let's say we're implementing HTML DOM in C#. Naming conventions are different: HTMLCollection interface/class vs. IHtmlCollection/HtmlCollection, body attribute vs. Body property etc. Behavior is ...
0
votes
4answers
165 views

What is the industry norm for naming standard for gui object event handlers in C# [closed]

Lets say you have a button objects on a form with a click event (c#/.Net). How is the event handler normally named throughout the industry? fooButton_Click fooButtonClick (or if you like ...
2
votes
3answers
377 views

Coding standards for c# [duplicate]

I wanted to know if there are some default standards for writing c# code. By default I mean may be something officially from Microsoft, or any other organization. I am looking for something where I ...
0
votes
0answers
179 views

Commenting MVC applications [duplicate]

I've recently realised that my workplace doesn't comment their ASP.NET MVC applications. By 'doesn't document', I mean there is probably 1 line of comment per model/view/controller. No file purpose, ...
-1
votes
5answers
189 views

Is there a history behind the placement of code block markers? [closed]

When I started learning programming, I noticed that everybody (lecturers, authors, brainwashed fellow students, et cetera) placed code block markers in the following way: if(userIsBest==true){ ...
5
votes
2answers
230 views

Is Convention Over Configuration “Knowledge in the World” or “Knowledge In Your Head”?

In Don Norman's seminal work "The Design of Everyday Things", the author coined the phrases and explains the difference between "Knowledge in the World" and "Knowledge In Your Head"; an example of ...
0
votes
1answer
118 views

PHP - PSR 0 - Configuration Constants

This question is about PSR-0 autoloaded libraries and the way main configuration constants should be declared and used. From your point of view (lib/framework developer), where/how should be declared ...
1
vote
2answers
120 views

Should I Aggregate Web API Errors?

The Situation We are writing a REST API that performs validation up-front. The code is written such that it tries to find as many errors as possible. However, each error might correspond to a ...
3
votes
2answers
184 views

Unit testing method name standard for overloaded methods

I have read several posts which discuss coding standard for naming the unit test methods for improving readability. I follow this NameOfMethod_ExpectedBehavior_WhenSomeScenario, but now I am confused ...
4
votes
4answers
304 views

Why is the following naming guideline different between OO and non-OO languages?

I am working with a non-OO language and I'm trying to name my routines consistently. I came acrross the following guideline from Steve McConnell's Code Complete: To name a procedure, use a strong ...
0
votes
1answer
189 views

Should the helper function in class be defined before the usage or after

I need to do the code review of fellow members. One of the member always defined the helper functions at the bottom and use them at top e,g class Sample { public function SendFile(){ file = ...
0
votes
4answers
437 views

Usage of magic strings/numbers [closed]

This is somewhat controversial topic, and I guess there is as many opinions as there are programmers. But for the sake of it, I want to know what are the common practices in business (or in your work ...
4
votes
4answers
484 views

Using a function's return value as an if condition, good practice?

Do you think it is a good practice to use function return values as if conditions? I'm coding in PHP atm but it holds for many other languages. if(isTheConditionMet($maybeSomeParams)) { } or $res ...
12
votes
6answers
4k 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 ...
0
votes
1answer
192 views

Where does the tradition of shell prompts in code snippets come from?

Most code samples I see that demonstrate shell code preface each command with $. Having a prefix makes sense, but I'm confused as to why $ is used in particular. Some other symbol, like !, that can be ...
1
vote
3answers
253 views

“state” or “status”? When should a variable name contain the word “state”, and when should a variable name instead contain the word “status”? [closed]

Reading code and discussions pertaining to code, I often see the words "state" and "status" used interchangeably, but the following tendencies seem to exist: When a variable holds a value intended ...
-1
votes
1answer
49 views

Convention for using super class functions and members

Is there a Convention or common way for using super class functions and members? For example the super class has the function protected void Foo() and protected int myInt; In subclass would I want ...
48
votes
12answers
3k views

Is it reasonable to null guard every single dereferenced pointer?

At a new job, I've been getting flagged in code reviews for code like this: PowerManager::PowerManager(IMsgSender* msgSender) : msgSender_(msgSender) { } void PowerManager::SignalShutdown() { ...
13
votes
3answers
532 views

When is it appropriate to use colour in a command-line application?

Currently I have a command-line application in C called btcwatch. It has a -C option that it can receive as an argument that compares the current price of Bitcoin with a price that was stored ...
2
votes
2answers
435 views

Collaborative work (small team) - Best practices [closed]

I'm currently working in a very small team of programmers (2-3) and I'm looking for advices/best practices on how to organise our work. We're all working on the same application using PHP. Today we're ...
2
votes
0answers
104 views

Script language native extensions - avoiding name collisions and cluttering others' namespace

I have developed a small scripting language and I've just started writing the very first native library bindings. This is practically the first time I'm writing a native extension to a script ...
1
vote
2answers
108 views

Coding convention question about AS3 duplicate variable definition

AS3's got some awkward rules about variable scope, due to its use of hoisting. I don't like pointlessly leaving a bunch of compiler warnings lying around, but it's more important to me for my code to ...
4
votes
3answers
288 views

Is it OK to use same variable to store similar stuff sequentially? [duplicate]

Say I have a variable name len in a function and several strings. Can I use this to store length of those strings one after the other or should I create separate variables? Basically this: size_t ...
6
votes
2answers
714 views

Java convention for if/else if order

I have an if/else if structure that on some cases does nothing. From the code I have seen in my career, the "empty" case is normally left out. But when I wrote my code, it just doesn't feel right to ...
3
votes
1answer
121 views

Do you have to ban atomics to get good tool support for race detectors?

It seems that Helgrind treats atomics the same way as normal read/write operations. So, using atomics will result in lots of false positives. I don't know exactly how ThreadSanitizer deals with ...
0
votes
1answer
165 views

Multiple conditions in a function using PSR

I'm trying use the PSR conventions in all my projects, but today I view some code of my co-worker and I disagree. if ($cond == 1 AND $cond == 2) { // to-do } For me, the correct is: if (($cond ...
1
vote
2answers
284 views

Arguments for conforming to PSR-2

I am trying to convince the lead developer of an open-source project I'm contributing to, to conform to the PSR standards (PSR-2 in particular) created by the PHP Framework Interop Group. He is ...
3
votes
3answers
472 views

Which is the better: a <= b or a < b+1 [closed]

For loops are usually inclusice, exclusive, meaning that you start at the bottom, and stops when you reach, but don't to the top. In Python: for i in range(0,a): print(i) would print 0 through ...
3
votes
2answers
1k views

Excessive use “this” keyword in Java [duplicate]

The this keyword is primarily used in three situations. The first and most common is in setter methods to disambiguate variable references. The second is when there is a need to pass the current ...
8
votes
6answers
907 views

Should my team use some common well-regarded coding standard as a basis for its own?

The R&D team I'm in has decided to adopt a coding standard. We have only recently formed, and have too little code and common coding time of our own to base our standards/conventions document on ...
4
votes
2answers
298 views

Is CType() ever the preferred option?

Is there any time CType() is the proper option over other methods? I did plenty of thinking on this myself, but wanted to put the question in hopes there would be answer to my question so I can put ...
0
votes
1answer
196 views

How can I organize my data flow to process a good program solution? [duplicate]

My main problem when trying to form a program is that while I have the tools at my disposal, I am too disorganized to properly use them to solve my problems. Often my process is simply trial and ...
6
votes
3answers
542 views

How to Implement Error Handling [closed]

Even though I've programmed on a professional level for some years I still do not fully understand error handling. Although my applications work fine, the error handling isn't implemented at a ...
-1
votes
1answer
68 views

What are the most crucial categories of content to organize into an internal developer portal in a large company? [closed]

I have been tasked with organizing all of the company's internal content currently spread around sharepoint, a markdown reference manual and confluence into a single cohesive and usable portal in ...
0
votes
2answers
140 views

Should model / table names be as generic as possible?

When naming a model, should the name be as generic as possible-- even if that won't be the name displayed to users? For example let's imagine a Django model for liking another user's posts. Does it ...