Object oriented design is cheaper, it’s scientifically proven

There’s a new attack on object oriented software design principles: phpthewrongway.com

Maybe it’s just simple trolling, and I shouldn’t feed them, but I always wanted to collect some hard datas that can support object oriented principles, so this insult was just the perfect time for some research.

My only thesis now is that it’s scientifically proven that using object oriented software design is cheaper. Here are the numbers.

Reusing already written software is cheaper: no need to write it, test it, debug it etc.

In a study object oriented projects were able to reuse more then 70 percent of their code while functional could only 35. Yes, it’s two times more.

Steve McConnell: Code Complete (190/952)

Information hiding (encapsulation) is an object oriented design principle that is unavoidable with OO. If it’s easier to modify, and easier means less time, so it is cheaper also. It’s actually 4 time cheaper.

Large programs that use information hiding were found years ago to be easier to modify — by a factor of 4 [my bold] — than programs that don’t.

Steve McConnell: CodeComplete(133/952)

This “abstract-data-type” routines mentioned in the next paragraph is also known as the definition of the class: the data and the methods that uses them. So this paragraph states that a class based program is 30% more understandable then a functional. It’s faster to maintain, refactor or optimize. Which again means less time and less money. It’s cheaper.

[…] conducted a study in which graduate and senior undergraduate computer-science students was divided into eight abstract-data-type routines (1981). Students using the abstract-data-type program scored over 30 percent higher than students using the functional version.

Steve McConnell: Code Complete (165/952)

Another object oriented principle is the so called cohesion: do one thing and do it well. Higher cohesion means less bug, and less bug means less debugging time — and yes, less money.

The payoff is higher reliability. One study of 450 routines found that 50 percent of the highly cohesive routines were fault free, whereas only 18 percent of routines with low cohesion were fault free (Card, Church, and Agresti 1986).

Steve McConnell: Code Complete (205/952)

A non object oriented method, the procedural —in its best form, when it has high cohesion — means a lot of functions calling each other using parameters. But most errors stems from communication between functions:

Interfaces between routines are some of the most error-prone areas of a program. One often-cited study by Basili and Perricone (1984) found that 39 percent of all errors were internal interface errors — errors in communication between routines.

Steve McConnell: Code Complete (211/952)

Remember: ideally a class method has zero parameter, because object = data + methods (see abstract-data-type above), so there’s no need to pass them around. Object oriented programming helps eliminating 39% of all errors — by solely its design.

And why software quality is this important?

it’s cheaper to build high-quality software then it is to build and fix low-quality software.

Steve McConnel: Code Complete (558/952)

There are a lot of evidence that proves that object oriented software design is cheaper. If the price and the time is not important, there is no scientific reason behind choosing object oriented design. Just as Steve McConnell wrote at least ten times: design is heuristic.

Design is heuristic. Dogmatic adherence to any single methodology hurts creativity and hurts your program.

Steve McConnell: Code Complete (160/952)

PS. Mind the dates. These are more then 20–30 years old facts.