Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

System Analysis of object-oriented Technology: class Diagram

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

I. the method of identifying class diagrams and objects

1. Objects and classes

1) concept and representation

L object: an entity used to describe objective things in the system, an entity with clear semantic boundaries; as a basic unit of the system, an object has a set of attributes and a set of services that operate on these attributes.

Class l: a collection of objects that have the same attributes, services, relationships, and semantics. It provides a unified abstract description for all objects belonging to this class, and its interior includes two main parts: attributes and services.

The relationship between class and object + template and instance; the instance of class is object. The extension of a class is the set of objects it produces.

The connotation of class

Generally speaking, the elements in a class always have some common property, which is the homogeneity of the elements of the class.

2 what all the elements of a class have in common and are unique to the elements of the class (that is to say, the elements of the class do not have the property) is called the connotation of the class.

There is an intuitive "inverse relationship" between the connotation and denotation of the two types: the more the connotation of the class is, the smaller the denotation is; the smaller the connotation is, the greater the denotation is.

There is an object generated by a class that can play different roles.

2 role: a role of a class is the behavior of the object of this class in a specific context.

2 active object: an object that owns a thread or process and is able to start control activities. Is used to describe things that have active behavior.

2 active class: the class to which the active object belongs is called active class.

2 signature: the name of the service followed by a list of parameters in parentheses is called a signature (or keynote).

SetColor (String aColor)

Various representations of classes

2) the method of identifying objects and classes

Study users' needs and clarify system responsibility

2 Reading: read all written materials related to the needs of users

2 Communication: clarify one point and guide the needs

2 investigation: go to the scene to investigate

2 record and organize: generate requirements documents (supplementary use case diagrams)

Research problem domain

2 come to the scene to investigate and master the firsthand information

2 listen to the opinions of problem domain experts

2 read the materials related to the problem domain

2 draw lessons from the existing system development experience and documents in the same or similar problem domain

Consider the system boundary (referrer)

2 conditions for participant heuristics as classes in the system

Management information

Simulated behavior

Establish a communication

Consider system responsibility

2 compare each function required by system responsibility to see if these functions can be accomplished by existing objects.

2 if we find that some functions cannot be provided in any of the existing objects, it can inspire us to find some missing objects in the problem domain.

Noun technology

2 there is usually an one-to-one mapping from nouns to objects or classes.

Identify the object with a single proper noun or pronoun and a directly referenced noun.

(2) identify classes with plural nouns and different noun classes.

2 the factors that can inspire analysts to find objects include: people, organizations, items, equipment, events, forms, logs, reports, structure and so on.

3) Review and screening

Give up useless objects

(2) judging by attributes:

Does n record Miaoxia's useful information through attributes?

2 judging by service:

Does n provide some useful functionality through services?

2 neither is-- useless

2 in the application, one object should provide services for some other objects

Compact object

2 objects with only one attribute

2 objects with only one service

2 in general, the object must have multiple properties and services. There are also cases in which the object has no properties and only provides services, or the properties have no services.

Objects related to implementation conditions are deferred to OOD.

2 some functions required by system responsibility

N such as system installation, configuration, information backup, browsing-- you may not be able to find the appropriate objects from the problem domain to provide these functions, but consider adding some objects specifically for them at the design stage, postponing them to the design stage.

(2) some functions required by system responsibility may be related to the implementation environment and are deferred to the design stage.

N objects related to graphical user interface (GUI) systems, data management systems, hardware, and operating systems.

4) identify active objects

Consider problem domain and system responsibility

2 which objects need to show active behavior? -- by definition

Consider the implementation of the system in terms of requirements

2 if all object services are executed sequentially, which object (unique) is the first service executed?

2 if concurrent execution is required, which object is the starting point of each control thread? Such objects are all active objects.

Consider the system boundary

2 which objects interact with participants?

N if an interaction is initiated by a participant

N the first object to handle the interaction is the active object

5) naming of the class

All object instances suitable for this class and its special classes

2 car plus motorcycle-> motor vehicle; and horse-drawn carriage-> vehicle

Reflect individuals rather than groups

2 books-books; ships-ships

Use nouns to avoid meaningless symbols

Use the common and standardized vocabulary of the problem domain

In China: double naming can be used in both Chinese and English

6) establish the object layer of the class diagram

Use class symbols to represent each object class

Fill in the class description template

If new attributes, services and relationships are found, they can be added to the class symbol at any time.

2. Methods of identifying attributes and operations

1) concept and representation

Instance property: a named property of a class that describes the range of values that can be taken by an instance of that property.

