Re: OOP and Reusability
Posted: Sat Jul 14, 2012 7:07 am
This thread has gone way off-topic now, but I just wanted to chime in with my thoughts regarding TDD/BDD. As somebody who actively uses TDD on all code on a daily basis, I find it ludicrous that another TDD'er could suggest that using TDD alone eradicates *all* bugs. That is just frankly absurd. Even with 100% test coverage (and mutation testing), you will still run into edge cases where combinations of inputs fall outside of some expected range, unless you're writing extremely simple applications, or have an infinite number of test cases to cover all possible inputs. Yes, you can prove that the bug exists once it has been found, then ensure it doesn't come back by using a test, but you can't, with 100% certainty know that it will never exist, if you haven't specifically tested the edge-case inputs. We have few bugs, but we do run into them, always at the extreme edge cases. We find out about them through our exception-tracking service (Errbit) and add test coverage as needed.
With regards to the discussion of OOP vs. Functional Programming, I have no idea how WordPress came into the discussion. WordPress is not functional. It may favour global functions over classes, but it is more generally imperative in design.
I don't think OO and Functional programming concepts differ vastly in terms of code re-use, though I can see how that thinking may come about when functions are not coupled with an associated state container, making them more generally applicable in different problem domains. Good object-oriented languages allow very fine-grained code re-use through object-models that support mixins/traits. Take a look at Ruby's Enumerable module. Just about everything you can iterate, map, reduce, zip, partition etc etc in Ruby has done nothing more than define an "each" method, then mixed in the Enumerable module to get the rest of the behaviour for free.
With regards to the discussion of OOP vs. Functional Programming, I have no idea how WordPress came into the discussion. WordPress is not functional. It may favour global functions over classes, but it is more generally imperative in design.
I don't think OO and Functional programming concepts differ vastly in terms of code re-use, though I can see how that thinking may come about when functions are not coupled with an associated state container, making them more generally applicable in different problem domains. Good object-oriented languages allow very fine-grained code re-use through object-models that support mixins/traits. Take a look at Ruby's Enumerable module. Just about everything you can iterate, map, reduce, zip, partition etc etc in Ruby has done nothing more than define an "each" method, then mixed in the Enumerable module to get the rest of the behaviour for free.