How can I write my program better to be more Object Oriented?

1 Answer(s)


First I pose the question, "What does Object Oriented Programming mean?". In practice everyone has a different definition in mind, making it a virtually worthless in a discussion. Does it mean programming with objects? A class system with nominal sub-typing? structural sub-typing? polymorphism? prototypical inheritance? open-recursion? bounded polymorphism? interfaces? methods? There are a variety of languages that bill themselves as OO, but are wildly different. In contrast if you remove all the buzzword-y meaning attached to it, and ask a true practitioner of FP. It is about using pure functions (in the mathematical sense, aka mapping from inputs to outputs) as the fundamental unit of abstraction. Functional Programmers value pure functions because they are much easier to reason about and compose, allowing us achieve the promises of the modularity, and code reuse that OOP had promised. Often times objects become little more than a wrapper for semi-global-state and program invariants typically require objects to be in specific states for system to function correctly, and things usually will blow up in an exception or crash. Functional Programmers attempt to write total functions as much as possible for these reason and avoid things like null or random throwing of exceptions.

Like   0
Your Answer

* This site is facing technical problems right now, you may try later.