Practice Flashcards
Flip to reveal answersHow do you find the classes and methods in a description?
Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.
All 5 Flashcards — Designing classes
Sign up free to track progress and get spaced-repetition review schedules.
Question
How do you find the classes and methods in a description?
Answer
Underline the nouns as candidates for classes and attributes, and the verbs as candidates for methods. It is crude but gets a first draft right surprisingly often.
Question
What are the three parts of a UML class box?
Answer
The name at the top, the attributes in the middle with their types, and the methods at the bottom with their return types — always in that order.
Question
What do -, + and underlining mean in UML?
Answer
A minus sign means private, reachable only inside the class. A plus sign means public. An underlined entry is static, belonging to the class itself rather than to each object.
Question
Where should a method be placed?
Answer
In the class that holds the data it uses. borrow() belongs on Book because Book holds onLoan; putting it elsewhere would force that attribute to be made public, losing encapsulation.
Question
When is inheritance the wrong choice?
Answer
When the relationship is really 'has a' rather than 'is a'. A Library has Books but is not a Book, so it should hold a collection rather than inherit.
Read the notes
Full study notes for Designing classes
Topic 7.1 hub
OOP: a single class
More from Topic 7.1
All flashcards in this topic
Computer Science exam skills
Paper structures & tips
Track your progress with spaced repetition
Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.
Start Free