four people using laptop computers and smartphone
Photo by Canva Studio on Pexels.com

[Class Report] Introduction to System Development Week 18 – Object-Oriented Programming: Classes and Instances

This week’s lecture introduced the new second-semester first-year topic: Object-Oriented Programming (OOP). We learned to treat programs as “objects” to write more modular, maintainable code for large systems.


■ Instructor’s Introduction: “Think of Programming as ‘Making Things’”

Professor Tanaka:

“Procedural programming with functions and lists is convenient, but for large systems, defining and handling ‘things’ via object-oriented design is more effective.”

On the board was an example modeling a real-world “Dog” as a class.


■ Exercise ①: Defining a Class

First we experienced defining a class in Python:

class Dog:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    
    def bark(self):
        print(self.name + " says: Woof!")

Professor Tanaka:

“In __init__, we initialize ‘name’ and ‘age.’ The bark method adds the dog’s bark behavior.”

Student A: “So self refers to the object itself!”
Student B: “With a class, we bundle data and behavior together.”


■ Exercise ②: Creating and Using Instances

Next, we generated and ran actual objects (instances):

dog1 = Dog("Pochi", 3)
dog2 = Dog("Hachi", 5)

dog1.bark()  # → Pochi says: Woof!
dog2.bark()  # → Hachi says: Woof!

Student C: “We made two ‘dogs’ with different names and ages!”
Professor Tanaka:

“One of OOP’s advantages is you can create as many objects as you like from the same ‘type.’”


■ Independent Practice Time: Design and Implement Your Own Class

In the second half, we tackled a mini-assignment to turn an everyday item into a class.

💡 Sample Assignments

  • Book class: attributes title, author, pages; method read()
  • Car class: attributes model, color, mileage; method drive(km)
  • Student class: attributes name, grade, score; method is_passed()

Student D: “If I make a Book class, I could build my own personal library manager!”
Student E: “It’s fun that calling drive(10) just adds 10 to the mileage!”


■ Instructor’s Closing Remark

“OOP shines in design and team development. Get comfortable packaging data and behavior together in one ‘box.’”


■ Next Week’s Preview: Inheritance and Polymorphism!

Next week we’ll learn inheritance (reusing and extending existing classes) and polymorphism (using the same method name to vary behavior). You’ll experience more flexible design!


This marks the first step into OOP—the foundation of large-scale development. Our first-year students have gained a new “making-things” perspective.

By greeden

Leave a Reply

Your email address will not be published. Required fields are marked *

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)