2 the property abstracted as an attribute is related to the problem domain

2 from a technical point of view, a property is a variable (data item or state information), and each object (instance) that contains it has its own value.

2 according to the encapsulation principle of object-oriented method, the properties and services of an object are closely integrated, and the properties of an object can only be accessed by the service of this object.

Class attribute: a data item that describes the common characteristics of all objects of a class, and its property values are the same for any object instance.

2) characteristics of attributes

Proposed by ShlaerMellor (1992), supplemented by Richard C.Lee

Feature 0: an attribute must capture features that are consistent with the semantic domain of its object.

Feature 1: an instance gives an exact value for each of its attributes at any time.

Feature 2: cannot contain internal structure.

Person's last name + first name

Feature 3: the attribute must be the feature of the entire entity.

What is the screen size of the computer? Screen size of the monitor

Feature 4: the attributes of an object must be related to that object.

The volume property in the container of the oil bottle of the oil tank

Feature 5: the attribute value of an object cannot be the value of the object to which it is related.

People's salary, date of marriage.

two。 Identification service

1) concept and representation

Operation: is the behavioral characteristic of a class that describes the names, types, parameters, and constraints that trigger the related behavior.

2 has name and parameter table; visibility and return type.

2 visibility values are + (public), # (protected),-(private) or ~ (in the package).

2 visibility, parameter tables, and return types can be described in the class description template.

2 Abstract operations: operations that are not implemented in a class (that is, no methods are provided).

Service: the work that one class does for other classes. An object's service is published or exposed work that it is willing to perform when other objects request it with the help of a messaging mechanism.

Method: it is the realization of the operation. A detailed set of actions (algorithms, procedures) performed by an object when it requests the services of another object.

Object behavior classification

System behavior

Example: create, delete, copy, rollover

The behavior of the object itself-- the service with simple algorithm

Example: read and write attribute values

The behavior of the object itself-- A service with complex algorithms

Calculate or monitor

Representation:

Class scope operations are represented by an underlined string of names and type expressions. Instance-wide operations are default and are not marked.

-an abstract operation is marked "{abstract}", or the characteristic tag of the operation is written in italics to indicate that it is abstract.

2) identify the service

-OOA does not consider algorithm simple service

To create, connect, access, disconnect, delete, and so on.

-consider services with complex algorithms

An algorithmically complex business service provided by an object (such as to perform certain calculations or monitoring operations)

3) Review and adjustment

-Review each service of the target

Is it really useful?

Does it directly provide a function required by system responsibility?

Or

Perform some local operations of this function indirectly in response to requests from other services?

Adjust-cancel useless services

Is it highly cohesive?

A service only performs a single, complete function

Adjust-split or merge

4) the active behavior of the cognitive object

2 consider whether the behavior of the object in the problem domain is triggered or presented actively?

2 object services that interact with participants

2 the outer and inner layers of the object service that perform the outermost function are the relationship between the request and the requested

2 the reverse tracking of the service execution route to find the active service is to find the active object.

5) naming and positioning of services

Naming: verb or verb-object structure; extroversion

Positioning:

Be consistent with actual things

Ex.: salesperson-- sell goods, goods-- sell

Position in generalization

-- suitable for all object instances of the class

6) describe the service

Fill in the corresponding class symbol for each object's service.

2 in the class description template, write out:

2 explain the responsibilities of the service

2 Service prototype (message format)

2 message sending (indicates which other object services need to be requested when this service is executed, that is, the name of the object class that receives the message and the name of the service that executes the message)

2 constraints: if the execution of the service has pre-conditions, post-conditions, and other matters that need to be explained, such as the requirements of execution time, they will be explained here.

2 the method of implementing the service (text, activity diagram or flowchart).

III. Identification relation-generalization relation

1. Definition:

2 if class A has all the attributes and operations of class B, and also has some unique attributes or operations of its own, then An is called the special class of B, and B is called the general class of A. the relationship between An and B becomes a generalization.

2 if all objects of class An are objects of class B, and there are objects in class B that do not belong to class A, then An is a special class of B, B is a general class of A, and the relationship between An and B becomes a generalization relationship.

two。 Nature:

Future generations will have all the connections of their ancestors.

A) Anti-symmetry

If object An is a descendant of object B, then B will not have a "is" relationship with A (object B is not a descendant of object A). For example, Employee is a Person, but not everyone is an employee.

B) transitivity

If object An is an object B, and object B is an object C, then object An is an object C.

