I hate active records and I hate functional models

I once worked at a company which had a class that was 10,000 or so lines of code. This class was a ‘model’ in which seemingly every function under the sun was imbedded into the object. Not only did it store referenced get and set variables, was mapped to a database table, had util functions, and database queries as well.

I’m sorry, but a class with 10,000 lines of code from an application being worked on for only a few years is insane. I’m not blaming the developers, I blame the silly notion of the active records, functional model pattern. Where plain old data store objects are abused and extended to nightmareic proportions in the name of ‘it’s easy’ or ‘portable’.

https://github.com/robotlegs/robotlegs-framework/wiki/Best-Practices

Robot legs suggests the same thing. Almost. It seems they are using the word model to refer to a dao. Why are flex developers so afraid of java words like dao and bean? But, back to the point. You should not put functions, event triggers, queries, utils, etc in your getter and setter data store model classes. Don’t do it.

Why isn’t a util class portable? Why isn’t a controller class portable? It seems like if you write those things properly, they will be MORE portable then infesting your domain model with silly functions.

Its one of the reasons I don’t like spring roo. Is it really that hard to inject a dao to save an object? Why do we need model.save()? And why do I need 100s of find methods generated on a model classes that I have to look through every time I want to reference a property? Just because the language doesn’t support type safe queries without making people’s eyes bleed doesn’t mean you should bastardize a light weight working design pattern. Again, cant we generate daos that do the same thing, but have some separation of concerns.

Btw, I know that some people will say it’s not that bad, but i only see two good things about it; small throw away apps and job security. Seriously write one CrudDao and be done with it. Write one Query dao and be done with it. The examples of developers writing a dao for each model and query is a joke. Aspect oriented programming has been around for a few years, use it.

/rantover

Published by using 387 words.