PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Nov 22, 2014 10:16 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: OOP and Reusability
PostPosted: Sat Jul 14, 2012 7:07 am 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia
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.


Top
 Profile  
 
 Post subject: Re: OOP and Reusability
PostPosted: Mon Jul 16, 2012 6:52 pm 
Offline
DevNet Master
User avatar

Joined: Mon Sep 19, 2005 6:24 am
Posts: 3587
Location: London
It's the ATDD and BDD that removes all the bugs - i.e. not "using TDD alone" :). TDD just helps us get there when filling in the very minute gaps that the specs don't directly fill. To us, TDD is "this card shuffler should randomise the order of this pack" whilst BDD and ATDD take care of the "given I've got a pack of cards in a contiguous order, when I shuffle those cards, then those cards should be in a random order." I hope the meaning behind the difference between those statements is clear.

We also advocate CQRS, and Event Sourcing. It is absolutely imperative that everything is broken down to the smallest possible detail with the person(s) who understands what it is that is required - not a BA or Manager, but the actual expert of the domain. No room for "just simple CRUD" at all here. Ergo, there is no way for there to be erroneous input. Must have complete and concise capture of the intent behind an operation. There is no "allow admin to update a user." There is only commands and events for "changing the name of a user because they have married" or "changing the name of a user because they have divorced." It's as complex as complex can be, but we must understand it all to develop it. Number of tests is exponential to complexity of software because rule number one of BDD, TDD, CQRS is to eradicate complexity. Complexity is compacted simplicity. Is it complex? Then take smaller bites.

A "Bug" is unintentional behaviour through oversight or mistake when developing. It's very, very difficult (I'm only refraining from using "impossible" due to the uncertainty principle here :p) to do either of those if employing BDD (and employing it "properly".)

4, nearly 5 years bug free on a very large system spanning multiple technologies and platforms; interacting with multiple systems including many 3rd party systems, and used globally by 120,000+ users for real time transportation of pharmaceutical supplies, with 2 teams of 8 developers working full time adding new features, both teams limited to 3 stories in "work in progress". It's not simple software.

Anyway... I hope that isn't too "smug".. I really don't intend it to be, so apologies if it is. I replied to give some light onto what benefits resusability in OOP has, and that, like all things in life, it can be "done badly" and then I saw Benjamin's post and just couldn't resist responding to his misunderstanding(s) but I can see I've upset him and possibly others, so I'll return to lurking again.


Top
 Profile  
 
 Post subject: Re: OOP and Reusability
PostPosted: Mon Jul 16, 2012 10:38 pm 
Offline
Site Administrator
User avatar

Joined: Sun May 19, 2002 10:24 pm
Posts: 6874
Jenk I'm not upset, don't worry. Just have a tendency to say what's on my mind ;)

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group