The relationship between class and class diagram

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 ->

分类:Development 时间:2010-04-07 人气:214
blog comments powered by Disqus


  • script defer attribute in the [transfer] 2010-08-22

    Transfer from: Js code <button"myButton1""alert('ok1')"> test1 </ button> <script> (); </ Script> <script defer> myButton2.c

  • Dynamic modification framework (frame) src attribute method 2010-06-11

    Frame (frame) of the src attribute is read-only, in accordance with the normal line of thought (document.frames ["faramename"]. Src) do not have permission to modify the prompts, but by setting document.getElementById ["frameid"] in th

  • Src attribute on the embed tag 2010-09-05

    A while back to be a project, users need to upload the pdf file converted to swf file and then the page shows is mainly to prevent the crawler, use a conversion Gongju SWFTools, the use of the Internet on SWFTools many. Save the converted file's path

  • public void testStatementAddBatch () public void testConnCommit () 2011-09-01

    public void testStatementAddBatch() { Connection conn = null; Statement stmt = null; try { conn = getDBConnectionMsSqlBySuperAdmin(); stmt = conn.createStatement(); for(int i = 0; i < 100; i++) { String sql = " sql " + i; stmt.addBatch(sql);

  • The relationship between class and class performance and code UML diagram (reproduced) 2010-09-26

    The relationship between classes to understand object-oriented with a very important role, before the interview, they also often asked this question, here I introduce myself. Between classes of the following relationship: (1) generalization (Generali

  • The relationship between classes in UML: inheritance. To achieve. Dependence association. Polymerization mix and differences between 2010-11-01

    Between classes the following relationship: (1) generalization (Generalization) (2) association (Association) (3) dependence (Dependency) (4) aggregation (Aggregation) Generalization that the inheritance between class and class relationships, interfa

  • Write a small script to the latest statistics the number of lines of code to write 2010-03-27

    class CodeLineStat attr_reader :code_lines def initialize @code_lines = 0 end def stat(path) Dir.foreach(path) do |file| if file != "." && file != ".." then filePath = path + "/" + file if filePath the

  • Cannon-class persistence layer - VO package 2011-08-19

    Title: VO package I am on a blog ( describes the persistence of a small handling class, a data operation can be compatible with all kinds of ways. The most important way is to build various types of data manip

  • Documents on the Chinese android 2010-07-08

    What is Android? Android is a specialized set of software for mobile devices, which includes an operating system, middleware and some important applications. Beta version of the Android SDK provides the Android platform using the Java language for An

  • Pen questions with answers of JavaSE part of the _ 2010-12-05

    Document based questions fundamental part of the Java part of the order: basic grammar, syntax related to the class, the syntax of inner classes, inheritance-related syntax, unusual grammar, syntax of the thread, a collection of grammar, io of the gr

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C), All Rights Reserved. 版权所有 黔ICP备15002463号-1

processed in 0.351 (s). 12 q(s)