OOP and Object Permanence
Many of the benefits with OOP can be applied to other design styles, e.g., design patterns (conceptual, not GOF) and reusability, but for me the differences have been primarily in object permanence and code quality.
I recently read a critic of OOP, and the point that I would agree from his article is that OOP provides a clearer set of rules, with the end result better code and the ability to program complex concepts more easily.
Just some quick ideas:
- Procedural code can be quite messy with a tendency to sprawl, something that encapsulation and properties reduce.
- Writing with OOP, one better defines responsibilities, reducing coupling and the problems that ensue from intertwined code.
- State and messaging are improved as procedures generally only return a single item or object, and generally have no state.
- Procedural programming does not lack for reuse, and one of my concerns when I began writing classes instead of procedures was whether I would be losing some flexibility and some reuse
- Although the GOF are known for design patterns, generally, I think procedural languages could easily have their own set of patterns, albeit not class-oriented.