Tagged Questions
59
votes
19answers
10k 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 ...
39
votes
11answers
4k 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 ...
28
votes
8answers
3k 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 ...
24
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 ...
20
votes
8answers
1k views
Should comments say WHY the program is doing what it is doing? (opinion on a dictum by the inventor of Forth)
The often provocative Chuck Moore (inventor of the Forth language) gave the following advice (paraphrasing):
"Use comments sparingly. Programs are self-documenting, with a
modicum of help from ...
19
votes
10answers
5k 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. ...
16
votes
13answers
196 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 ...
12
votes
6answers
3k 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. ...
11
votes
9answers
820 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 ...
10
votes
9answers
1k 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
5answers
1k 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 ...
8
votes
7answers
805 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 ...
8
votes
3answers
539 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 ...
7
votes
7answers
938 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?
6
votes
5answers
469 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 ...