6.Structural Modelling using Class, Package Diagrams Flashcards
What is the purpose of a Class diagram in UML?
A class diagram represents a set of classes, interfaces, their collaborations, and relationships in a system or software application.
What is a Class in object-oriented programming, and how does it relate to the creation of objects, their shared attributes, and the concept of instantiation?
- A class is a blue print (template) for creating objects.
- All the objects created using the same class share simillar attributes and methods.
- Instantiation is a concept that refers to* the process of creating an instance or an object of a class.
How should the class name be represented in UML?
Class names should be a single word, written without spaces and class name** should start with an uppercase letter**.
If the class name consists of multiple words, we combine the words together and make the** first letter of each word capitalized.**
Single Word: Car
Multiple Words: StudentRecord, BankAccount.
What are attributes in a class, and what are the recommended conventions for writing attribute names?
Attributes are characteristics or properties of interest about an object.
If an attribute name consists of multiple words, you combine the words by removing spaces, and the first letter of each added word after the first one is uppercase.
Note: There can be classes with no attributes.
Elaborate on the concept of methods/operations/services within a class?
Methods are services that objects of a class can perform.
Method Names Start with a Lowercase Letter.
If a method name consists of multiple words, you combine the words by removing spaces, and the first letter of each added word after the first one is uppercase.
They are sufixed with parenthesis.
e.g. addClothes()
What is the primary purpose of utilizing access modifiers in programming?
The primary purpose of utilizing access modifiers is to* control the accessibility of attributes and methods from other parts of the program.
Access modifiers help to enforce encapsulation.
Name access modifiers and describe the symbols used to represent each modifier?
- + Public :are accessible from any part of the program.
- - Private :are only accessible within the class where they are defined.
-
#Protected : are accessible within the class and its subclasses (derived classes or child classes).
They are not accessible from unrelated classes.
In order to get things done a class must interact with another class or with the same class.
What are the different types of relationships between classes?
1.Association
2.Aggregation
3.Composition
What is an Association Relationship and how is it represented in a UML diagram?
An association relationship indicates a natural business association between classes where a class can send massages to other classes that are connected to it.
- Associations are represented using a solid line connecting classes in the relationship.
- Associations can be unidirectional(one way) or bidirectional(Two way with no arrow heads.
What is an association name?
- Usually the name of the association is an active verb or verb phrase that communicates the meaning of the relationship.
Association name is optional.
eg. a Lecturer teaches a Course.
Note: Aggregation relationships typically are not named. They are read using the words “has”, “part of” or “contains”.
What is a Role name in an association?
- The end of an association where it connects to a class is called an association role.
- Role name can be used instead of association names.
- It is a noun that describes the reason the relationship exists.
- The role name is placed on the association near the class it modifies.
What are the Multiplicity Indicators?
1 - Exactly one
0..* - Zero or more
1..* - One or more
0..1 - Zero or one
5..8 - Specific Range (5,6,7 or 8)
What are Reflexive Relationships/Associations?
When a class is in association with itself we call it a reflexive association.
(This is denoted by drawing a solid line connecting a class with itself. )
Explain Aggregation and how is it represented in a Class diagram?
An aggregation is a stronger form of association where one class (whole class) is created using part classes.
Note: In aggregation if whole is to die, parts will not die with it.
Aggregation is represented using a hollowed diamond, drawn closer to the whole class.
What is Composition and how is it represented in a Class diagram?
An Composition is a stronger form of aggregation where the whole class is composed with part classes.
Note: In composition if whole is to die, parts will die with it.
Aggregation is represented using a filled diamond, drawn closer to the whole class.