DEV Community

quoc187
quoc187

Posted on

I don't remember the principles of OOP :D

The interviewer asked me to describe the principles of Object-oriented Programming. I don't remember the answer? but should I remember all that? My opinion is I don't need to.

Is there any connection between remember what the definitions are and the right way to use them? I think they are far apart. You dont need to list every principle on the paper in order to implement OOP the good way.

We all know a Class can be inherited
We all know in some cases we don't want to expose everything to the outside, that's why we use private and protected for some of our methods and properties
We all know a method can be override
We all know a method could have multiple signatures
We all know when we have different entities but have the common behavior, we could use interface or AbstractClass...

What is Encapsulation, Inheritance, Polymorphism, Abstraction. Man give me 5 minutes for searching :D. I don't remember what they are, but if you ask me what is the problem in some lines of OOP codes, I might still get the right answer.

Could us in some points violate the principles? We could, but the thing is, we do the best way, not do as any principle tells us to do, the code might not be OOP, or might not be FP, but if it works and it works well, go for it.

What I want to emphasize is the way of learning programming, you don't need to remember all the definitions or all the terms, expecially if it doesnt have anything to do with a realworld problem, learn how to use them, and how to use them the efficient way.

Same thing happen to SOLID principles, you don't remember what S,O,L,I,D stands for but if you know how to follow those principles, that's more than enough.

When learning a programming concept, instead of what they are, learn how to utilize them and why we follow them.

Some might agree with me, some might say this post is just me excuses for not remembering one of the most famous set of principles in programming world.

Top comments (0)