Principles for Better Object-Oriented Programming
…that you can brag to your interviewer about
Has your interviewer ever asked you about object-oriented programming? It always starts with what an object is, and what the four pillars of OOP are. But if you really want to impress your interviewer, try bringing up some of these principles:
What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm based on objects, which contain both state and behavior. OOP is popular because:
- Altering state is intuitive in imperative programming
- Abstraction simplifies business logic into inputs and outputs
This is different from functional programming which:
- Focuses on transforming data though declarative programming
- Simplifies concurrency through its stateless/immutable nature
Introducing the SOLID principles
Languages or concepts will either support the four pillars of OOP, or they will not. This is not up to the developer.
However, SOLID is a set of “optional” principles that object-oriented design should strive to adhere to. SOLID only determines how “good” your design is, not if it is object-oriented (thus they are principles).
More principles for good code — coupling and cohesion
On the topic of writing good code, you should also have an understanding of coupling and cohesion.
Conclusion
Understanding these concepts are key to writing good OOP code. Next time your interviewer asks you about OOP, make sure you also talk about good practices.