Class encapsulates data and behavior, is an important part of object-oriented, and it is the collective name of a collection of objects with the same properties, operations, and relationships. In the system, each class has a certain responsibility, the responsibility refers to the class to complete what kind of function, to undertake what kind of obligation. A class can have multiple responsibilities, and well-designed classes generally have only one responsibility. When defining a class, the responsibilities of the class are decomposed into the properties and operations of the class (that is, methods). The property of a class is the data responsibility of the class, and the operation of the class is the behavior responsibility of the class. Design classes are the most important part of object-oriented design and the most complex and time-consuming part.
1. Object-oriented features
1) Abstract
2) Inheritance
3) package
4) polymorphic
2. Class Diagram:
When the software system is running, the class is instantiated as an object, which corresponds to a specific thing and is an instance of the Class (Instance).
Class Diagram uses the different classes that appear in the system to describe the static structure of the system, which is used to describe the different classes and the relationships between them.
In the system analysis and design phase, the class can usually be divided into three types, namely entity class, control class and boundary class (boundary Class), and the following three types are briefly described:
(a) Entity classes: Entity classes correspond to each entity in the system requirements, which usually need to be stored in a persistent storage body, typically recorded using a database table or file, which includes both the classes that store and pass the data, and the classes that manipulate the data. The entity class originates from the nouns in the requirement description, such as students, commodities, etc.
(b) Control classes: The control class is used to embody the execution logic of the application, providing the corresponding business operations, abstracting the control class to reduce the coupling between the interface and the database. The control class is usually a noun that is transformed by a verb-structure phrase (verbs + nouns), such as adding a commodity to a product, adding a class, registering a user registration class, etc.
(c) Boundary class: The boundary class is used to abstract the interaction between the external user and the system, mainly including interface classes, such as dialog boxes, windows, menus, and so on.
In the early stages of object-oriented analysis and design, it is common to identify entity classes first, and to draw initial class diagrams, where class diagrams can also be called domain models, including entity classes and their interrelationships.
PS: Domain model vs. Data modeling (ER diagram)
Domain model is an object-oriented perspective, that is, OOP, the entity in the system, the Data modeling (ER diagram) is based on the database storage and structure as a visual angle to view the entities in the system.
1) UML Diagram of Class
2) class relationships
(1) Generalization (generalization)
Used to describe the relationship between the parent class and the child class
(2) implementation (realization)
Used to describe the relationship between an interface and a class
(3) Association (Association)
A kind of structured relationship
(4) dependence (Dependency)
A usage relationship.
Cond
Java Fundamentals: Object-Oriented & class diagrams