14
votes
16answers
1k views

Do else blocks increase code complexity? [closed]

Here is a very simplified example. This isn't necessarily a language-specific question, and I ask that you ignore the many other ways the function can be written, and changes that can be made to it.. ...
0
votes
2answers
64 views

Erlang return value conventions

Should functions that return tuples, always return tuples? For example, I have a function is_user_name_allowed that returns a tuple in this he form if the username is not allowed: {false, ["Reason ...
5
votes
4answers
2k views

Should you ever use private on fields and methods in C#?

I am somewhat new to C# and just found out that: in C# all of the fields and methods in a class are default private. Meaning that this: class MyClass { string myString } is the same as: class ...
2
votes
1answer
52 views

When should I pass setting-like value as class' variable and when as an assoc. array?

Following my other question, is there a general rule of thumb, when we should pass a setting-like value, that controls class' behavior (for example displayed texts) as as class' constant or variable, ...
1
vote
1answer
93 views

When should I pass value as class variable and when as a method argument?

Is there a general rule of thumb, when we should pass a value as as class variable and when as a method argument? Or is it just a choice of the developer? For example -- are there any reasons, why ...
3
votes
3answers
584 views

Avoiding boilerplate in PHP classes

I am working on a PHP code and as it grows getting more and more tired of repeating the same standard pattern again and again and again: class BolerPlate { protected $property1; protected ...
8
votes
2answers
822 views

What does Uncle Bob mean by 'noun phrase names'?

I am reading Clean Code by Uncle Bob. Because I am not a native-English speaker, I couldn't understand following statement: Classes and objects should have noun or noun phrase names like ...
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 ...
4
votes
7answers
446 views

Should I spend time prettifying unit tests? [closed]

The company I used to work for before we had automated unit tests to test our work. However the coding standards and architecture was not very important for tests. Of course you had to indent code ...
22
votes
8answers
2k views

Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth) [duplicate]

The often provocative Chuck Moore (inventor of the Forth language) gave the following advice[1]: Use comments sparingly! (I bet that's welcome.) Remember that program you looked through - the ...
4
votes
2answers
321 views

What should my “large codebase sample” look like?

If an employer asks for a large code sample, one for an entire project, what characteristics should the project have to show architectural skills and the ability to manage a large codebase? For ...
8
votes
7answers
1k views

Why would an employer ask for a 'long' code sample?

What would a large project that spanned multiple files and >1000 lines show to an employer that a few individual files and a couple hundred lines couldn't capture?
26
votes
9answers
2k views

Simple vs Complex (but performance efficient) solution - which one to choose and when?

I have been programming for a couple of years and have often found myself at a dilemma. There are two solutions - one is simple one i.e. simple approach, easier to understand and maintain. It ...
5
votes
4answers
595 views

Method flags as arguments or as member variables?

I think the title "Method flags as arguments or as member variables?" may be suboptimal, but as I'm missing any better terminology atm., here goes: I'm currently trying to get my head around the ...
11
votes
9answers
930 views

Should a programmer take writing lessons to enhance code expressiveness?

Given that programmers are authors and write code to express abstract thoughts and concepts, and good code should be read by other programmers without difficulties and misunderstandings, should a ...
1
vote
4answers
255 views

Is 'Protection' an acceptable Java class name

This comes from a closed thread at stack overflow, where there are already some useful answers, though a commenter suggested I post here. I hope this is ok! I'm trying my best to write good ...
1
vote
6answers
1k views

Setters or constructor for many variables? [duplicate]

Possible Duplicate: Are there guidelines on how many parameters a function should accept? I have got class with 30 variables (it is application form), so I wonder what is the best practice ...
3
votes
4answers
291 views

Create new variable or make multiple chained calls?

What is the best way to get this attributes, thinking in performance and code quality? Using chained calls: name = this.product.getStock().getItems().get(index).getName(); id = ...
1
vote
3answers
5k views

how to nicely use constant std::string in c++

In my current code project, there is an awful lot of constant strings I use to print out error messages. Hardcoding such strings is generally considered to be bad practice. Now I'm searching for a ...
12
votes
10answers
3k views

Passing member variable as a method parameter

In a project, I've found a code like this: class SomeClass { private SomeType _someField; public SomeType SomeField { get { return _someField; } set { _someField = value; ...
10
votes
3answers
1k views

What is the pattern name for using method chaining to build an object?

I frequently use a pattern where I using method chaining to setup an object, similar to a Builder or Prototype pattern, but not creating new objects with each method call, instead modifying the ...
3
votes
2answers
233 views

How to go about bring up the topic of bad programming practices with colleague [duplicate]

Possible Duplicate: How do I approach a coworker about his or her code quality? My development colleague is producing numerous blocks of code which I am a bit concerned doesn't really make ...
25
votes
4answers
17k views

Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: Some warnings: avoid all books that present an "hello world" stating ...
9
votes
7answers
2k views

Keep my classes and methods as small as possible?

A few days ago, I was talking to a Software Engineering PhD candidate and at some point she said to me: Keep your classes and methods as small as possible And I wonder if this is always a good ...
37
votes
8answers
6k views

How can I learn to effectively write Pythonic code?

Doing a google search for "pythonic" reveals a wide range of interpretations. The wikipedia page says: A common neologism in the Python community is pythonic, which can have a wide range of ...
42
votes
11answers
6k views

Should I reuse variables?

Should I reuse variables? I know that many best practice say you should not do it, however later when different developer is debugging the code and have 3 variables that look a like and only ...
16
votes
13answers
290 views

How to name parts of your program as a non native English speaker [duplicate]

Possible Duplicate: Do people in non-English-speaking countries code in English? I am from the Netherlands and we speak Dutch. I have worked on quite a few projects now in various ...
3
votes
5answers
490 views

Minimising little coding mistakes [closed]

I make a fair amount of small mistakes when I code (things such as getting an angle bracket to the wrong direction). It adds a fair amount of time to my coding because I have to debug several times ...
10
votes
5answers
4k views

Why have a method that returns a bool/int and has the actual object as an output parameter?

I see the following code pattern all over the place in my company's codebase (.NET 3.5 application): bool Foo(int barID, out Baz bazObject) { try { // do stuff bazObject ...
6
votes
5answers
778 views

How do you get consistency in source code / UI without stifling developer's creativity?

We have a small team (2-3) of programmers writing a program with a lot of forms and dialogs. We have a problem where we cannot keep good consistency in what we write, or how we write it. The latest ...
17
votes
6answers
8k views

What should my “code sample” look like?

I've just had quite a good phone interview (for a CakePHP-related position, not that it's especially important to the question). The interviewer seemed to be impressed with my resume and personality. ...
54
votes
15answers
11k views

What's wrong with circular references?

I was involved in a programming discussion today where I made some statements that basically assumed axiomatically that circular references (between modules, classes, whatever) are generally bad. ...