Class diagram work

A modeling class diagram requires a set of classes related to each other, each class has a set of attributes and operations.

My question is, how and where should the implementations (bodies) be modeled for these operations?

To ask, because I'm confused in understanding the application of concepts class

, interface

,abstract class

+3


source to share


2 answers


I agree that interface and abstract set are "empty" (ie no code). This is really not the place to implement the model. I mean, every RSx instrument, Rhapsody, Modelio, etc. Has its own strategy. It can be a model as a UML comment, OpaqueBehavior, or Activity belonging to an Activity. The UML does not define where and how the code should be (Operating bodies).



I am adding a screenshot of simulating Java code using Modelio. Since you see a specific UML comment, Code is generated under the name UML, and the body of this comment is the method codeJava Hello Word

+3


source


When the class is represented in UML, the field will contain three sections. The first section is the class name The second section is the names of the class variables. The third section is the names of the class methods (with parameter types and return value).

The difference between a class (which has an implementation) and an interface (which is basically a list of empty methods with no implementation) is that the interface will have a dedicated tag above its name.

When a class uses an interface, it "promises" all of the functionality described in that interface.



To summarize: - Abstract class: can contain variables, abstract methods ("empty" method with no implementation) and regular methods. An abstract class cannot be instantiated.

  • Interface: a set of "empty" methods

  • Class: A class can extend one (and ONLY one) abstract class, in which case it needs to implement abstract methods. A class can also implement multiple interfaces (similarly, a class must implement methods defined in interfaces).

0


source







All Articles