All Questions
175 questions
8
votes
5
answers
2k
views
Open Closed principle in design patterns
I am bit confused about how Open Closed principle can be applied in real life. Requirement in any business changes over the time. According to Open-Closed principle you should extend the class instead ...
3
votes
2
answers
987
views
GetOrCreate method for a database operation
I have read this thread: Is it bad coding practice to create something in a get if it does not exist?
But, my question involve a method which gets a record from a database or creates it if it doesn't ...
0
votes
3
answers
434
views
Would you test this piece of configuration code? How do I determine which code is worth testing?
We have a piece of code that decorates an interface to transparently add retry logic.
Inversion of Control configuration
service.AddOurRestApiClient()
.AddResilienceHandler("Retry", ...
0
votes
2
answers
417
views
How to restrict the construction of a domain object to an external service?
I have this object
RelativeFoo{int relativeCode, Origin relativeTo}
And I want to map it to this other object
AbsoluteFoo{int absoluteCode}
In order to do this, I need to use a service whose ...
3
votes
5
answers
993
views
How are strings simultaneously objects and primitive data types in C#?
In C#, strings can be used like objects with methods, properties, and other features of objects. At the same time, strings are treated the same as primitive data types like int or float in numerous ...
71
votes
8
answers
23k
views
How do you encode Algebraic Data Types in a C#- or Java-like language?
There are some problems which are easily solved by Algebraic Data Types, for example a List type can be very succinctly expressed as:
data ConsList a = Empty | ConsCell a (ConsList a)
consmap f ...
17
votes
3
answers
5k
views
Does the state Pattern violate Liskov Substitution Principle?
This image is taken from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
This is the class diagram for the State Pattern where a SalesOrder can have different states during ...
7
votes
3
answers
19k
views
What is meant by Scope of a variable?
I think of the scope of a variable as -
"The scope of a particular variable is the range within a program's source code in which that variable is recognized by the compiler".
That statement is ...
41
votes
8
answers
4k
views
Can modern OO languages compete with C++'s array store performance?
I just noticed that every modern OO programming language that I am at least somewhat familiar with (which is basically just Java, C# and D) allows covariant arrays. That is, a string array is an ...
6
votes
9
answers
17k
views
What are the hardest parts of the C++/C#/Java programming languages? [closed]
Just wondered what are the features of the three main programming languages which show you are an 'expert'? Please exclude 'practical' skills such as indenting.
Am I right in saying for C++ the most ...
74
votes
5
answers
83k
views
Why do C# developers newline opening brackets?
I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow ...
39
votes
9
answers
6k
views
Why do C# and Java use reference equality as the default for '=='?
I've been pondering for a while why Java and C# (and I'm sure other languages) default to reference equality for ==.
In the programming I do (which certainly is only a small subset of programming ...
1
vote
2
answers
385
views
Are experienced developers and software architects able to describe an entire software application in terms of design patterns?
Do experienced developers and software architects see entire application in terms of design patterns?
In other words experienced developers and software architects able to describe an entire software ...
-2
votes
1
answer
300
views
Why aren't constructors atomic? [closed]
If thrown exceptions in constructors can lead to memory leaks or partially-constructed objects, then why we don't make them atomic? so neither an object nor it's local variables will get created/...
1
vote
1
answer
3k
views
Any OOP design pattern that is somewhat representative of all of the SOLID OOP design principles at play?
I'm trying to teach an object oriented design principles course (on SOLID) at a training institute. I also want to teach the students a few OOP design patterns such as factory, singleton and one other....