Monday, September 15, 2008

Fat bean vs Fat service?

I recently started a thread on CFCDev, a google group for CFer's like you and me.

Fat bean vs Fat service?
http://groups.google.com/group/cfcdev/browse_thread/thread/fd27e0332043278a

'Bean' was introduced to me when I was learning Model-Glue.

While I did blindly use bean as instructed by MG and other tutorials on MG, I found that:

1.) Some thinks bean is nothing more than using CFC as a struct to hold fields of forms.
2.) Some thinks bean is nothing more than representing a table in SQL (data-centric extreme)
3.) Some thinks bean is an object that handles everything internally and (talks to database)
4.) Some thinks bean is an object that handles everything othan than talking to database (with external XXXDao.cfc)

I have used a code generator to generate all the getters and setters. With code folding support by CFEclipse, I don't mind them too much. Using MG together with ColdSpring, it seems the preferred way is to code most logic in the Service layer because they will be kept alive throughout the lifetime of the application through use of Singleton. However, doesn't that lean towards... procedural programming?

I like the idea of having a "fat bean", and with that I can rely much less on getters and setters. However, as the object grow larger with number of methods, wouldn't initializing the object be too expensive on CF8?

What's your take? Please continue the discussion at the thread, or leave a comment here whatever is easier for you.

1 comments:

ike said...

Your comment about the fat service layer resembling procedural programming is probably somewhat similar to the comments others have made (in the Java community in particular) about "anemic domain models". Fowler, who wrote a more recent and very popular book on design patterns (i.e. the next generation of GoF), considers the fat service an "anti-pattern". More info on Wikipedia http://en.wikipedia.org/wiki/Anemic_Domain_Model

Clicky Web Analytics