Does the ubiquitous base object have an anti-pattern?

I remember that I discussed this issue somewhere, and I am currently considering the possibility of deleting a base object that inherits every business object in the system that I am working on. It contains several properties, some database logic, and some design logic.

Is this an anti-pattern, or is the jury still not working? Would it be better to have a basic contract to inherit, which would require a certain amount of coding in each object?

EDIT : I like dsimcha and feel it reflects very well on this question, I'm still glad to hear further answers

+3
source share
3 answers

The standard rule is to use inheritance only to provide flexibility for class users through polymorphism and composition use if you want to reuse code from other classes. However, if you do not violate the Liskov Principle of Replacement , this is probably not so bad. Writing a ton of the template is also a bad thing, as it obscures the parts of your code where the real action takes place and is anti-dry. However, if you violate the Liskov Substitution Principle, then this is absolutely a bad idea.

+2
source

I would also like to understand what problems I am facing, or should know

, : "Eve"... ++ .

: , .Net System.Object... /, COM- IQueryInterface.

+2

- . " Eve" ? ? , -, , .

+1

Source: https://habr.com/ru/post/1702881/


All Articles