The purpose of establishing generalization in the OOA model is to make the system model map the classification relationship of things in the problem domain more clearly. It organizes classes with generalization relations together, which can simplify our understanding of complex systems, thus increasing the maintainability of software and flexibility to adapt to changes.

3. Basic representation

4. Generalized set (GeneralizationSet)

Used to define a collection of subsets in a generalization relationship.

Constraints of generalized sets

2 {complete,disjoint}

It shows that the generalization set is covered and some special classes do not have a common instance.

2 {incomplete,disjoint}

Indicates that the generalization set is not covered and that some special classes do not have a common instance.

2 {complete,overlapping}

It shows that the generalization set is covered and some special classes have common instances.

2 {incomplete,overlapping}

It shows that the generalization set is not covered, and some special classes have common instances.

2 default {incomplete,disjoint}

For example:

Fourth, the identification strategy of generalization relation

1) learn the taxonomic knowledge of the current field

2) consider the classification of things according to common sense

3) using the definition of generalization

Two classes

Collection contains

Feature inclusion

4) to see whether there is a "yes" relationship between the objects of the two classes.

Is A relation table

Inspection An is a BMague B is an A?

If all are-- synonyms

If it has never been-- there is no generalization relationship.

An is always B, B, sometimes A, then An is a B.

5) examine the attributes and services of the class.

6) consider domain-wide reuse

Review and adjustment

Do problem domains and system responsibilities need such a classification?

(example: book-rare book with useful content, rare circulation, excellent engraving, cultural relic, academic or artistic value)

Does it conform to the common sense of taxonomy?

Does it constitute an inheritance relationship? (does inherit some properties or services)

Simplification of general-special structures

(1) cancel special classes that have no particularity

Too many special classes are divided from the general classes, so that there are too many class settings in the system, which increases the complexity of the system.

The establishment of too deep inheritance level increases the difficulty of understanding and processing overhead of the system.

(2) adding attributes to simplify general-special structure

(3) abolish the general classes with single purpose and reduce the level of inheritance.

The reason for the existence of the general class

There are two or more special classes

You need to use it to create an object instance

Contribute to software reuse

Adjust object layer and feature layer

Defining generalization activities will give analysts a deeper understanding of the object classes and their characteristics in the system. In many cases, with the establishment of generalization, it is necessary to make some changes to the object layer and feature layer of the class diagram, including adding, deleting, merging or separating some classes, and adding, deleting or moving some attributes and services to other classes.

Fifth, the classification and identification strategy of association relations

1. Concept and representation

2 Association

An n association describes a collection of tuples that reference instances of a class.

N there can be multiple associations between two classes

2 chain

An n chain is a tuple of an object reference. In the most common case, it is a pair of object references. It is an instance of the association.

Example:

two。 Multiplicity

2 Multiplicity is a subset of the set of non-negative integers.

2 the multiplicity on the other end means that for one object on the local side, the number of objects on the other end is required.

(2) the lower bound and upper limit are literal integer values, indicating the integer closed interval from the lower bound to the upper limit. In addition, the asterisk (*) can be used for the upper limit, indicating that the upper limit is not limited.

2 if the multiplicity specification consists of a single (*), then it indicates an infinite range of non-negative positive integers, that is, it is equivalent to 0.

3. Role

2 has a role on each endpoint associated with it. Each role has a role name that describes what its class is considered by other classes.

2 use the associated role name when you need to emphasize the exact meaning of a class in an association.

2 if you use a role name, you can omit the association name.

The role name also determines the multiplicity of its class; that is, the number of instances of the class associated with an instance of another class.

Example:

4. Navigability

2 navigability limits the access direction of the association

2 two-way navigation does not need to draw arrows

Representation of navigability in UML2.0

5. Type of association

2 Associated classes

N modeling elements with the characteristics of associations and classes. The association class can be regarded as not only the association with the nature of the class, but also the class with the nature of association.

N represents the associated class as a class symbol connected to the associated path with a dotted line.

N association and association class symbols represent the same model elements, and their names are the same. Names can be placed on associations or in class symbols (but their names must be the same).

N if a property of a class can have multiple values at the same time, consider using an associated class.

For example, a person's salary.

Conversion from association class to binary association

2 qualified association (Qualifier)

A binary association of attributes or a list of attributes in which the value of the attribute selects a unique associated object or set of associated objects from the entire set of objects.

Qualified association (Qualifier)

The n qualifier can be an attribute of the target class

N but usually an associated attribute

N the value of this attribute qualifies the association

2 XOR association

2 ordered correlation

2 multiple association

2 polymerization

Strategy for establishing association

