Function-centric to Data-centric to Model-centric
I picked up book called The Waite Group’s Object-Oriented Programming in Turbo C++ recently to look at what Robert Lafore was saying about OOP 17 years ago. The book was published in 1991. I’ve just read chapter one at this point, but it was rather interesting.
Before we look at Lafore’s views, lets talk about where we are now.
A fairly common complaint we hear in 2008 is that people write their programs in a very data-centric way. They write objects for the sole purpose of CRUD but the life of the application in is the database. They might throw in bit of inheritance to make their objects feel more OO, but end of the day they are making glorified data containers that map directly to the database tables.
I was recently in an interview where one person admitted that it was easiest to start with the database and work out from there. So their “business objects” were just in-memory data containers for performing CRUD with a few useful utility methods hanging off the objects.
If you talk with people working with NHiberate, people doing DDD, an Alt.Netter or Rocky Lhotka (I realize there are very diverse view in these groups), you’ll get the view that your domain objects or your business objects should be the core of your application. I buy into this view by the way; the database is a good place to persist your data, but it shouldn’t be where you start in application design.
So what was Robert Lafore’s concern with procedural programming? Remember that in 1991 OO wasn’t mainstream. Here is a direct quote from a section called Data Undervalued in Chapter 1:
What [functions] do may be more complex or abstract, but the emphasis is still on the action.
What happens to data in this paradigm? Data is, after all, the reason for a programs existence. The important part of an inventory program isn’t a function that displays the data, or a function that checks for correct input; it’s the inventory data itself. Yet data is given a second-class status in the organization of procedural languages.
He goes on to explain that functions/methods/procedures don’t let you model the world very well. How do you model a windowing system with dropdown menus with just methods? And he is right, there needs to be more than verbs in our programming languages, we needed first-class nouns (beyond local variables) to be able to model the world better.
17 years ago coding was too action centric but Robert claims it should have been more data-centric. Now that OO is fairly mainstream coding is too data-centric, and the claim is that we need to be more model-centric.
None of these views stand on there own. If you took away functions we wouldn’t have programming; if we didn’t have data we wouldn’t have a reason to program. But I think that building out a good model that is object based and is independent of the database is just as important for application design.
What do you think about this progression? Where are we going from here?