Decided to do a talk about OO; but this time wanted to provide some actual metrics to back it up.
Took measurements per "iteration", e.g. when a new functionality is added in the code base. For each iteration counted methods and types respectively.
Though in the beginning adding types has some overhead, it only takes 3 iterations to achieve 83% reusability. For reusability counted the number of types reused vs the total number.
Would be interesting to do some more metrics and find how many iterations should take (on average) and how many types to find a true golden ratio and what that is. However it might be the case that numbers vary greatly depending on the problem domain.
An IDE plugin to show you how the reusability ratio increases as you add types would be a great tool to assist developers and give a new dynamic on coding.
Even though when starting to write code we have a higher level of understanding of the problem (iterations are not that short), usually as developers we take the procedural route and think in terms of methods. It demonstrates how complex the object oriented programming paradigm is, even though it has been around for decades.
Resist the urge to jump straight to code. Lay down your thoughts first using pen and paper and start thinking in terms of objects, there are benefits both in the short and long term.
Note On the 3rd iteration there are actually 5 methods. (not 4 as depicted on the slide)
Urban Legends - O is for Object (Part 1)
The Myth - O is for Object (Part 2)
Revelations - O is for Object (Part 3)
On Reusability (Part 1) - Misconceptions
On Reusability (Part 2) - Misconceptions
Don't Lose Your Train of Thoughts series
//1st iteration private List<String> load() public String findByValue(String value) //2nd iteration public String findByReverse(String reverse) //3rd iteration private List<Integer> load() public Integer findByValue(Integer value)
//1st iteration public final class Service<T> public interface Predicate<T> public final class Implementation //2nd iteration public final class Evals public interface Eval<T> //3rd iteration public final class PredicateBuilder<T>