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.