Approaching Object oriented design
- hieu nguyen xuan
- Mar 7, 2021
- 2 min read
Updated: Apr 10, 2021
Handle ambiguity.
Ask clarifying questions rather then making assumptions. It is waste of company's time and money if a developer just code a feature out without a good understanding what he/she expected to create.
Define the core object.
Now that we understand the requirement clearly. We need identify objects that will interact with other in our systems. For example, if we are designing a library, we should have actionable objects, such as: Kiosk, Book, Librarian, Student (Borrower), Section, Employee, Member, Genre.
Analyze relationships.
Having more or less decided on our core objects, we now want to analyze the relationships between objects. Which objects are members of which other objects ? Do any objects inherit from each other ?
For example, in the restaurant question, we may come up with the following design:
- Student inherits from Member.
- Librarian inherits from Employee.
- Book belongs to many Genre.
Investigate all actions between objects.
Consider what key actions that the object will take and how they relate to each other. For example, A student can borrow at most 3 books. A librarian can be assigned to different time periods in a library section in a week. A librarian can be assigned to different A kiosk should be able to get the right book code from the library from the barcode.
My Journey in OOP
There has been a lot of progess in my journey in OOP. My take on arranging my code is that it is good to take some minutes and plan ahead but I am not afraid to make mistakes and fix the it along the way. I think making mistakes and fixing it is the only to improve my code. OOP has helped me a lot in understanding about professional software development. Hopefully, I will try to get more experience in OOP before dipping my toe to other paradasm like functional programming.
댓글