21
עעעעע עעעעעע עעעעClass diagrams Aggregation, Composition and Generalization

פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Embed Size (px)

Citation preview

Page 1: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

פיתוח מערכות מידע

Class diagramsAggregation, Composition and

Generalization

Page 2: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Stereotypes

מנגנון שמופעל על מחלקות, קשרים וסוגי •תלות בין מחלקות כדי לציין את הקטגוריה

המתאימה.

<< boundary>> << interface>>

<<control>>

<<entity>>

Page 3: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Class types

• Iconic /non-iconic representation of 3 class stereotypes: control, boundary and entity.

• Example: agreementUI – interacts directly with actors agreementControl- interacts with elements

inside systemagreementEntity- passive class manipulated

by system elements. Entity = business class

Page 4: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Association

אסוציאציה, מציין קשרים בין מופעים של מחלקות, •

מופעים מאותה בכל קצה של קשר ניתן לציין מספר מחלקה שיכולים להיות למופע אחד מהמחלקה

השנייה

מקושרים אחד או יותר מופעים של A לכל  מופע של•B אבל לכל מופע של B מקושר מופע של A אחד

ויחיד

קשר ניתן לתת שם, וגם לקשר עצמו ניתן לכל קצה של•לתת שם

Page 5: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

-A1..1

-B1..*

Association

Page 6: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Multiplicity and Cardinalityof associations

ניתן לציין רק את מידת הריבוי של הקשר•

עדיף לציין גם את קרדינליות הקשר•

ניתן לא לרשום מידת הריבוי והקרדינליות •כאשר סוג הקשר מובן מאליו או המידע אינו

חשוב בשלב מסוים של בנית המודל

Page 7: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Composition

( part of )המחלקה מצד שמאל היא חלק•מהמחלקה בצד ימין,כלומר למחלקה מצד ימין

על המחלקה מצד שמאל" יש  "בעלות

•Composition הוא סוג של Association

גם כאן ניתן לציין בקצות הקשר את מספר • המופעים האפשריים

Composition

Page 8: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

COMPOSITIONדוגמה ל-

מסמך שמורכב מהקדמה, פרקים,סיכום •ואינדקס

יופיע כשלם שמורכב מחלקים שאין להם זכות קיום אם הם לא חלק מאותו מסמך.

אם מסמך מבוטל, אז כל המרכיבים שלו •יבוטלו.

Page 9: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Document

IndexSummarySectionFrontMatter

-End11

-End2*

-End3

1

-End4*

-End7

1

-End8

*

-End5

1

-End6*

Page 10: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Aggregation

Compositionקשר פחות חזק מ-• “-סוג קשר שנועד רק לייצג את היחס  "חלק מ•

Assembly-Component:

Component is part of an assembly

and

Assembly consists of components

Aggregration

Page 11: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Generalization

המחלקה מצד שמאל מכלילה את המחלקה מצד •ימין יורשת מהמחלקה ימין, כלומר המחלקה מצד

מצד שמאל

Generalization

Page 12: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Generalization

• One class is a kind of another class

• Generalization - Specialization

• Superclass - Subclass

• Supertype - Subtype

• Generalization allows inheritance of attributes and operations of a superclass by its subclasses

Page 13: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Generalizationסוגי הגדרת

• Bottom-up generalization

במהלך הגדרת מחלקות מתברר שלמספר מחלקות

יש תכונות והתנהגות משותפות ולכן מגדירים superclass והמחלקות בעלות תכונות משותפות subclassesהופכות ל-

• Top-down generalization

במהלך פיתוח המודל, מתברר שיש יותר ממחלקה אחת subclassesמאותו סוג ולכן יש להגדיר מספר

superclassוהמחלקה המקורית הופכת ל-

Page 14: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Abstract superclasses

למחלקה מופשטת אין מופעים ישרים.•

Employee

AdministratorManager

Page 15: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Generalizationדוגמה ב-

לקוח, בעל חשבון, מבצע טרנזקציה מסוג •הפקדה או משיכה.

Customer Account

Transaction

Debit Credit

End1 End2

End3

End4

Page 16: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Visibility of attributes and operations

• Visibility = availability to other classes• Private – :available only within the class• Public + :available to any class associated with

the class that owns the feature• Protected #: available only within that class and

any subtype of that class• Attributes are normally private• Operations are mostly public• Private operations = internal responsibilities

Page 17: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Constraints for generalization

• {complete} –all subclasses defined within class model

• {incomplete} – not all subclasses specified• {disjoint} – one instance of a subclass cannot be

an instance of another subclass. • {overlapping}- opposite of disjoint generalization.

An instance may be an instance of more than one subclass

Page 18: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Associationסוגי קשרים מורכבים-class

קשר האסוציאציה שמקשר בין מופעים של •עצמים

לקשר זה יכולות להיות תכונות מסוימות ואז •Association classמדובר  

Page 19: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Dependency

• Dependency: one element requires the presence of another element in order to function.

• If the element upon which the dependency is specified is changed, then the dependent element may also need to be changed

,תלות בין שני אלמנטים/שתי מחלקות

בצורה ששינוי של אלמנט אחד עלול לגרור שינוי

.באלמנט השני

Page 20: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

Dependency

Page 21: פיתוח מערכות מידע Class diagrams Aggregation, Composition and Generalization

עוד על קשרים...

• Visibility )prefix to role name on association end( private/public visibility of an attribute of a class as viewed

from different classes associated with that class• Changeability constraints )omission= no changeability

constraint( {frozen}, {addOnly}• Ordering constraints {ordered}, {unordered}, {sorted}• Navigability ) omission = bi-directional navigability( –

shows that it’s not necessary to implement navigability from x to y