Answer the question
In order to leave comments, you need to log in
Definition of abstraction level violation?
Habrosoobshchestvo, help.
I have a question that has been bugging me for a few days now.
How to understand that I violated the abstraction level when implementing a class?
How to calculate the abstraction level of method X.
How to calculate the abstraction level of the class used in method X?
Does the decomposition of the class logic by methods intersect with a set of tasks in which the violation of the abstraction level is possible?
Answer the question
In order to leave comments, you need to log in
Dripping on the intuit site in the UML course, I unexpectedly found the answer to my question :)
So, in order:
The system is a set of interconnected managed subsystems, united by a common purpose of functioning.
A system is a set of subsystems organized to achieve a specific goal and described using a set of models, possibly from different points of view.
A subsystem is a system whose functioning does not depend on the services of other subsystems.
The software system is structured as a set of relatively independent subsystems. Interactions between subsystems are also defined.
Model- this is a certain (material or not) object that displays only the most significant characteristics of the system for a given task.
From all of the above, we conclude that a violation of the abstraction level is the use of properties in the model outside the task for which the model is intended.
Or, in other words, using the functionality of another subsystem in a subsystem.
So, the violation of the abstraction level cannot be within the methods of the same class.
Violation of the abstraction level, as far as I understand what you mean by the concept of the abstraction level, will be the fact that the class interface is inconsistent. If you have methods whose names imply that they belong to different levels of abstraction, you have violated the abstraction of the class. In other words, if the same class has getCount and getCountOfFlat methods, then there is a violation of abstraction. The appearance of such methods is likely in the presence of inheritance, which I consider an exception to the rule.
As far as I understand, from the TSPP course, the level of abstraction is an abstract value, and cannot be calculated.
An abstraction is defined solely by the interface of a class, and cannot be violated outside of that class.
The decomposition of the logic of the class, determines only its logic, and indirectly indicates what the interface will be like. Tasks that are solved using this class can only violate their own abstractions, but, theoretically, cannot violate the abstraction level of ready-made classes.
PS I have never met the concept of abstraction level outside the context of decomposition, maybe I misunderstood, therefore, I didn’t answer correctly :(
If we talk about the violation of the level of abstraction in the method, then, as a rule, it consists in the fact that the method performs several actions that belong to different levels of abstraction.
For example, if the same service method contains both business logic and calls to the database or file system that are not abstracted, for example, through DAO, then this is a violation of abstraction at the method level.
If we talk about an abstraction level violation in relation to a class, then it is usually represented by the fact that different methods of the class belong to different levels of abstraction.
For example, if some DAO methods receive domain objects as parameters, while others receive field values for direct insertion into a table, then this is a violation of abstraction at the class level.
If you think about theory and cosmic then:
In my vision, everything is simple.
If you implement two identical methods somewhere for two descendant classes, then these methods must be implemented in the base class. Also, if you wrote a method in the base class that is used only in one successor, then you need to transfer this method to this class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question