(2) recognize the static relationship between objects

N consider problem domains and system responsibilities-the relationships between object instances of which classes need to be expressed in the system.

U physical location or intimacy

U contains

U communication

U enjoy the service

U store information

2 recognize the associated attributes and operations

N for each association under consideration, further analyze whether it should have certain attributes and operations. That is to say, whether it contains some information that cannot be fully expressed by a simple relevance.

2 analyze and represent the multiplicity of instance connections

N from each end of the connector, it can be seen that an object on this end may be connected to several objects on the other end, marking the result to the other end of the connector.

2 processing of many-to-many associations

The problem of many-to-many association

2 using object-oriented language to realize two array pointers

2 using relational database to implement many-to-many tables

The information of n many-to-many tables is redundant

N two many-to-many relationships are transformed into tables that do not conform to the fourth normal form

Reduce the multiplicity of many-to-many associations

2 Limited association

N is implemented as a filter function with parameters in object-oriented language.

N using relational database to filter first and then connect

2 introduce a new intermediate class

N cut off many-to-many classes

N find a new intermediate class from the problem domain, which forms an one-to-many relationship with both parties.

N if the corresponding class cannot be found in the problem domain, you can conceive a

VI. A brief introduction to the analysis model

General analysis model

Accountability responsibility (party OrganizationHierarchies Organization structure …)

Observation and Measurements observation and measurement

References to Rederring to Objects objects

Domain analysis model

Financial field

Planning

business

...

Analysis mode Party

Analysis mode Organization Hierarchies (organizational level)

Analysis mode Organization structure (organizational structure)

VII. The relationship between aggregation and combination

1. Concept and representation

2 aggregation is a special form of association, which represents the "whole-part" relationship between the whole and the part.

2 aggregate is a class as a "whole" in an aggregation relationship, while a class as a "part" is called a component or part.

The aggregate relationship between classes and classes means that the object instance of one class, with the object instance of another class as its component, is a "a part of" or "has a"; it can also be understood that one class definition refers to another class definition.

2 Composition is a form of aggregation, in which there is a strong "belonging" relationship between the part and the whole, and their lifetime is the same. The multiplicity of the end of this aggregation cannot exceed 1.

2. A composite object is an instance of a composite class.

Representation:

Nature

2 structural properties

Parts must have some structural or functional relationship with the whole they build.

2 Mathematical properties

A. Antisymmetry

If object An is part of object B, then object B cannot be part of object A.

B. transitivity

If object An is part of object B, and object B is part of object C, then object An is part of object C.

classification

The nature of the whole-part relationship

Constructive: whether there is a functional or structural relationship between the whole parts.

Homogeneity: whether the types between the whole parts are the same

Invariance: the inseparability between the whole parts

According to the nature, the whole part relationship can be divided into the following categories:

Identification strategy

2 the physical whole thing and its components

Example: machine, equipment and its parts

2 organizational structure and its subordinate organizations and departments

Ex.: companies and subsidiaries, departments

2 groups (organizations) and members

Ex.: company and staff

2 one thing contains other things in space

Ex.: production workshops and machines

2 the whole and part of abstract things

Example: disciplines and sub-disciplines, laws and legal provisions

2 concrete things and some abstract aspects of them

Ex.: personnel and identity, resume

2 the composition of the material

For example, bread is made of flour, sugar and yeast, while cars are made of steel, plastic and glass.

Examination and screening

Does 2 belong to the problem domain or system responsibility?

Ex.: company employees and families

2 do some objects have more than one attribute?

Ex.: cars and tires (specifications)

2 is there an obvious whole-part relationship?

Ex.: students and courses, who is the whole? Part?

VIII. The relationship between dependence and realization

A dependency specifies a semantic relationship between two or more model elements (or a set of two model elements), and changes to the target elements may require changes to the source elements in the dependency.

The following types of dependencies are predefined:

Access-- access; derive-derivation; import-move in; refine-- refinement

Trace-- tracking; use-- uses

Include- contains; extend- extension

Representation:

Represents the dependency as a dotted arrow between two model elements. The model element (customer) at the end of the arrow depends on the model element (provider) at the head of the arrow. The arrow can be identified by a string placed in the title number of the book.

There may be a set of elements as customers or providers. In this case, one or more arrows with a tail on the client side are connected to the tail of one or more arrows with a head on the provider side. If desired, you can place small dots at the joint. Dependent comments should be attached to the join point. Use dashed lines without arrows to represent the connection between the comment or constraint and the element to which it is applied. This is not dependence.

Different types of dependencies

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report