Gang Of Coders
Home
About Us
Contact Us
All Coding Style Solutions on Gang of Coders
Total of 261 Coding Style Solutions
Best way to return multiple values from a function?
Python
Coding Style
Return
Return Value
What are the most common Python docstring formats?
Python
Coding Style
Documentation
Docstring
Python `if x is not None` or `if not x is None`?
Python
Coding Style
Nonetype
Boolean Expression
Pep8
Styling multi-line conditions in 'if' statements?
Python
Coding Style
If Statement
Should a function have only one return statement?
Language Agnostic
Coding Style
Order of items in classes: Fields, Properties, Constructors, Methods
C#
.Net
Coding Style
Code Cleanup
Code Structure
Single quotes vs. double quotes in Python
Python
Coding Style
What's the best way to convert a number to a string in JavaScript?
Javascript
String
Performance
Coding Style
Numbers
"std::endl" vs "\n"
C++
Coding Style
Iostream
C++ Faq
What is the purpose of wrapping whole Javascript files in anonymous functions like “(function(){ … })()”?
Javascript
Scope
Coding Style
Iife
Why use def main()?
Python
Coding Style
Are PHP short tags acceptable to use?
Php
Coding Style
Php Shorttags
typeof !== "undefined" vs. != null
Javascript
Coding Style
What is the most effective way to get the index of an iterator of an std::vector?
C++
Iterator
Coding Style
Is there a better way of writing v = (v == 0 ? 1 : 0);
Javascript
Variables
Coding Style
Toggle
Why do most fields (class members) in Android tutorial start with `m`?
Android
Coding Style
#pragma once vs include guards?
C++
Coding Style
Vim 80 column layout concerns
Vim
Coding Style
Declaring multiple variables in JavaScript
Javascript
Variables
Coding Style
Performance
Declaration
Good Haskell source to read and learn from
Haskell
Coding Style
Open Source
What's the purpose of using braces (i.e. {}) for a single-line if or loop?
C++
C
Coding Style
Curly Braces
Defensive Programming
Acronyms in CamelCase
Language Agnostic
Coding Style
Camelcasing
Acronym
Should methods in a Java interface be declared with or without a public access modifier?
Java
Interface
Coding Style
Public Method
Which comment style should I use in batch files?
Windows
Batch File
Coding Style
Comments
Coding Conventions - Naming Enums
Java
Enums
Coding Style
Naming Conventions
Standards
Why is it recommended to have empty line in the end of a source file?
Language Agnostic
Coding Style
Eof
What open source C++ static analysis tools are available?
C++
Coding Style
Static Analysis
80-characters / right margin line in Sublime Text 3
Formatting
Coding Style
Sublimetext3
Sublimetext
Sublimetext4
When is JavaScript's eval() not evil?
Javascript
Coding Style
Eval
Why does PEP-8 specify a maximum line length of 79 characters?
Python
Coding Style
Pep8
Dictionaries and default values
Python
Dictionary
Coding Style
Best way to check for nullable bool in a condition expression (if ...)
C#
Coding Style
Nullable
How can I set multiple CSS styles in JavaScript?
Javascript
Coding Style
Creating an empty list in Python
Python
Performance
List
Coding Style
Timeit
When do you use the "this" keyword?
C#
Coding Style
This
Is it a good practice to place C++ definitions in header files?
C++
Coding Style
Code Separation
Iterate through a C++ Vector using a 'for' loop
C++
Coding Style
For Loop
Iterator
What does 'foo' really mean?
Language Agnostic
Coding Style
Why are dashes preferred for CSS selectors / HTML attributes?
Html
Css
Coding Style
Naming Conventions
Using "super" in C++
C++
Coding Style
What's the correct way to sort Python `import x` and `from x import y` statements?
Python
Coding Style
Python Import
Pep8
Getter and Setter?
Php
Oop
Coding Style
How do you tell someone they're writing bad code?
Coding Style
return statement vs exit() in main()
C++
C
Coding Style
Return
Exit
For a boolean field, what is the naming convention for its getter/setter?
Java
Coding Style
Naming Conventions
Javabeans
.toArray(new MyClass[0]) or .toArray(new MyClass[myList.size()])?
Java
Performance
Coding Style
codestyle; put javadoc before or after annotation?
Java
Coding Style
Annotations
Javadoc
Code Documentation
Why do some scripts omit the closing PHP tag, '?>'?
Php
Coding Style
Should enums in C# have their own file?
C#
Coding Style
Enums
Check if a string contains an element from a list (of strings)
C#
vb.net
List
Coding Style
Performance
Internal typedefs in C++ - good style or bad style?
C++
Coding Style
Typedef
Advantages of std::for_each over for loop
C++
Stl
Foreach
Coding Style
pythonic way to do something N times without an index variable?
Coding Style
For Loop
Python
Checking for NULL pointer in C/C++
C++
C
If Statement
Null
Coding Style
String output: format or concat in C#?
C#
String
Coding Style
string.format
Why is it considered a bad practice to omit curly braces?
Java
C#
C++
C
Coding Style
Relational table naming convention
Database
Database Design
Coding Style
Naming Conventions
Relational Database
How to name factory like methods?
Coding Style
Naming Conventions
Methods
Factory
Are there any coding standards for JavaScript?
Javascript
Coding Style
Setting variable to NULL after free
C
Coding Style
Malloc
Free
Heap Memory
What was the strangest coding standard rule that you were forced to follow?
Coding Style
Why should I use var instead of a type?
C#
.Net
Coding Style
Resharper
Var
Is nested function a good approach when required by only one function?
Python
Coding Style
Nested Function
Is there a valid reason for enforcing a maximum width of 80 characters in a code file, this day and age?
Text Editor
Coding Style
Policy
Why use prefixes on member variables in C++ classes
C++
Coding Style
Naming Conventions
How to break a line of chained methods in Python?
Python
Coding Style
Pep8
Unique ways to use the null coalescing operator
C#
Coding Style
Null
Conditional Operator
Null Coalescing-Operator
Python style - line continuation with strings?
Python
Coding Style
do..end vs curly braces for blocks in Ruby
Ruby on-Rails
Ruby
Ruby on-Rails-3
Coding Style
Good or bad practice? Initializing objects in getter
C#
Coding Style
Getter
What's the deal with a leading underscore in PHP class methods?
Php
Coding Style
Forced naming of parameters in Python
Python
Function
Coding Style
Parameter Passing
Is it good style to explicitly return in Ruby?
Ruby
Coding Style
Return Value
Private vs Protected - Visibility Good-Practice Concern
Oop
Language Agnostic
Coding Style
In Intellij, how do I toggle between camel case and underscore spaced?
Java
Coding Style
Intellij Idea
How many constructor arguments is too many?
Parameters
Refactoring
Constructor
Coding Style
A free tool to check C/C++ source code against a set of coding standards?
C++
C
Coding Style
Is it a bad practice to use an if-statement without curly braces?
If Statement
Coding Style
Curly Braces
Difference in C# between different getter styles
C#
Getter
Shorthand
Coding Style
Does <STYLE> have to be in the <HEAD> of an HTML document?
Html
Coding Style
Html Head
Should I use `import os.path` or `import os`?
Python
Coding Style
Python Import
Is there a good reason to use upper case for SQL keywords?
Sql
Coding Style
Capitalization
Switch statement fall-through...should it be allowed?
Coding Style
Switch Statement
Chained method calls indentation style in Python
Python
Django
Coding Style
Pep8
Is effective C++ still effective?
C++
C++11
Coding Style
Effective C++
When is a function too long?
Function
Refactoring
Coding Style
Is pass-by-value a reasonable default in C++11?
C++
Coding Style
C++11
Haskell function composition (.) and function application ($) idioms: correct use
Haskell
Coding Style
Function Composition
Coding Style Guide for node.js apps?
Javascript
Coding Style
node.js
Default parameters with C++ constructors
C++
Constructor
Coding Style
Overloading
Why declare a struct that only contains an array in C?
C
Arrays
Coding Style
Struct
cleanest way to skip a foreach if array is empty
Php
Coding Style
Tool to convert Python code to be PEP8 compliant
Python
Coding Style
Pep8
In Python, when should I use a function instead of a method?
Python
Function
Coding Style
Methods
Why rename synthesized properties in iOS with leading underscores?
Objective C
Ios4
Coding Style
#ifdef vs #if - which is better/safer as a method for enabling/disabling compilation of particular sections of code?
C++
C
If Statement
Coding Style
C Preprocessor
What is "point free" style (in Functional Programming)?
Functional Programming
Coding Style
Scheme
Pointfree
PEP 8, why no spaces around '=' in keyword argument or a default parameter value?
Python
Coding Style
Pep8
Confused about the Interface and Class coding guidelines for TypeScript
Coding Style
Typescript
Are booleans as method arguments unacceptable?
Coding Style
Boolean
Enumeration
Naming "class" and "id" HTML attributes - dashes vs. underlines
Html
Coding Style
Naming Conventions
Best practice: ordering of public/protected/private within the class definition?
Oop
Coding Style
Class Design
Python coding standards/best practices
Python
Coding Style
Correct way to define C++ namespace methods in .cpp file
C++
Coding Style
Namespaces
Simple way to create matrix of random numbers
Python
Random
Coding Style
What is your preferred style for naming variables in R?
R
Coding Style
Naming Conventions
Does anyone still use [goto] in C# and if so why?
C#
.Net
Coding Style
Goto
Using do block vs braces {}
Ruby
Coding Style
Conveniently map between enum and int / String
Java
Enums
Coding Style
Singular or plural for enumerations?
Coding Style
Enumeration
Line continuation for list comprehensions or generator expressions in python
Python
Coding Style
List Comprehension
Pep8
Java naming convention for static final variables
Java
Coding Style
In C++, is it still bad practice to return a vector from a function?
C++
C++11
Coding Style
Return Value-Optimization
Why should a function have only one exit-point?
Coding Style
Space Before Closing Slash?
Html
Xml
Xhtml
Coding Style
Why does one often see "null != variable" instead of "variable != null" in C#?
C#
Coding Style
Is using assert() in C++ bad practice?
C++
Coding Style
Assert
Any reason to clean up unused imports in Java, other than reducing clutter?
Java
Eclipse
Coding Style
Import
Should commit messages be written in present or past tense?
Version Control
Coding Style
Is there a standard naming convention for XML elements?
Xml
Coding Style
Naming Conventions
Why do most C developers use define instead of const?
C
Coding Style
C Preprocessor
Correct way of declaring pointer variables in C/C++
C++
C
Pointers
Coding Style
JavaScript style for optional callbacks
Javascript
Coding Style
Callback
Where should I put @Transactional annotation: at an interface definition or at an implementing class?
Java
Spring
Annotations
Coding Style
What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?
Php
Python
Compiler Construction
Coding Style
Abstract Syntax-Tree
What is the gain from declaring a method as static
Java
Optimization
Coding Style
Static
Checking in of "commented out" code
Version Control
Tfs
Coding Style
Implicit conversion vs. type class
Scala
Coding Style
Implicit Conversion
Am I immoral for using a variable name that differs from its type only by case?
Language Agnostic
Coding Style
Naming Conventions
Variable Names
Style guide for c#?
C#
Coding Style
Python exception chaining
Python
Exception
Coding Style
Python 2.x
Unobtrusive JavaScript: <script> at the top or the bottom of the HTML code?
Javascript
Performance
Optimization
Coding Style
What does a good programmer's code look like?
Coding Style
Is calling destructor manually always a sign of bad design?
C++
Coding Style
Destructor
Python "private" function coding convention
Python
Python 2.7
Coding Style
Naming
Conventions
Stand-alone Java code formatter/beautifier/pretty printer?
Java
Coding Style
Code Formatting
Advantages of using const instead of variables inside methods
C#
Coding Style
Resharper
Constants
Is it ok if I omit curly braces in Java?
Java
Coding Style
Brackets
Setting top and left CSS attributes
Javascript
Coding Style
Using true and false in C
C
Coding Style
Auto-indent spaces with C in vim?
C
Vim
Coding Style
Vi
Do you leave parentheses in or out in Ruby?
Ruby
Coding Style
Do you end your exception messages with a period?
C#
Exception
Coding Style
Message
What does the dot mean in R – personal preference, naming convention or more?
R
Coding Style
Naming Conventions
Plyr
Jquery - How to get the style display attribute "none / block"
Jquery
Coding Style
Attributes
Importing modules in Python - best practice
Python
Coding Style
Workflow
Python Import
Function names in C++: Capitalize or not?
C++
Function
Coding Style
Naming Conventions
Splitting C++ Strings Onto Multiple Lines (Code Syntax, Not Parsing)
C++
String
Syntax
Coding Style
Readability
Two ways of currying in Scala; what's the use-case for each?
Scala
Coding Style
Currying
Is there a downside to adding an anonymous empty delegate on event declaration?
C#
Coding Style
Delegates
Events
Idioms
Do you use the TR 24731 'safe' functions?
C
Security
Coding Style
Tr24731
Java constructor style: check parameters aren't null
Java
Constructor
Null
Coding Style
Using try/catch for preventing app from crashes
Java
Android
Design Patterns
Coding Style
Try Catch
Parenthesis surrounding return values in C
C
Syntax
Coding Style
Dot notation vs. message notation for declared properties
Objective C
Syntax
Coding Style
Python: using sys.exit or SystemExit differences and suggestions
Python
Performance
Coding Style
Netbeans 7.4 introduces "10 lines max" per method rule. Where does this rule come from?
Netbeans
Methods
Conventions
Coding Style
Passing hashes instead of method parameters
Ruby
Oop
Coding Style
What is the recommended coding style for PowerShell?
Powershell
Coding Style
Java - when to use 'this' keyword
Java
Coding Style
This
How do you PEP 8-name a class whose name is an acronym?
Python
Coding Style
Naming Conventions
abstract class naming convention
Java
Coding Style
SQL Statement indentation good practice
Sql
Coding Style
Indentation
Naming Conventions: What to name a boolean variable?
Coding Style
Naming Conventions
Pylint invalid constant name
Python
Coding Style
Pylint
Is it bad to explicitly compare against boolean constants e.g. if (b == false) in Java?
Java
Coding Style
Boolean
How do you edit files over SSH?
Coding Style
Editor
Ssh
Terminal
Is it correct to use single quotes for HTML attributes?
Html
Syntax
Coding Style
Apostrophe
Intellij (Android studio) member variable prefix
Java
Intellij Idea
Coding Style
Android Studio
How to indent Python list-comprehensions?
Python
Coding Style
Tools to find included headers which are unused?
C++
Coding Style
Header Files
Why is it bad practice to call an eventhandler from code?
Delphi
Vb6
Coding Style
Realbasic
c#: difference between "System.Object" and "object"
C#
Coding Style
Good Haskell coding standards
Haskell
Coding Style
Conventions
How should one comment an if-else structure?
Coding Style
Comments
Clearest way to build html elements in jQuery
Javascript
Jquery
Coding Style
Element
TypeScript Coding Style Guide?
Coding Style
Typescript
Python import coding style
Python
Coding Style
PHP Coding styles return; in switch/case
Php
Coding Style
C# Custom getter/setter without private variable
C#
Coding Style
Accessor
Automatic Properties
Conditional logging with minimal cyclomatic complexity
Language Agnostic
Logging
Coding Style
Cyclomatic Complexity
Naming Conventions: What to name a method that returns a boolean?
Coding Style
Naming Conventions
What are your favorite C++ Coding Style idioms
C++
Coding Style
How to copy a dict and modify it in one line of code
Coding Style
Python
Why is "else" rarely used after "if x then return"?
Java
Coding Style
If Statement
Function Exit
int vs const int&
C++
Coding Style
Reference
Constants
x >= x pattern in JavaScript
Javascript
d3.js
Coding Style
Nan
Why does StyleCop recommend prefixing method or property calls with "this"?
C#
.Net
Coding Style
Stylecop
Should 'if' statement always have an 'else' clause?
Coding Style
Ruby Style: How to check whether a nested hash element exists
Ruby
Hash
Coding Style
What's the reasoning behind putting constants in 'if' statements first?
C++
Coding Style
Constants
If Statement
Correct style for line breaks when chaining methods in Python
Python
Coding Style
Line Breaks
Pep8
When is it appropriate to use a semicolon?
Typescript
Coding Style
Which coding style you use for ternary operator?
Php
Language Agnostic
Coding Style
Ternary Operator
C++ getters/setters coding style
C++
Coding Style
Getter Setter
Member variables vs setArguments in Fragments
Java
Android
Coding Style
Android Fragments
What are the benefits to using anonymous functions instead of named functions for callbacks and parameters in JavaScript event code?
Javascript
Coding Style
Callback
Anonymous Function
Code Readability
Why use a for loop instead of a while loop?
Loops
Coding Style
Control Flow
Any reason NOT to always use keyword arguments?
Coding Style
Python
Java Conventions: use getters/setters WITHIN the class?
Java
Coding Style
Why does the STL/Boost C++ coding style differ so much from everyone elses?
C++
Coding Style
Naming Conventions
Ignore camelcase variable in JSHint
Javascript
Coding Style
Jshint
Code Cleanup
Using implicitly typed local variables
C#
Coding Style
Implicit Typing
When to use each method of launching a subprocess in Ruby
Ruby
Performance
Coding Style
Standards
Subprocess
Are there standards for Linux command line switches and arguments?
Linux
Coding Style
Command Line-Interface
How to signal "not implemented yet"?
Ruby
Exception Handling
Coding Style
Conventions
Alphabetizing methods in Visual Studio
Visual Studio
Visual Studio-2008
Coding Style
Resharper
Organization
Ruby: unless vs if not
Ruby
Coding Style
Use of Haskell state monad a code smell?
Haskell
Coding Style
Monads
State Monad
Should I use public properties and private fields or public fields for data?
C#
.Net
Coding Style
Properties
How do you use Control.Applicative to write cleaner Haskell?
Haskell
Coding Style
Modifier Keyword order in Java
Java
Syntax
Coding Style
Access Modifiers
SQL formatting standards
Sql
Sql Server
Formatting
Standards
Coding Style
What is the advantage of the 'src/main/java'' convention?
Java
Coding Style
Conventions
How do I write a RGB color value in JavaScript?
Javascript
Function
Coding Style
Colors
Rgb
Get rid of ugly if statements
Java
Coding Style
Opaque C structs: various ways to declare them
C
Coding Style
Struct
Typedef
Opaque Pointers
JavaScript: What dangers are in extending Array.prototype?
Javascript
Coding Style
Prototype
Preferred standard use: range based for or std::for_each
C++
Coding Style
C++11
importing multiple functions from a Python module
Python
Coding Style
Import
Multi-line description of a parameter description in python docstring
Python
Coding Style
Python Sphinx
Restructuredtext
Docstring
how to change dart line length in vscode when formatting dart files?
Flutter
Dart
Visual Studio-Code
Formatting
Coding Style
Why would var be a bad thing?
C#
Coding Style
Implicit Typing
In C#, what's the best way to spread a single-line string literal across multiple source lines?
C#
String
Coding Style
Prefixing property names with an underscore in Objective C
Iphone
Objective C
Coding Style
Arguments Against Annotations
Java
Coding Style
Annotations
Is there a difference between main(String args[]) and main(String[] args)?
Java
Coding Style
Argument Passing
Should I Return None or (None, None)?
Python
Python 3.x
Coding Style
Why an expression instead of a constant, in a C for-loop's conditional?
C
For Loop
Coding Style
Expression
Constantfolding
Static factory methods vs Instance (normal) constructors?
Design Patterns
Constructor
Coding Style
Is assignment in a conditional clause good ruby style?
Ruby
Coding Style
Multiple or Single Try Catch
Java
Exception Handling
Coding Style
isset() vs strlen() - a fast/clear string length calculation
Php
Coding Style
Attributes initialization/declaration in Python class: where to place them?
Python
Coding Style
Attributes
Is there a nice way to make function signatures more informative in Haskell?
Haskell
Syntax
Coding Style
Functional Programming
Why does the Swift language guide suggest using Int "even when values are known to be non-negative"?
Types
Coding Style
Swift
Type Safety
What are hard and soft tabs?
Coding Style
Terminology
Tabbing
How many lines of code should a function/procedure/method have?
Function
Coding Style
Refactoring
Code Metrics
Use a 'goto' in a switch?
C#
Coding Style
Switch Statement
Goto
What SQL coding standard do you follow?
Sql
Coding Style
Should I seal all classes I know shouldn't ever be used as a base class?
C#
Coding Style
Class
Sealed
Currying subtraction
Haskell
Coding Style
Long imports in Python
Python
Coding Style
Theme/Style is not applied when inflater used with ApplicationContext
Android
Coding Style
Themes
How much duplicated code do you tolerate?
Refactoring
Coding Style
Dry
Code Duplication
JavaScript braces on new line or not?
Javascript
Coding Style
Conventions
Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'
Android
Coding Style
Should you use the private access modifier if it's redundant?
C#
Coding Style
Strategy Pattern with no 'switch' statements?
C#
Design Patterns
Dependency Injection
Strategy Pattern
Coding Style
Space after if, while, etc (and before the paren)
Coding Style
Assignment with "or" in python
Python
Coding Style
Variable Assignment
Why are try blocks expensive?
.Net
Coding Style
Should you always use 'int' for numbers in C, even if they are non-negative?
C
Coding Style
PHP: Access Array Value on the Fly
Php
Arrays
Coding Style
Your preferred C/C++ header policy for big projects?
C++
C
Coding Style
Include
Header
How do you test your Request.QueryString[] variables?
C#
Coding Style
Tryparse
Isnumeric
request.querystring
When to use properties instead of functions
C#
Properties
Coding Style
How to force a class to be initialised?
Java
Coding Style
Static Initializer
JavaDoc: where to add notes/remarks to documentation?
Java
Coding Style
Javadoc
How to generically format a boolean to a Yes/No string?
C#
Formatting
Coding Style
String Formatting
Oracle Java code conventions
Java
Coding Style