The relationship between class and class diagram

sponsored links
I. Introduction

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

The relationship between class and class diagram

Third, the relationship between classes (Relationship)

Association (Association)

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:

The relationship between class and class diagram

C # code:

Public class Order
Public List<Product> order;
Public void AddOrder(Product product )
Public Class Product

<script src="/ads/ads_250x250.js"></script>

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


C# Code

Public class User
Public List<Order> GetOrder()
} return new List<Order>();
Public Class Order
Public User GetUserByOrderID(string OrderId )
Return new User();

3, self-association

With the association between a class object

Self-association between class and class diagram

The relationship 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:

The relationship between class and class diagram

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:

The relationship between class and 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.

The relationship between class and class diagram

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

The relationship between class and class diagram

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

The relationship between class and class diagram

IV Summary

In this paper, the relationship between classes used a simple description, are: correlation, generalization, dependency, aggregation and composition.


<! - Page ->
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of The relationship between class and class diagram

  • Hibernate configuration parameters

    Hibernate in the configuration file: <properties> <property name="" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • hibernate to use the principle of

    The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...

  • hibernate generic generic DAO

    package org.lzpeng.dao; import; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries