Revision Flashcards
What is a class diagram?
A static diagram that describes the structure of a system by showing its classes, attributes, operations, and relationships.
What is the purpose of a state diagram?
To describe the behavior of a system by showing its states and the transitions between those states.
What does a sequence diagram depict?
It shows how objects interact in a particular scenario of a use case, highlighting the sequence of messages exchanged.
Define invariant in OCL.
An invariant is a condition that must always hold true for a system at all times.
Write an OCL constraint restricting the course name to between 10 and 25 characters.
context Course
inv: courseName.size() >= 10 and courseName.size() <= 25
What does the context keyword specify in OCL?
It specifies the class to which the constraint applies.
What does the inv keyword declare in OCL?
It declares an invariant constraint.
How do you ensure that the length of courseName is at least 10 characters and at most 25 characters in OCL?
courseName.size() >= 10 and courseName.size() <= 25
Write an OCL constraint ensuring that if fees are paid, the student must be registered for at least one course.
context Student
inv (feesPaid == True) implies (self.registeredFor->notEmpty())
What does the OCL operation ->size() do?
It returns the number of elements in a collection.
What does the OCL operation ->isEmpty() check?
It checks if a collection is empty.
What does the OCL operation ->notEmpty() check?
It checks if a collection is not empty.
What does the OCL operation ->includes(element) check?
It checks if a collection includes a specific element.
What does the OCL operation ->forAll(x | condition) do?
It checks if a condition holds true for all elements in a collection.
What does the OCL operation ->exists(x | condition) do?
It checks if there exists at least one element in a collection that satisfies a condition.
What does the ‘=’ operator represent in OCL?
Equality operator
What does the ‘<>’ operator represent in OCL?
Inequality operator
What does the ‘and’ operator represent in OCL?
Logical AND operator
What does the ‘or’ operator represent in OCL?
Logical OR operator
Write an OCL if/else statement ensuring course name size is based on course level.
context Course
inv: if courseLevel = CourseLevel::bachelor then courseName.size() >= 10 else courseLevel = CourseLevel::master and courseName.size() >= 15 endif
Write an OCL constraint ensuring student categories and course levels match.
context Student
inv: self.registeredFor-> forAll(course | (studentCategory = StudentCateg::bachelor implies courseLevel = Courselevel::bachelor) and (studentCategory = StudentCateg::master implies courseLevel = Courselevel::master))
What is a box-and-line diagram?
A diagram that shows the high-level structure of a system, including its components and the relationships between them.
What is a pipe and filter diagram?
A diagram that represents a system as a series of processing steps (filters) connected by pipes, which transport data between the steps.
What is the intent of the strategy pattern?
To define a family of algorithms, encapsulate each one, and make them interchangeable, allowing the algorithm to vary independently of clients that use it.