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

learn more… | top users | synonyms (1)

1
vote
2answers
146 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
32 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
310 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
65 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
100 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
209 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
150 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
349 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
121 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
178 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
225 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
89 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
99 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
129 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
294 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
119 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
280 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
425 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
7answers
2k 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
187 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
232 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
524 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
287 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
101 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
95 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
274 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
597 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
113 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
137 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
209 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
467 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 ...
2
votes
2answers
837 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 ...
6
votes
6answers
619 views

Should my team use some common well-regarded coding standard as a basis for own 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
1answer
245 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
171 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 ...
5
votes
3answers
463 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
66 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
116 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 ...
0
votes
1answer
202 views

How to justify efforts to make capitalization of class and property names uniform? [closed]

In this thread, an Oracle Product Manager (username "Alex Keh") refused to make Oracle's EF provider to conform with .NET's PascalCase coding standard for class names and property names, saying that ...
1
vote
1answer
83 views

Is there any reason not to include issue numbers in debug logs?

I was going through the answers to this question: What information must never appear in logs? And noticed that nobody mentioned this particular attribute. It's something I find useful- whenever any ...
0
votes
2answers
260 views

Is PHP “list()” language construct a bad convention?

PHP supports the list() language construct which, in short, allows you to return multiple values from a function and then attach them to different variable, eg: function myBigReturn(){ return ...
2
votes
2answers
727 views

Why do we not prefix Enums, Abstract classes and Structs?

The C# community has so ubiquitously used the "I" prefix to denote an interface that even the most inexperienced programmers know to use it. Why is it then that we do not prefix enums, abstract ...
0
votes
2answers
199 views

What's a good way to manage long piece of code in files? [duplicate]

I am a web developer and at the moment am finding it hard to cope with long un-documented code written by previous developers in an organisation I work for. With the deadline gun always pointed at my ...
4
votes
2answers
657 views

Java naming conventions vs. C++/C naming conventions

I am a Java developer who is starting to pick up more and more C++/C (yes I know they're different, bear with me). One thing that struck me as odd was the different naming conventions used by these ...
3
votes
5answers
2k views

What's meant by, “TODO Auto-generated method stub”? [closed]

I am using eclipse for android programming, and every here and there i see the statement, "TODO Auto-generated method stub." I understand that these methods were generated automatically by eclipse ...
6
votes
4answers
454 views

How do I introduce clean code? [duplicate]

My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code. ...
0
votes
4answers
218 views

Coding convention regarding the usage of underscores [closed]

There seems to be divided opinion on this subject, and I wanted to get people's insights on whether they've found using underscore prefixes and suffixes to be helpful with coding or not. You know, ...
-2
votes
1answer
253 views

Coding standards in programming? [closed]

I am an WordPress Plugin Developer. I am not sure how to follow the coding standard while creating a plugin of wordpress. I check with some of the plugins like woocommerce and All in one SEO Plugin in ...