Escolar Documentos
Profissional Documentos
Cultura Documentos
• Scope :- • Visibility :-
-> The Scope indicates if a feature applies to an -> Visibility refers to the ability of method to
object or a class. reference a feature from another class and has the
possible values of public, private, protected and
-> An Underline distinguishes features with class
package.
scope (static) from those with object scope.
• Any method can freely access Public features.
-> Our
O convention
i is
i to list
li attributes
ib andd
operations with class scope at the top of the • Only methods of containing class can access
attribute and operation boxes, respectively. private features.
-> Ex.. Fig , A Phone Mail System will define some • Only methods of the containing class and its
different rules/constraints based on, which descendants via inheritance can access protected
merchants product we are using. Ex.. Reliance, features.
Indicom and so on. So these attributes must be
• Methods of classes defined in the same package
defined in their respective object scope, which
as a target class can access package features.
varies depending on the model we are using.
1
12/8/2010
-> The UML denotes visibility with a prefix. -> Comprehension : We must understand all public
1) The character “+” precedes public features. features to understand the capabilities of a class.
Ignoring rest.
2) The character “#” precedes protected features.
-> Extensibility : Many classes can depend on public
3) The character “-” precedes private features. methods, so it can be highly disruptive to change
4) The character “~” precedes package features. their signature.
5) The lack of prefix reveals no info. About visibility. -> Context : Applied out of context, a private
method may calculate incorrect results or cause the
-> There are several issues to consider when object to fail.
choosing visibility.
-- Comprehension
-- Extensibility
-- Context
2
12/8/2010
-> If the association has a name, it is written italics -> Fig shows another ternary association. A
next to the diamond. Professor teaches a listed course during a semester.
The resulting delivered course has a room number
-> End names are necessary if a class participates
and any number of textbooks.
in an association more than once.
-> The Typical programming language cannot
-> We can’t traverse n-ary associations from one
express n-ary associations. Thus if you are
end to another as with binary association.
association
programming, you will need to promote n-ary
-> The OCL does not define notation for traversing associations to classes as Ex fig.
n-ary associations.
-> Be aware that you change the meaning of
model, when you promote an n-ary association to a
class.
-> Aggregation is drawn like association, except a -> The notation for composition is a small solid
small diamond indicates the assembly end. diamond next to the assembly class (vs. a small
• Aggregation vs. Composition hallow diamond for the general form of
aggregation).
-> The UML has two forms of part-whole
relationship; a general form called aggregation and -> Ex.. Fig, a Company of divisions, which in turn
a more restrictive form called composition. consist of departments; a company is indirectly a
composition of departments.
-> Composition is a form of aggregation with two
additional constraints.
i) A constituent part belong to at most one
assembly.
ii) Once a constituent part has been assigned an
assembly, it has a coincident lifetime with the
assembly.
3
12/8/2010
-> In the UML notation an abstract class name is -> In the UML notation an abstract operation is
listed in an italic font. Or we may place the keyword listed in an italic font. Or we may place the keyword
{abstract} below or after the name. {abstract}.
-> Ex for an abstract class, ComputePay is an -> It is a good idea to avoid concrete superclasses.
abstract operation of class Employee; its signature. Fig shows, We can always eliminate concrete
but not
ot its
ts implementation
p e e tat o is s defined.
de ed Each
ac subclass
subc ass superclasses
supe c asses by introducing
t oduc g an
a Ot
Other
e subc
subclass.
ass
must supply a method for this operation.
-> An abstract class can define the signature for an
operation without supplying a corresponding
method. It is called as abstract operation.
-> An abstract operation defines the signature of an
operation for which each concrete subclass must
provide its own implementation.
4
12/8/2010
• Multiple classification
-> Fig Ex2, Multiple inheritance can also occur in
overlapping classes. -> For Ex.., an instructor could be both faculty and
student. But what about a Harvard Professor taking
-> The UML uses a constraint to indicate an
classes at MIT [Massachusetts Institute of
overlapping generalization set;
Technology]. There is no class to describe the
the notation is a dotted line cutting
g across the combination. This is an example of multiple
affected generalizations with keywords in braces. classification.
In the ex.., overlapping means that an individual -> The UML permits multiple classification, but most
vehicle may belong to more than one of the OO language handle it poorly.
subclasses.
-> The best approach using conventional languages
Incomplete means that all possible subclasses of is to treat Person as an object composed of multiple
vehicle have not been explicitly named. UniversityMember objects. This workaround
replaces inheritance with delegation [group
representing others].
-> This is not totally satisfactory, because there is a i) Delegation using composition of parts:
loss of identity between the separate roles.
-> We can recast a superclass with multiple
• Workarounds independent generalizations as a composition in
-> Dealing with lack of multiple inheritance is really which each constituent part replaces a
an implementation issue, but early restructuring of generalization.
a model is often the easiest way to work around its -> Ex.. fig.., An operation sent to an Employee
absence. object would have to be redirected to the
EmployeeEmployment or EmployeeManagement
-> Two of the approaches make use of delegation, part by the Employee class.
which is an implementation mechanism by which an -> This approach replaces a single object having a
object forwards an operation to another object for unique ID by a group of related objects that
execution. compose an extended object.
1. Delegation using composition of parts -> In this approach, All combinations of subclasses
2. Inherit the most important class and delegate the from the different generalizations are possible.
rest.
i) Inherit the most important class and delegate -> Any of these workarounds can be made to work,
the rest: but all compromise logical structure and
-> fig 4.19, preserves identity and inheritance maintainability. There are several issues to consider
across the most important generalization. when selecting the best workaround:
5
12/8/2010
5.Large quantities of code: Try to avoid nested -> Many real-world applications have metadata,
generalization if you must duplicate large quantities such as catalog, dictionaries.
of code. -> Fig shows, an ex.. For metadata and data.
6.identity: Consider the importance of maintaining A car model has a model name, year, basePrice, and
strict identity. Only nested generalization preserves manufacturer. Some ex.. For car model are 1969
this. Ford Mustang.
A physical car has a serial number, color, options,
and an owner. Ex.. John Doe may own a blue ford
with serial number 1FABP.
6
12/8/2010
• Constraint on Links -> The UML has two alternative notations for
constraints. We can either delimit a constraint with
braces or place it in a “dog-eared” comment box,
-> Multiplicity for association and Multiplicity for which can be connected to the constrained elements
attributes using dashed lines.
->
> Qualification also constraints an association.
association -> Ex.. Fig..
g
7
12/8/2010