[Class Report] Introduction to System Development Week 20 – OOP Mini Project: From UML Design to Implementation
In Week 20, we kicked off the small-scale OOP project announced last week. First, we drew the “class blueprint (UML)” to clarify roles and relationships, then began actual code implementation.
■ Teacher’s Introduction: “With a blueprint, you can build even large systems”
Mr. Tanaka: “UML is a design expression that communicates more with diagrams than words. Before writing code, let’s organize the connections between classes, their attributes, and methods.”
On the blackboard was a sample UML for the “Library Lending System,” the project theme.
■ Exercise ①: Draw a UML Class Diagram
First, with paper and pen, we worked on class diagram creation tailored to our theme.
- Book class: attributes
title
,author
,is_available
, methodslend()
,return_book()
- Member class: attributes
name
,member_id
, methodsborrow(book)
,give_back(book)
- Library class: attribute
books
list, methodsfind_book(title)
,register_book(book)
Student A: “Seeing relationships in a diagram makes implementation so much clearer.”
Student B: “With UML, later design changes are easy to understand!”
■ Exercise ②: Implement Classes in Separate Files
Based on the UML, we split into three files and began defining the classes.
book.py
class Book:
def __init__(self, title, author):
self.title = title
self.author = author
self.is_available = True
def lend(self):
if self.is_available:
self.is_available = False
return True
return False
def return_book(self):
self.is_available = True
member.py
from book import Book
class Member:
def __init__(self, name, member_id):
self.name = name
self.member_id = member_id
self.borrowed = []
def borrow(self, book: Book):
if book.lend():
self.borrowed.append(book)
return True
return False
def give_back(self, book: Book):
if book in self.borrowed:
book.return_book()
self.borrowed.remove(book)
return True
return False
library.py
from book import Book
class Library:
def __init__(self):
self.books = []
def register_book(self, book: Book):
self.books.append(book)
def find_book(self, title: str):
return [b for b in self.books if b.title == title and b.is_available]
Student C: “Splitting files makes everything so clear!”
Student D: “Adding type hints would make it even more user-friendly.”
■ Focus Time: Write and Run Test Code
In the latter half, we wrote simple test code to verify functionality.
from book import Book
from member import Member
from library import Library
lib = Library()
b1 = Book("Harry Potter", "J.K. Rowling")
lib.register_book(b1)
m = Member("Tanaka", "M001")
assert m.borrow(b1) == True
assert b1.is_available == False
assert m.give_back(b1) == True
assert b1.is_available == True
print("Tests OK!")
Student E: “Using assert
for automatic checks is so convenient!”
Student F: “When tests pass, I feel confident moving on.”
■ Teacher’s Final Word
“Test code is ‘proof that it works.’ There’s a special joy when the system behaves exactly as designed. From now on, let’s also incorporate test-driven development.”
■ Next Week’s Preview: Extending with Inheritance & Building a UI Interface
Next time, we’ll work on class extensions via inheritance (e.g., ReferenceBook
/Magazine
classes) and implement a simple console-menu UI. We’ll learn how to design user-friendly interfaces!
Having experienced the full workflow from design blueprint to code and tests in Week 20, our first-year students’ OOP skills have grown even stronger!