Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
A design pattern is a general reusable solution to a commonly occurring problem in software design.
-2
votes
Do Design Patterns Stifle Creativity
Design patterns are of course less creative. That's the whole idea. Creativity is a scarce resource. You shouldn't waste it on problems that don't need creativity. It is much easier, quicker, and more …
1
vote
What is the "Fix Everything" design pattern?
I have mostly used this within user interfaces. The nice thing is that you write it once, and it handles everything from the simplest to the hardest case equally well (for example if the user rotates …
1
vote
Multiple steps of mutations in one function - how to refactor?
Just a minor thing: it is very helpful for the stability both of the system you are implementing, and of your mind, that an operation is atomic. That is, it is either executed successfully, or it retu …
3
votes
Handling if-statements with a known duration
The simplest code doing the job is the best.
The first version just works. And it is very simple: All it has to do is to evaluate which of two functions to call, and then to call the right one. Litt …
0
votes
According to Demeter's law, is a class allowed to return one of its members?
Depends on what you are doing. If you expose a member of your class, when it's nobody's business that this is a member of your class, or what the type of that member is, that's a bad thing. If you the …
2
votes
Accepted
Should I use "dynamic" singleton design?
The essential thing about a Singleton is that there is one call which will return the same instance each time, which makes sure that the instance is available on the first call, and which makes sure t …
1
vote
Design a 1D parking lot that could park a two wheeler (1 slot), a car (2 slots) or a bus (4 ...
You want to allocate vehicles as near to the entrance as possible. I assume that each vehicle counts, so instead of allocating 4/1/1/1/1, you would prefer 1/1/1/1/4 which moves four vehicles to the fr …
-3
votes
Simplifying TryGet methods to execute logic
You should really try to make your TryGet method callable repeatedly without side effects. How you do that will depend on the language; in languages with garbage collection or reference counting you s …
0
votes
How to abstract version switching using feature flag?
Feature flags are very much preferable. I don't really care what version it is, as a developer I care about the features. So feature X can be turned off in version 1.1 and turned on again in version 1 …
1
vote
Is there a reason to not modify values of parameters passed by value?
In C++, a parameter can have type (for example) int i, const int i, int& i, and const int& i. References obviously work different, but if you want to prevent assignment to i, you just make it const in …
0
votes
Do Private methods in subclasses violate Liskov Substitution Principle?
Clearly if I have an object with a property “InterestRate” with a getter and setter then I expect that calling the setter to change the value returned by the getter and the interest calculation. Your …
0
votes
Best Practice - Wrapping if around function call vs Adding early exit if guard in function
There are two cases: One, you have a function that should either be run or not, depending on the situation. If the function itself cannot decide, the caller must decide.
Two, you have a function that …
0
votes
Is this a candidate for Singleton?
So I just bought this USB hub with seven ports. And I had this great idea to put a thermometer into each room of my home. The problem is... there's a singleton object!
The other problem is that other …
1
vote
Call class method only if condition is met
Just a note: It is very, very, very difficult to determine precisely whether you are online or not. The only method that really works is to send a request, and to interpret any success or error messag …
0
votes
How to handover an iOS project that creates views in code?
It's a good idea to have a comment at the top of each source file explaining what the code in each source file is good for, and what you would have to do as a user of the application to execute this c …