Object-Oriented Programming

Throughout my coding experience in Tong Hin’s module . I have applied most of the concepts in Object Oriented Programming (OOP) . OOP is a concept of using classes and objects . The classes in OOP are usually referred to as “blue prints” which means the structure of the program , we are able to use these classes to form objects which contains data . The 4 basics concepts of OOP are Encapsulation , Inheritance , Polymorphism and Abstraction .

Encapsulation controls the display and access of methods with public , private and protected modifiers , each with its own unique purpose . These access can also be control by a getter and setter method . A getter method is used to get the changes of a value of a property . A setter method is used to set or update a value of a property . I have used this concept a lot while creating new features with the wrapper pattern implementation .

Inheritance allows us to access methods from other classes with the : symbol . This concept has helped me a lot with achieving less messy and maintainable code with inheriting repository interfaces and database contexts when creating unit tests .

Polymorphism can be broke down into 2 types , static (method overloading) and dynamic (method overriding) . Method overloading allows us to use multiple methods with the same name , under the conditions of declaring different data types , changing the order or number of parameters . Method overriding allows us to use the virtual keyword within a base class method , I have used this a lot to with the creation/disposing of the test databases .

Abstraction is rarely used among the 4 concepts . However the purpose of an abstract class is to hide certain details and showing only essential information .

After getting the hang of these concepts , I could not imagine developing a project without the practice of OOP , while recognizing more and more new ways of problem solving and reducing code complexity .

Leave a Reply