By Peter Bell

The Campaign Against Unnecessary Object Orientation

I have seen posts and comments over the years from a number of developers who feel OO is getting a little too much press. They point out (quite reasonably) that many applications don’t need to be Object Oriented, but some also suggest that Object Zealots (I'm a card carrying member :->) are proposing we OO everything from single page forms on up.

In my personal experience, the biggest proponents of Object Orientation and Design Patterns tend to be strongly opposed to the unnecessary use of patterns or OO principles. I for one still have some smaller apps that are proudly procedural and many that have cfqueries in their views. Some of the projects are old, others just didn’t need the additional complexity.

So, I am calling for everyone who likes and dislikes OO alike to comment below, listing these blog postings where Object Oriented proponents suggest that we brazenly and maliciously overuse Design Patterns and Object Orientation on our simplest forms and screens (other than perhaps as a learning tool which I see as a valid excuse) as then we can present a united front against this diabolical evil and return to the saner problems of how to learn OO and DP (if appropriate/relevant) and where best to utilize them.

Comments
if you know oop inside out, you are in a better situation to critizise it. To get to this point, you have to do everything in your new mindest.
# Posted By john miles | 12/23/06 2:37 AM
Hi John,

I'm about as big a fan of OO as you'll get, but I still have projects where maintainability isn't a top concern and where I need to get a page or a simple site working in say an hour or two. In those cases I take pragmatism over the additional practice, and I just use OO for larger projects that justify it and for "play" projects where I'm trying to learn principles.

There is nothing wrong with using OO for everything as a learning exercise, but I think it is important that people "get" that it isn't the optimal solution to every problem - if only to stop OO detractors using that as an excuse to discredit the benefits of OO where it IS appropriate.
# Posted By Peter Bell | 12/23/06 10:41 AM
Pete,

I am at a kind of interesting place right now. After hearing Clark Valberg talk at the last NY CFUG about Interface Driven Design, I went ahead and prototyped a small task-management application. Clark's idea (and those with the FLiP mindset - FuseBox Lifecycle Process???) preach that full prototyping upfront leads to faster, better development. In theory I agree, so I set out to test it for myself.

So, I have the full design file mockup (Adobe Fireworks). Then, I took that design and made a full *functional* prototype. I say functional, but it is not doing any code. Just flat files that can click through to pages with hard coded values.

I have not yet moved from the prototype to the full ColdFusion version... and that's where it gets tricky. The application is about 9 pages long. And from the prototype, I really can see what is needed. I can show others and get feedback and before any real ColdFusion code is put down, I am going know more or less that the application will be successful as long as it does what the prototype does.

So, for this small, 9 page application, where the upfront design suggests that maintenance will not be a huge issue.... is it worth doing this in OOP? Let's say I did the whole thing in an old-school, proceedural way; I could probably finish off the entire app in less than a day. I'm not talking code generation or anything fancy... i'm just talking nose to the grind stone put my head down and muscle through it.

If I went the OOP route, it would take much longer. Between creating beans and gateways and services and controllers and all the time *NOT* really being sure how it all fits together... it would take days to do (optimistically), and at my skill level, would probably not turn out as nicely as the procedural counterpart.

So what to do? One the one hand, I want to learn OOP and I feel that it can have great benefits for large projects. But on the other hand, I feel that this app might just work *better* if I were not to use OOP.

I think what I might end up doing is doing it procedural at first and then perhaps re-doing in OOP. The app is small enough where this is a very possible idea.

Anyway, that's my two cents worth of frustration on the matter.
# Posted By Ben Nadel | 12/24/06 10:16 AM
Hi Ben,

How complex are the business rules (custom calculated prices based on multiple field values, etc.)? How likely are they to change? Once you've built this are you going to have to keep changing the way it works? If the answer to any f those is yes, that is a sign to consider it MAY be worth OO'ing the project. If the answer to all of them is no, I'd personally hack it out in a day and then use the spare time to play with something else.

Only two reasons to use OO - complex project where maintainability of sophisticated business rules over time will be a concern, and for learning projects where you are doing the extra work (and there is extra work) just to learn OO so you'll be ready when you get a more complex project down the pipe.

Happy Holidays!
# Posted By Peter Bell | 12/24/06 10:26 AM
Pete,

I want to say No to all of those. My small task management app is basically a glorified ToDo list that has:

Clients
Staff
Tasks (joined to staff / clients with extra info)
Teams (join of staff to clients)

That's all there is to it. As you can probably guess, 8 of the 9 pages in the app are the list / edit pages for the above 4 items. So yeah, in the interest of time (i am doing this for work but in my OFF hours, so no pay) I just want to get it done.

Then, if we start to use it at the office, which I hope that we will, perhaps I can sell my boss on expanding the functionality and rebuilding from the ground-up in OOP on the company's dime :)
# Posted By Ben Nadel | 12/24/06 10:31 AM
Makes perfect sense to me. I write a BUNCH of little apps and until I've finished my OO generator, I still use my procedural generator and just hack any additional screens - often wth queries in the fiews and as long as the sites are simple enough it works just fine.

One of the many goals of the OO generator is to make it as easy to generate good OO apps as good procedural ones, but until that is done, OO and most DPs sound like a set of solutions to problems this simple app just doesn't have!
# Posted By Peter Bell | 12/24/06 11:53 AM
I'm one of those people who has accused OO zealots of insisting that every last single page app be fully be-patterned and multi-tiered and what-have-you. But on your request for specific examples, sadly I can think of none.

Here's what I think: the problem is that programmers who don't embrace OO are constantly told they are dinosaurs, they need to get with the OO program or get a new career, they need to skill up quick or get left behind. I think that's where the ideas that zealots think everything should be OO are coming from.

I'm actually in both camps - I do some basic OO-style stuff AND some procedural stuff with Fusebox 4.1 - and while I can see the OO benefits, which is why I use it in particular situations, I also work a bit on systems that totally don't need the complexity. I am actually working on a system where both approaches are used within different areas of the same app, for quite specific reasons.

Here's what I reckon: long live diversity in programming!
# Posted By Kay Smoljak | 12/24/06 9:28 PM
Hi Kay,

Agreed 100%!
# Posted By Peter Bell | 12/25/06 8:26 AM
Where I work we do mostly small business sites and a lot of basic 'query it / output it' type scripting. Many of the jobs, there is NO reusable code, even if you wanted to. That's just how small some sites are.

I have worked on other sites that require a lot of functions / methods to be built to keep the thing maintainable. I keep CFML away from HTML as much as possible without taking a full on OO stance.

I've played around with a lot of OO principles, but they simply do not fit most of our sites.

There is nothing wrong with OO approaches, in fact you can do some really nice things with OO ideas, but it is overkill in a small site, adds unnecessary complexity to what should be simple. A simple script that runs a query or 2 and outputs results will ALWAYS run faster than the overhead of most frameworks also. (not that frameworks are the issue here though.)

So I think there needs to be a balance, and the best techniques for the job need to be applied.
# Posted By Kevin | 12/28/06 6:05 PM
I agree 100% with the small proviso that performance is not usually a good reason to choose an approach. I would choose simple procedural scripts for simple sites based on the fact they are quicker and easier to code - not based on the performance benefits (even though they exist). For the vast majority of apps, the performance differences between OO and procedural are real - but irrelevant.
# Posted By Peter Bell | 12/28/06 6:41 PM
For sure. I mentioned it as fact - not a reason for choosing.
# Posted By Kevin | 12/29/06 1:53 PM
Agreed!
# Posted By Peter Bell | 12/29/06 2:08 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.005.