Class is a collection of objects to display the object's structure and interactions with the system. Class main attribute (Attribute) and method (Method) composition, properties represent the state of the object, if the property is saved to the database, this called the "persistence"; way representative of the operational behavior of objects, class inheritance, can be inherited in the parent class, you can also interact with other Class.
Class diagram shows the logical structure of the system, the relationship between classes and interfaces.
Second, the composition of class
There are properties and methods class composition. Such as product attributes are: name, price, height, width, etc.; commodities methods: calculation of tax rates, access to product evaluation and so on. As illustrated
Third, the relationship between classes (Relationship)
Two relatively independent of the object, when an object instance with another instance of an object-specific fixed relationship exists, this association exists between the two object relations.
1, one-way association
A1-> A2: understanding that A1 A2, A1 aware of the existence of A2, A1 can call A2 in the methods and properties
Scene: orders and goods, including goods orders, but the goods do not understand the existence of orders.
Class and class one-way between the incidence graph of:
C # code:
Public class Order
Public List<Product> order;
Public void AddOrder(Product product )
Public Class Product
Code performance :Order(A1) In Product(A2) The variable or reference
2. Bidirectional Association
B1-B2: Understanding that represents B1 B2,B1 Aware of the existence of B2 ,B1 You can call the B2 's methods and properties : Also know as B2 B1 In the present, the B2 can also call the B1 Methods and properties .
Scene : Orders and customers, orders belonging to a customer , The customer has some specific orders
Class and unidirectional associations between a class diagram
Public class User
Public List<Order> GetOrder()
} return new List<Order>();
Public Class Order
Public User GetUserByOrderID(string OrderId )
Return new User();
With the association between a class object
Self-association between class and class diagram
4, multi-dimensional correlation (N-ary Association)
Correlation between the number of objects
Scene: The company employs the same time, companies need to pay wages to employees
Class and the class of multi-dimensional correlation map between:
5, generalization (Generalization)
Classes and class inheritance, relations between classes and interfaces.
Scene: Father and Son, animals and people, plants and trees, the system users and B2C relationship between members and B2E Member
Generalization between classes and the class diagram:
Users of the system include: B2C members, B2B and B2E Member Member
6, dependent on (Dependency)
Class A to complete a function must refer to class B, then A and B there is dependency, dependency is a weak association.
C # does not recommend the two-phase dependent, that is, each reference
Had no relationship between man and computer, but by chance, people need to write a computer program, this time people will rely on the computer.
Class and class dependency graph
Generally in the program using reference.
7, aggregation (Aggregation)
When the object A is added to the object B, as an integral part of the object B, object B and object A relationship between the aggregate. Aggregation is an association relationship is a strong correlation between stress the relationship between whole and part.
Scene: goods and his specifications, style is the aggregation relationship.
Class and the class diagram of polymerization
8, composite (Composite)
Object A contains object B, object B from object A has no real meaning. Is a stronger association. One contains hand, the hand leave the human body loses its proper role.
Scene: Window Forms from the slider slider, the head and work areas Header Panel combination.
Combination of class and class diagram
In this paper, the relationship between classes used a simple description, are: correlation, generalization, dependency, aggregation and composition.
<! - Page ->