Aug 14 2007

Model Glue Tips Part 6: Create a services directory to keep your model tidy

Posted by Mark Drew at 7:44 AM
5 comments
- Categories: model-glue

By default, when you create a Model-Glue project you get the following directories in you root project:
	/config
	/controller
	/css
	/images
	/model
	/views
This fits (apart from the css and images folders) with the idea of an MVC model. The problem that I find is that Reactor (by default) creates objects in the model/data directory. Why is this a problem you might ask? Well, I find that it doesn't fit in with what I think of the model. I see the model as the business model, and I tend to add another directory; "services" which interact with the model. The services are stored there and they glue the model together the model being stuff created by your ORM. I know people might disagree (no names) but I tend to add a services directory in which I have number of cfc's usually named %3CSomething%3EService.cfc . In my model folder I then have the objects and gateways. This means that the controller talks to the service and the service talks to the gateways and objects. This keeps it nice and tidy in my view. Of course, it doesn't matter at the end of the day, since you can change where all the objects are stored and just change your ColdSpring.xml file (you ARE using your ColdSpring.xml file your services aren't you?!)

Comments

Matt

Matt wrote on 09/22/08 4:13 PM

I think it might help some people if you posted an example of a service you have written.
Mark Drew

Mark Drew wrote on 09/22/08 4:13 PM

I have written many services in my time, but for example a PersonService might be something along the lines of:
Person
getPerson
getPeople
getActivePeople

etc etc,
Henry

Henry wrote on 09/22/08 4:13 PM

I found that by putting DAO + Gateway + Bean + Service together has one advantage. They can refer to the bean without fully qualified name. Since Service will have a lot of method that takes a Bean in as a type, without fully qualified name, the service can be moved into another project without changing the fully qualified name in type.

what do you think?
Henry

Henry wrote on 09/22/08 4:13 PM

oh, and have most methods having access = package.
Mark Drew

Mark Drew wrote on 09/22/08 4:13 PM

@Henry: That is true, but one thing that I tend to do is set everything in ColdSpring, so the DAO + Gateway + Bean are refered to from Coldspring. But I think you have a valid point, and It just depends.

My services tend to bring a lot of things together (People, Security etc) so its easier to have it access stuff from coldspring.

Write your comment



(it will not be displayed)





Search Archives

Contribute


MD on Twitter

Categories

coldfusion cfeclipse personal apple cfconferences ukcfug model-glue webdev blogging cfunited railo coldspring cfobjective presentations adobe scotch on the rocks reactor lost jobs ajax eclipse flex model-glue frameworks max google podcast podcasting reference ask md fusebox getrailo cfml spam donations eventvalidation fusiondebug air blue dragon cloud development flying funny java microsoft music snipex tattoo tips apple aptana blog cfml derby eventguard graphic novels hosting itunes metrics open bluedragon rant wishlist apollo barcamp bolt cebit cfdevcon cfonwheels cfug codeshare codeswarm coldfusioncamp directing doh! firefox flash gadgets groovy jquery mdc mvc ooops pownce quack regex spry subversion tashr transfer webservices xml

Monthly Archives