Most Popular
1500 questions
57
votes
9 answers
In what cases is less code not better?
I have refactored some code at work lately, and I thought I did a good job. I dropped 980 lines of code to 450 and halved the number of classes.
When showing this to my colleagues some did not agree that this was an improvement.
They said - "fewer…

PiersyP
- 543
- 1
- 4
- 6
57
votes
4 answers
Are there exceptional cases where we can accept duplicate code?
I'm working on a software project where we have to build three APIs. One for the home banking channel, one for the agency channel and a third for the mobile channel.
The agency API is the most complete one as it has all the functionalities .. then a…

Mohamed Amine Mrad
- 733
- 1
- 7
- 12
57
votes
5 answers
Should I really use all uppercase for my constants?
I am a Python programmer primarily who uses pylint for linting source code. I am able to eliminate all of the warnings except one: Invalid name for a constant. Changing the name to all caps fixes it, but am I really supposed to do that? If I do it,…

Abhishek Kumar
- 681
- 1
- 5
- 7
57
votes
5 answers
How do you explain Separation of Concerns to others?
If you had a colleague who didn't understand the benefits of Separation of Concerns, or didn't understand it quite enough to apply consistently in their daily work, how would you explain it to them?

Marcie
- 3,009
- 2
- 19
- 21
57
votes
3 answers
Is it an antipattern to use peek() to modify a stream element?
Suppose I have a stream of Things and I want to "enrich" them mid stream, I can use peek() to do this, eg:
streamOfThings.peek(this::thingMutator).forEach(this::someConsumer);
Assume that mutating the Things at this point in the code is correct…

Bohemian
- 1,956
- 2
- 17
- 24
57
votes
4 answers
Development process used for the code on Apollo 11 missions?
The Apollo missions had technology no more complicated than a pocket calculator.
From link here, there's an information about Apollo Guidance Computer (AGC)
The on-board Apollo Guidance Computer (AGC) was about 1 cubic foot with 2K of 16-bit RAM…

Josip Ivic
- 1,617
- 5
- 28
- 46
57
votes
8 answers
Is it good practice to rely on headers being included transitively?
I'm cleaning up the includes in a C++ project I'm working on, and I keep wondering whether or not I should explicitly include all headers used directly in a particular file, or whether I should only include the bare minimum.
Here's an example,…

futlib
- 2,107
- 3
- 21
- 26
57
votes
6 answers
Should a getter throw an exception if its object has invalid state?
I often run into this problem, especially in Java, even if I think it's a general OOP issue. That is: raising an exception reveals a design problem.
Suppose that I have a class that has a String name field and a String surname field.
Then it uses…

AgostinoX
- 841
- 1
- 6
- 12
57
votes
3 answers
What is a symbol in Ruby?
I'm totally new to the Ruby world, and I'm a bit confused with the concept of Symbols. What's the difference between Symbols and Variables? Why not just using variables?
Thanks.

wassimans
- 1,173
- 2
- 10
- 12
57
votes
5 answers
Why do all functions take only ranges, not containers?
There are many useful functions in , but all of them operate on "sequences" - pairs of iterators. E.g., if I have a container and like to run std::accumulate on it, I need to write:
std::vector myContainer = ...;
int sum =…

lethal-guitar
- 2,065
- 2
- 16
- 19
57
votes
5 answers
Is jQuery an example of "god object" antipattern?
I want to ask – I am slowly learning jQuery.
What I see is an exact example of a God Object anti-pattern. Basically, everything goes to the $ function, whatever it is.
Am I right and is jQuery really an example of this anti-pattern?

Karel Bílek
- 697
- 5
- 8
57
votes
8 answers
Why a static main method in Java and C#, rather than a constructor?
I’m Looking for a definitive answer from a primary or secondary source for why (notably) Java and C# decided to have a static method as their entry point, rather than representing an application instance by an instance of an Application class (with…

Konrad Rudolph
- 13,059
- 4
- 55
- 75
57
votes
5 answers
Where should I put functions that are not related to a class?
I am working on a C++ project where I have a bunch of math functions that I initially wrote to use as part of a class. As I've been writing more code, though, I've realized I need these math functions everywhere.
Where is the best place to put them?…

coconut
- 673
- 1
- 5
- 5
57
votes
11 answers
IDEs for dynamic languages - how far can you get?
I find it frustrating how the speed of development that dynamic languages should offer gets significantly compromised by the lack of completions and other assets that IDEs would give you in their static counterparts.
It's not just about typing less…

deprecated
- 3,297
- 3
- 20
- 26
57
votes
6 answers
Should unit tests be stored in the repository?
I'm a growing programmer who's finally putting unit testing into practice for a library that I'm storing on GitHub.
It occurred to me that I might include the test suites in the repo, but as I look around at other projects, the inclusion of tests…

parisminton
- 673
- 1
- 5
- 6