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

learn more… | top users | synonyms (1)

0
votes
1answer
278 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 ...
3
votes
2answers
1k 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
201 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
708 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 ...
4
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
469 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
304 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
259 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 ...
1
vote
2answers
130 views

What values in an application should be configurable?

What values in an application should be configurable, or otherwise not hard coded? Does this differ based on application type (batch vs UI) and are there any published standards or guidance on this ...
2
votes
6answers
349 views

Should all classes have a default constructor as part of good coding convention

From the texts I have read so far, the conventions talk about organizing constructors, starting with the default, if any. I am wondering, should all classes have a default constructor anyway. This ...
3
votes
3answers
1k views

articles in variable names and hard-coding strings

re-edited by author: no this is not 2 questions. This is one question about code review questions containing two separate points. Please do not edit my question. For naming variables, the two sides ...
0
votes
1answer
80 views

Writing contextually related control statements next to each other [duplicate]

Recently I've been messing around with this. Note that I'm not using LINQ because while this could be easily be done that way, I could do this in any language. Allow me to exemplify: foreach ( var i ...
6
votes
7answers
1k views

Making Simple IF Statements Shorter

If we assume we have this little snippet of code: string str = "checked"; bool test1; if (str == "checked") { test1 = true; } else { test1 = false; } Is it bad practice to change a simple ...
3
votes
1answer
118 views

Verification for value of test standards

We are currently developing a concept for our tests standards. Up until now, we don't have standards. All we do is to tell the developer to write tests. Now we have the following basic idea: We will ...
4
votes
1answer
105 views

When to build(code) vs buy(download plugin)

Recently I have been working with a large set of talented programmers that lead to a discussion on when should we start building our own components (web js/css) vs downloading and modifying existing ...
1
vote
1answer
334 views

Checklist for coding MVVM web application [duplicate]

We are a small team working on a web application using MVVM design pattern using technologies like .NET, Knockout and HTML. I am trying to come up with a code review checklist for this, so that my ...
0
votes
0answers
43 views

BASE_DIR/URL with or without trailing slash? [duplicate]

When you have basedir/url constants or variables, do you put a trailing slash? In theory I think ultimately one should, since /path/to/dir/ is a dir while with /path/to/dir if I'm not mistaken the ...
3
votes
2answers
601 views

Are there any industry standards that define code quality?

Our specific situation is that we are creating an agreement between ourselves and another team for shared control or use of a PHP based web application that we have been building. We have a set of ...
1
vote
3answers
359 views

Code Base with awful code conventions, follow them?

With no time to refactor, when you are working on legacy code, with the most awful conventions, what is the best practice? Will trying to follow better coding style would improve readability or ...
3
votes
3answers
903 views

When are chained assignments (i.e. a=b=c) bad form?

I'm working on a VB.Net WinForms project and found myself writing code like this: this.Fizz.Enabled = this.Buzz.Enabled = someCondition; I couldn't decide whether that was bad code or not. Are ...
2
votes
5answers
243 views

Best practice to sort then reverse, or write “backwards” comparator?

I wrote a comparator for a custom class of mine and when I ran my code I realised the output of my list of these objects was in the reverse order as to what I wanted. It was "ascending" as opposed to ...
2
votes
4answers
3k views

Creating a coding standards document

I work in a control systems company, where the primary work is SCADA and PLC, along with other control systems stuff. Softwre development is not really something the company does, apart from little ...
1
vote
1answer
143 views

Should I not try to emulate private class data in javascript?

So I have been building this ORM style library for AngularJS (JavaScript) and since I come from a C++/PHP/C# background, I always try to make sure that private things stay private. While this can be ...
6
votes
3answers
299 views

Dynamic typing function arguments - how to keep readability high?

Dynamic typing newbie here, hoping for some wizened words of wisdom. I'm curious if there is a set of best practices out there for dealing with function arguments (and let's be honest, variables in ...
7
votes
1answer
260 views

Naming of related classes and interfaces

I have created an ObjectParser class which parses data into strongly typed objects using an IObjectParserDataSource as the data source (the data could be an Excel file, text file, array, query string, ...
3
votes
4answers
3k views

Is using “out” or “ref” parameters in Java methods to return extra values bad?

I happened to create a mutable class like this: class Mutable<T> { private T value; public Mutable() { this.value = null; } public Mutable(T value) { this.value = value; } T ...
2
votes
3answers
259 views

Implementing a new coding standard to an existing application

Recently we have had some turnaround in the shop I work in, because of this comments in our source code were made hastily and explained very little. We have started working on the departments first ...
11
votes
3answers
892 views

The problems with Avoiding Smurf Naming classes with namespaces

I pulled the term smurf naming from here (number 21). To save anyone not familiar the trouble, Smurf naming is the act of prefixing a bunch of related classes, variables, etc with a common prefix so ...
3
votes
2answers
300 views

Are there standard style guides for PHP?

I've been working in a very small team for PHP development and we've been using an ad-hoc, "Invented Here" style guide. Now that our team and codebase is growing, we would like to use a more ...
2
votes
4answers
2k views

Microsoft's coding standards for ASP.NET controls

I cannot find any naming standards/conventions in MSDN for naming ASP.NET controls. One of the following standards tends to be used by programmers: lblAddress AddressLabel Address According to ...
1
vote
4answers
2k views

Is using `continue`, `break` in non-`switch` loops and `?:` bad practice? [duplicate]

Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only ...
5
votes
8answers
758 views

Why is (position < size) such a prevalent pattern in conditionals?

In a condition statement (IF) everyone use (position < size), but why? Only convention or there is a good reason for that? Example: if (pos < array.lengh) { // do some with array[pos]; } ...
7
votes
7answers
1k views

Prevent developers from using constants

I have one one software system which allows developers to specify an ID or name to create NodeReferences. Both work fine, but ID's are not guaranteed to be the same across different environments. I've ...
-1
votes
1answer
500 views

What is the C++ convention, if any, for naming to differentiate between structure types and other types? [closed]

In general, should I use some sort of convention for structure names which is distinct from other type name? I was thinking about this when my professor started talking about structures. I had the ...
2
votes
2answers
499 views

coding style for If condition [duplicate]

I came across below style of writing if statements in C#, on msdn code examples. Usually when I write if statements, the conditions I would write `(Customer != null) I want to know if there is any ...
2
votes
6answers
1k views

Validation of the input parameter in caller: code duplication?

Where is the best place to validate input parameters of function: in caller or in function itself? As I would like to improve my coding style, I try to find the best practices or some rules for this ...
11
votes
4answers
473 views

Always pull out common cases and branch separately? [duplicate]

We had a disagreement in a code review. What I had written: if(unimportantThing().isGood && previouslyCalculatedIndex != -1) { //Stuff } if(otherThing().isBad && ...
14
votes
1answer
2k views

Why Bootstrap 3 changes camelCase to dashes - is it more readable?

I'm wondering what's the reasoning behind Bootstrap's decision to change all camel case names into hyphenated names in v3.0. I searched on Google, and looked in a few books, but I can only find ...
3
votes
6answers
672 views

Criticizing your former employer in an interview [closed]

I'm a very junior developer fresh out of college, and in my first programming job. I'm pretty unhappy with my current company-the software engineering standards here are pretty shoddy-the code base is ...
-2
votes
1answer
234 views

Mobile Javascript Coding Standards Cueme browser

Is there a more generic Javascript Standard of Mobile Handheld devices. I could refer to the following links for generic standards. http://javascript.crockford.com/code.html or ...
2
votes
4answers
503 views

Naming convention for a method that both sets and gets

Let's say we have a method setFoo that sets a flag in a Bar object e.g. class Baz { public void setFoo(String foo)( ... } } inside setFoo, the method is doing some expensive load of ...
65
votes
19answers
12k views

How important is it to reduce the number of lines in code?

I am a Software developer who works on J2SE (core java). Often during our code reviews we are asked to reduce the number of lines in our code. It's not about removing redundant code, it's about ...
0
votes
2answers
114 views

addIfNotExist alternative

Is there are any standards or conventions on naming methods which add something if it not exist into another something. For example: Store.instance().addItemIfNotExist(item) IfNotExist is really ...
18
votes
15answers
2k views

I hate one of our coding standards and it drives me insane, how to process it? [closed]

Disclaimer: Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about that ...
0
votes
1answer
666 views

Preventing override of methods in Objective-C [closed]

Objective-C lacks private methods or java-esque final methods. This means that it is possible for a subclass to (accidentally) override some of the internals of a superclass. How does one prevent ...
4
votes
5answers
509 views

How can I avoid mistakes using the same variable name again?

This isn't a rare case and occurs with me often and I spent countless time trying to debug the code. Latest example, this PHP code where I used $email for the parameter and for object as well. ...
30
votes
8answers
8k views

Is it necessary to add the default case while using switch cases?

During a recent code review I was asked to put default cases in all the files wherever switch block is used, even if there is nothing to do in default. That means I have to put the default case and ...
6
votes
3answers
316 views

Why does Zend discourage “floating functions”?

Zend's Coding Standard Naming Convention says Functions in the global scope (a.k.a "floating functions") are permitted but discouraged in most cases. Consider wrapping these functions in a static ...
2
votes
8answers
762 views

tips, guidelines, points to remember for rendering professional code? [closed]

I'm talking about giving clients professional looking code. The whole nine yards, everything you hardcore professional highly experienced programmers here probably do when coding freelance or for the ...
6
votes
3answers
211 views

“static” as a semantic clue about statelessness?

this might be a little philosophical but I hope someone can help me find a good way to think about this. I've recently undertaken a refactoring of a medium sized project in Java to go back and add ...