Back to Topic 7.1 — OOP: a single class
7.1.2Computer Science SL5 flashcards

Designing classes

Practice Flashcards

Flip to reveal answers
Card 1 of 57.1.2
7.1.2
Question

How do you find the classes and methods in a description?

Click to reveal answer

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.

Card 1process

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.

Card 2definition

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.

Card 3definition

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.

Card 4concept

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.

Card 5concept

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.

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