Most Popular
1500 questions
61
votes
8 answers
LSP vs OCP / Liskov Substitution VS Open Close
I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more).
the open/closed principle states "software entities (classes, modules, functions, etc.) should be…

Kolyunya
- 955
- 2
- 9
- 15
61
votes
14 answers
Forbidding or controlling "Hidden IT..." Who should write and maintain ad-hoc software applications?
Bigger companies usually have the problem, that it is not possible to write all programs employees want (to save time and to optimize processes) due to a lack of staff and money.
Then hidden programs will be created by some people having (at least…

matcauthon
- 1,221
- 1
- 10
- 18
61
votes
12 answers
Is it bad practice to pass instances through several layers?
In my program design, I often come to the point where I have to pass object instances through several classes. For example, if I have a controller that loads an audio file, and then passes it to a player, and the player passes it to the…

Puckl
- 1,525
- 2
- 13
- 17
61
votes
16 answers
Why not write all tests at once when doing TDD?
The Red - Green - Refactor cycle for TDD is well established and accepted. We write one failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing many failing unit tests for a class and make them…

RichK
- 1,457
- 2
- 12
- 12
60
votes
10 answers
Is there such a thing as staying in a job too long?
After reading through a few "job hopping" related threads recently, I've been thinking how the opposite of job hopping can also be a problem.
I've known many people (especially in large, relatively sluggish companies) who got comfortable in a cushy…

Bobby Tables
- 20,516
- 7
- 54
- 79
60
votes
14 answers
What is the history of the use of "foo" and "bar" in source code examples?
Why do many code examples, especially tutorials, use the names "Foo" and "Bar" so often? It is almost a standard.
For example:
void foo(char* bar) {
printf("%s", bar);
}
user15453
60
votes
13 answers
Have you ever been involved in a BIG Rewrite?
Joel Spolsky said in one of his famous posts:
The single worst strategic mistake
that any software company can make:
rewrite the code from scratch.
Chad Fowler wrote:
You’ve seen the videos, the weblog
posts and the hype, and you’ve…

systempuntoout
- 3,545
- 3
- 29
- 33
60
votes
5 answers
How to explain to a non-technical person why the task will take much longer than they think?
Almost every developer has to answer questions from business side like:
Why is going to take 2 days to add this simple contact form?
When a developer estimates this task, they may divide it into steps:
make some changes to the Database
optimize DB…

Mag20
- 3,281
- 2
- 23
- 21
60
votes
10 answers
If null is a billion dollar mistake, what is the solution to represent a non-initialized object?
This comes with a debate with my colleague that I'm using null as an object initial state.
type Value = Node | null
const [value, setValue] = React.useState(null)
function test(v: Value) {
if (value === null) // Do something
else // Do…

Mengo
- 579
- 1
- 4
- 7
60
votes
8 answers
Should generated documentation be stored in a Git repository?
When you use tools like jsdocs, it generates static HTML files and its styles in your codebase based on the comments in your code.
Should these files be checked into the Git repository or should they be ignored with .gitignore?

garbage collection
- 1,281
- 1
- 13
- 15
60
votes
7 answers
Code coverage highlights unused methods - what should I do?
I have been tasked to increase code coverage of an existing Java project.
I noticed that the code coverage tool (EclEmma) has highlighted some methods that are never called from anywhere.
My initial reaction is not to write unit tests for these…

Lucas T
- 753
- 1
- 5
- 9
60
votes
16 answers
Why did SQL injection prevention mechanism evolve into the direction of using parameterized queries?
The way I see it, SQL injection attacks can be prevented by:
Carefully screening, filtering, encoding input (before insertion into SQL)
Using prepared statements / parameterized queries
I suppose that there are pros and cons for each, but why did…

Dennis
- 8,157
- 5
- 36
- 68
60
votes
4 answers
DDD repositories in application or domain service
I m studying DDD these days, and I m having some questions concerning how to manage repositories with DDD.
Actually, I have met two possibilies :
First one
The first way of manage services I've read is to inject a repository and a domain model in an…

mfrachet
- 1,481
- 3
- 15
- 21
60
votes
3 answers
Name of a program's startup/initial loading window?
I am writing user documentation (an SOP) that involves third party programs that I am trying to describe well. One such program is a server that offers little indication of it's startup besides a graphic that shows during its initialization/startup…

rtmh
- 643
- 5
- 8
60
votes
4 answers
Is it better to call a function that doesn't have an effect at that point, IF it improves code clarity?
I have three views in my program (iOS app). Only one of them is ever active at the same time so I set the visibility off for two of them and switch visibility as the user presses buttons. The views are initialized as visible so I set the visibility…

Kevin
- 844
- 1
- 7
- 14