If a class inherited many times could be slower?

When I try to create a good hierarchy of objects that will help me write less code and avoid using unnecessary fields, I feel free to create many base classes for a good grouping, which is usually abstract. What could be the inconvenience of doing it like this? Can an inherited class be slower? To see a lot of unnecessary abstract classes that don't have enough names, can it cause embarrassment when you run into it in intelli-sense (auto-complete)? What could be different?

+3
source share
4 answers

Can an inherited class be slower?

There is only one way to answer productivity questions: try in both directions and measure the results. Then you will find out.

What could be inconvenient for this?

The disadvantage of overly complex object hierarchies is:

1) they are confusing because they are concepts that are not part of the business area

, , , -. , StorableObject, Employee, Room, Computer, Employee, Room Computer StorableObject. "StorableObject", - . -, , : " " "? , , - , . " " -, ".

2) # " "; . , , - . Vehicle MilitaryVehicle CivilianVehicle, Aircraft, , .

; , . , , , , , .

. , .

+9

, , .

+4

- , , , , , .

- .

B / A , B , , , , A B. , k_b, .

+2

(), A, B, C... Q, B A, C B Q, P.

, x A, x B ..

.

Based on this, I could see that if it took 1 second (scaled) to create a type A object, it took 7-8 seconds to create a type Q object.

Thus, the answer should be YES; a hierarchy that is too deep will affect performance. If this is noteworthy depends on many things and how many objects you create.

+2
source

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


All Articles