New answers tagged

2 votes
Accepted

How encapsulating what varies can help us?

It is the nature of an example that it is simple and that a reader can easily grasp its entire content without needing an elaborate explanation. It is the nature of real production code that things ...
Flater's user avatar
  • 45.5k
1 vote

Multiple objects using the same connection for communication, filter messages "above" or inside the objects?

I think this problem is in need of another layer of abstraction. Sounds to me like you are in need of a ConnectionFilter object. That a device will link to the main connection. And it filters the ...
Adam B's user avatar
  • 1,515
2 votes

When to *not* use SOLID principles

S: Good for the most part, but be careful not to over-fragment your code and scatter functionality all over the place. O: Applicable to enterprise OOP. Probably you should just avoid inheritance, in ...
Beefster's user avatar
  • 255
1 vote

When to *not* use SOLID principles

As you are mostly looking for examples where skipping aspects of SOLID may be OK, or where sticking to it too much might be problematic, let me suggest this: The more your code base has the character ...
AnoE's user avatar
  • 5,664
1 vote

How to structure a cart with cart products object

Actually, you get to choose. Whatever makes the most sense to you. This is one of the beauties of properly separated code. You are able to define what your persistence CartProduct (i.e. the table ...
Flater's user avatar
  • 45.5k
1 vote
Accepted

How to structure a cart with cart products object

There are multiple ways to structure this, which are independent of Domain Driven Design. The Ubiquitous Language mentioned in DDD guides you in naming things. Within the realm of e-commerce, products,...
Greg Burghardt's user avatar
4 votes

When to *not* use SOLID principles

I do not think I can add anything new, as there are already a couple of really good answers, so I will merely try to put it another way around. The idea behind the SOLID principles is to have clean, ...
piotta's user avatar
  • 41
1 vote

REST - Adding a new field

There is no relation to how information is given on a REST API and how information is stored in a database. It is entirely normal and accepted that a REST API presents data from multiple database ...
Bart van Ingen Schenau's user avatar
3 votes

When to *not* use SOLID principles

The SOLID principles are also called the principles of object oriented programming. Since no other answer has mentioned it before, let me do it. You don't apply SOLID to any other programming paradigm,...
Thomas Weller's user avatar
152 votes
Accepted

When to *not* use SOLID principles

My Principle of Applying Principles: Principles, patterns, and practices are not final purposes. The good and proper application of each is therefore inspired and constrained by a superior, more ...
svidgen's user avatar
  • 14.5k
14 votes

When to *not* use SOLID principles

Even when a certain situation does not require those principles, following SOLID to a certain degree does not automatically lead to "worse code" (at least, it does not automatically make ...
Doc Brown's user avatar
  • 201k
4 votes

When to *not* use SOLID principles

All of these concepts in SOLID have disadvantages. S - This one is mostly safe, unless you are restrained from an address or storage space perspective. Think embedded software. O - Can come with a ...
Ccm's user avatar
  • 634
11 votes

When to *not* use SOLID principles

SOLID principles (and most of software engineering, really) are about human factors. The goal is to enable working on a codebase in the face of unforeseeable future requirements changes. Therefore, ...
Kilian Foth's user avatar
3 votes

How encapsulating what varies can help us?

As always the question for the "best" software design depends on the specific context and requirements, therefore there will likely be no definite answer, but lets introduce some concepts ...
Mathias Mamsch's user avatar
0 votes

How encapsulating what varies can help us?

First of all: your pancakes know how to cook and plate themselves. In my opinion that's a code smell. It also obscures why you would want to encapsulate the pancakes. Assume your EncapsulationExample ...
wallenborn's user avatar
  • 1,980
0 votes

How encapsulating what varies can help us?

Software engineering is about insuring against future, as yet unknown change. As long as all your program never changes, i.e. all it does is serve pancakes, and pancakes have no other use than being ...
Kilian Foth's user avatar
0 votes

Specialization and LSP violation?

If you want to add extra parameters to a method without changing the method signature, inject a context object into the constructor. ie ExternalDoc ExternalDoc(IContext context) public override ...
Ewan's user avatar
  • 71k
0 votes

Specialization and LSP violation?

There are two different situations: One, you use inheritance so that an "ExternalDocument" can be used wherever a "Document" can be used. In that situation it should have ...
gnasher729's user avatar
  • 42.7k

Top 50 recent answers are included