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.
-3
votes
Implementing factory that return the correct type
You have three weaknesses.
Your classes should not be aware that they can be created by a factory. Adding them to the factory should cause no change in the class. Instead, you decided they all need a …
1
vote
What options are there to handle dependencies that may error?
You are looking at this from a coding / implementation point of view. That's the wrong view. Ask yourself: What should your application as a whole do if this dependency fails? Can it run successfully? …
12
votes
Is "avoid extra null pointer risk" a reason to avoid "introduce parameter objects"?
Null pointers are the ultimate “fail fast”. Calling your function with a null pointer would be a severe bug in the callers code. So just access the data through this pointer, there is an instant crash …
0
votes
What is the better way to escape from too many if/else-if from the following code snippet?
The switch statement with nine cases is simple, obvious, doesn’t require any extra code, and is easily extended. Note how all the answers actually avoided writing nine cases down. So they are more com …
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 …
4
votes
How to deal with boolean or enum variables used to decide code flow?
You are misunderstanding things. Booleans are there to control code behaviour. What’s bad is calling a method with three arguments f(true, true, false) with no indication what each argument means with …
2
votes
Are there any benefits to delegation over subclassing/inheritance in the case of a singleton?
Nobody cares about whatever table size.
But if you create a subclass, then a developer who knows the behaviour of the original class has no clue what your subclass will be doing. A macOS / iOS develop …
0
votes
How to eliminate repetition in three subclasses: each defines an identical method that does ...
You can try writing a plain old function that does 95% of the work, identical for all three classes. And then each class gets a tiny instance method that mostly calls the plain old function.
You could …
1
vote
Why is Global State so Evil?
What makes global state bad is not that it is global, but that basically every single line of code could change the global variable, or could be affected if it is changed.
The minimal change in C or C …
0
votes
Is "Introduce Parameter Object" actually a good pattern?
You need to pass information from caller to callee. The amount of information can usually not be changed. You can divide this information into lots of primitive parameters, or you can combine some or …
1
vote
What is the advantage/disadvantage of returning a UnSubscribe class to Observer as opposed t...
In Objective-C, for a long time observers were not automatically removed from the observable when they got deleted, leading to a crash when the observable sent a notification to an object that didn’t …
2
votes
Push and Pull Communication in object oriented: why Push style is not flexible?
In macOS and iOS, intra-app notifications send a name for the notification, and an optional object. Any name, any kind of object.
An observer registers for notifications with a certain name, and has t …
0
votes
Can 1.0.1 be launched right after 1.1.0?
Not if it is available to the general public. For example, if you write software for an iPhone, and you just released 1.1.0, Apple won't accept any version 0.x.y, or 1.0.x for your application.
If you …
0
votes
Is it an anti-pattern to use interface for entity?
If you have a simple data-only object, declaring and using an interface costs very little.
Very often you don’t have a simple data object. Say you have an object that can persist or load itself. Or co …
0
votes
Alternatives to the singleton pattern
It depends very much what you mean by singleton. My definition: A “singleton instance” (not class) is an object that serves a specific purpose, that should be exclusively used for that purpose, that i …