Coding style is a set of guidelines that helps readability and understanding of the source code.
0
votes
1answer
62 views
Which is preferred coding style to validate and return from a method [duplicate]
Which of the below is a preferred coding style (in c# .net)
public void DoWork(Employee employee)
{
if(employee == null)
return;
if(!string.IsNullOrEmpty(employee.Name))
return;
// Do ...
-2
votes
0answers
44 views
Fixing problem for existing code [on hold]
I have to work on a project which is already done by 3 developers. My client seems to find bugs and ask me to fix it. But now i am seeing there are plenty of errors in the system. One main problem is ...
52
votes
7answers
3k views
Should you always pass the bare minimum data needed into a function
Let's say I have a function IsAdmin that checks whether a user is an admin. Let's also say that the admin checking is done by matching user id, name and password against some sort of rule (not ...
3
votes
6answers
546 views
More elegant way to avoid hard coding the format of a a CSV file?
I know this is trivial issue, but I just feel this can be more elegant.
So I need to write/read data files for my program, lets say they are CSV for now. I can implement the format as I see fit, but ...
-2
votes
1answer
72 views
Resources for learning good code structure/stye for non-OO languages [closed]
A coworker asked me today if I could recommend any books on good code structure/style. He's working in C and all the ones I can think of are about OOA/D and OO design patterns.
Do you have any ...
1
vote
1answer
43 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 ...
1
vote
2answers
387 views
Good or bad code? Or “a secret reason”?
I think this code:
if(file_exists("amodule.inc.php"))
require_once("amodule.inc.php");
is misleading because of the use of the require_once.
I think that - to keep the logic and "wording" ...
-1
votes
2answers
256 views
Interview Coding Assignments… how much do they account for? [closed]
So I've ran into a couple of companies that requires completing coding assignments before they give you a phone interview. I'm curious, do these coding assignments account for anything after the ...
0
votes
0answers
43 views
Boolean condition before variable [duplicate]
I have noticed this style from time to time:
if ( 0 == myVar )
Rather than:
if ( myVar == 0 )
Is this just the individual programmers idiom? A defensive programming style? Does anyone know if it ...
0
votes
2answers
115 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 ...
16
votes
12answers
1k views
Correct comment to put for boolean function arguments that are “false”?
From some open source projects, I gathered the following coding style
void someFunction(bool forget);
void ourFunction() {
someFunction(false /* forget */);
}
I always have doubt about what ...
3
votes
3answers
449 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
362 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 ...
1
vote
1answer
174 views
Is nesting typedefs a good style?
Let's say I have a namespace my and this namespace contains a class foo.
What should I prefer nesting typedefs into my class or hold it in my namespace?
namespace my {
class foo {
// some stuff
...
6
votes
6answers
484 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 ...