The blog post/article I choose to read and write about is Mastering OOP Fundamentals with SOLID Principles from the ByteByteGo blog page. This blogpost goes into many aspects of the OOP programming, some of which we’ve discusses in class. The first portion delves into Encapsulation, Abstraction, Inheritance, and Polymorphism. It explores some key concepts like single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, method overloading, method overriding, etc. It explains how these 4 fundamentals are important for creating and utilizing OOP effectively, but in and of itself doesn’t necessarily create code that is easy to work with and maintain.
That’s why it introduces the principles of SOLID, which according to the syllabus is something we will eventually touch on in the future. The S is for Single Responsibility Principle, stating that classes should only have a single reason to change. This ensures better organization, easier debugging, and improved testability, so it’s better to split a complex class into multiple simplified classes. The O stands for Open/Closed Principle, stating that classes should be open for extension, but closed for modification. Essentially, if we want to add new behaviors to a class, new subclasses or interfaces should be added without changing what already exists. The L stands for Liskov Substitution Principle, stating that “objects of a derived class must be replaceable by objects of the bass class without altering the program’s correctness.” A subclass shouldn’t break existing functionality while behaving like it’s parent class. This somewhat relates to the interface portion of what we did in class. The I stands for Interface Segregation Principle, stating that clients should not be forced to depend on unused interfaces. Essentially, interfaces should be small and specific, with only relevant methods. Finally, the D of SOLID stands for Dependency Inversion Principle. This states that high-level modules and low-level modules should depend on abstractions, rather than each other. This can help improve flexibility and mobility, so that it’s easier to test and work with without making as many modifications.
The reason I chose this blogpost/article is because it directly relates to what we’ve learned with the fundamentals of OOP so far, as well as introducing me to something that’s planned for the syllabus. I also saw it as a good primer for Java and OOP thinking to help me better understand the general ideas and concepts that hold it up.
Even though a good portion of what was written is just reiterating some of what we’ve discussed in class, I found it really helpful to have things explained another way with the examples the blogpost gave. It helped me better grasp the purposes behind these fundamental principles and ideas in a way that felt easily digestible. The SOLID portion was also interesting, and everything intuitively makes sense. I can definitely see myself referring back to this and sticking to these ideas as I do OOP programming in the future, because it genuinely does seem to make the code easier to work with and easier to understand.
From the blog CS@Worcester – Site Title by Justin Lam and used with permission of the author. All other rights reserved by the author.