Design patterns (repeatable solutions to commonly occurring problems) and best practices in software engineering
Questions tagged [patterns-and-practices]
365 questions
171
votes
11 answers
What happened to the "Surgical Team" pattern from "The Mythical Man-Month"?
Years ago, when I read The Mythical Man-Month, I found lots of stuff which I already knew from other sources. However, there were also new things in there, despite the book being from 1975. One of them was:
The Surgical Team
Mills proposes that…

vog
- 1,424
- 2
- 11
- 10
111
votes
13 answers
Exception vs empty result set when the inputs are technically valid, but unsatisfiable
I'm developing a library intended for public release. It contains various methods for operating on sets of objects - generating, inspecting, partitioning and projecting the sets into new forms. In case it's relevant, it's a C# class library…

anaximander
- 2,285
- 3
- 19
- 21
104
votes
3 answers
When and for what purposes should the const keyword be used in C for variables?
While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables.
I am confused about what are the various situations when it can be useful.
Should it…

Aseem Bansal
- 2,954
- 6
- 20
- 33
92
votes
5 answers
Best practices for making header file?
What things should absolutely always/never be included in a header file?
Functions: what must go in the header file and what mustn't
Constants: Is it good practice to define lot of constants in a header file?
Any other good practices for C header…

Moshe Magnes
- 1,071
- 1
- 8
- 6
90
votes
6 answers
Is it bad practice to enforce an execution order for unit tests?
I am writing tests for a project that consists of multiple submodules. Each test case that I have written runs independent of each other and I clear all data between tests.
Even though the tests run independently, I am considering enforcing an…

Ali Rasim Kocal
- 992
- 1
- 6
- 11
80
votes
8 answers
Is modifying an incoming parameter an antipattern?
I am programming in Java, and I always make converters sort of like this:
public OtherObject MyObject2OtherObject(MyObject mo){
... Do the conversion
return otherObject;
}
At the new workplace the pattern is:
public void…

CsBalazsHungary
- 1,389
- 3
- 13
- 15
80
votes
2 answers
Are there any OO-principles that are practically applicable for Javascript?
Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by:
Writing the functions to be used as classes by yourself
Use a nifty class system in a framework (such as mootools…

Spoike
- 14,765
- 4
- 43
- 58
75
votes
4 answers
Developing a feature which sole purpose to be taken out?
What is the name of the pattern in which individual contributors (programmers/designers) developed an artifact for the sole purpose is to serve as a diversion so that management can remove that feature in the final product?
This is a folklore I…

adib
- 925
- 1
- 7
- 9
54
votes
8 answers
Term (or "pattern"?) for "Do something if it's not already done"
Sounds pretty basic, I know, but I recently had a colleague tell me that a method called startHttpServer is too complicated to understand because it only starts the server if it's not already running. I find I get into trouble when I respond with,…

John Calcote
- 599
- 4
- 4
54
votes
5 answers
Is "convention over configuration" not violating basic programming principles?
I was looking at the WPF MVVM framework Caliburn.Micro and read that a lot of standard things are based on naming conventions.
For example, automatic binding of properties in the View to properties in the ViewModel. Although this seems to be…

Geerten
- 1,135
- 1
- 8
- 12
48
votes
11 answers
Are error variables an anti-pattern or good design?
In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to handle this? For an example of this in action…

Mikayla Maki
- 603
- 1
- 5
- 14
45
votes
6 answers
What is the best way to initialize a child's reference to its parent?
I'm developing an object model that has lots of different parent/child classes. Each child object has a reference to its parent object. I can think of (and have tried) several ways to initialize the parent reference, but I find significant…

Steven Broshar
- 575
- 1
- 4
- 4
40
votes
6 answers
Should I place functions that are only used in one other function, within that function?
Specifically, I'm writing in JavaScript.
Let's say my primary function is Function A. If Function A makes several calls to Function B, but Function B is not used anywhere else, then should I just place Function B within Function A?
Is that good…

Gary
- 503
- 1
- 4
- 5
39
votes
8 answers
Is it ok copying code from one application to another, both belonging to the same repository, to keep them independent?
Given a repository which contains two different applications A and B (e.g. bootloader and RTOS), is it ok to copy source code from A to B in order to avoid dependencies (include's, adding A source files to the B compilation) between them, so they…

Dan
- 615
- 5
- 7
38
votes
6 answers
Try/Catch/Log/Rethrow - Is Anti Pattern?
I can see several post where importance of handling exception at central location or at process boundary been emphasized as a good practice rather than littering every code block around try/catch. I strongly believe that most of us understand the…

rahulaga-msft
- 1,402
- 1
- 11
- 24