Wow. Some days I feel like I am just barely treading water on this Object-Oriented Stuff. Today is one of those days. I go to do a simple search on some concept in OO and I end up spending an hour and a half reading posts from all of these frakking geniuses
that make me feel dumber than a bag of hair.
I want to ask questions, but three things stand in my way.
- I don't want to bombard one or two people with all of my questions
- If I email one or two people, I don't want them to feel obligated to answer me
- It's hard to ask a question when I don't know all the terminology and I need to provide a huge example of what I am doing
So, to solve these problems, I am going to ask my questions here. This way anyone that wants can answer my questions in any of the following ways:
- Answer a question in the comments
- Write a blog post about it and link it in the comments
- Link me to an existing blog post
- Ignore this post completely and go back to surfing for por... er answers to their own questions
Without further yammering:
Using Transfer/Rector with your Service LayerI was reading Brian Rinaldi's post on this topic, and it was great! But one thing that I am not sure it answered, and I am kind of confused about it: Is it OK for my service to be aware of Transfer or Reactor?
In Brian Kotek's post he says "This way, your manager doesn't have to know anything about the Reactor factory...". So I am confused. Is it ok for a service layer object to call Transfer or Reactor from its variables scope?
<cffunction name="getList" output="false" returntype="string" access="public">
<cfreturn variables.Transfer.List('pages.page') />
It seems to me that by doing this that the Service layer becomes aware, and dependent on the ORM framework. Is this one of those no-nos I keep hearing about? If so, how do I do it "correctly"?
Bean ConstructionI think I have the general concept of beans and object inheritance and composition down; however, putting them into practice is quite a different story.
So let's say I have a simple bean that represents a page on a web site. And that page can contain links in a one to many relationship. So I want object composition between page beans and link beans. So my question is, when I call for a specific page bean in my controller/listener/handler/whatever from my pageService, what should I get back?
<cfset pageBean = pageService.getPage('18') />
Should this return a fully populated pageBean, including an Array (or struct) of all of its link objects? Or should it only return the page bean and then with a separate call from my controller to the linkService should I get all of the links for that page and then add them to the pageBean?
<cfset aLinks = linkService.getLinkArrayByPageId('18') />
<cfset pageBean.setLinkArray(aLinks) />
If it should be a fully populated pageBean, with the linkArray, where should that be created? Do the links get set into the pageBean in the service layer using code like what I have above? Or is it requested by the bean itself (I doubt it), or does ColdSpring or Transfer do this for me somehow?
Using Tranfer/Reactor instead of or in addition to a DAO and GatewaySo I think the H3 tag there sums up my question. I think I know the answer to this, but I will ask for clarification. I think that if all I need are CRUD (Create, Read, Update, Delete) methods and the List methods and other methods included with Transfer/Reactor that I do not need a DAO or Gateway in addition to the ORM. But, if I do need functionality beyond what an ORM offers, I can have a DAO and/or Gateway present and inject them into the service layer without interfering with the ORM. Is this correct?
Wrap upThese are big, ugly (and probably mis-worded) questions, and no doubt some of you will think them quite silly or simple. But to me, and I am sure to many others, the answers are not obvious. I think all too often, the expert developers to whom many of us look up will blog about a topic with the assumption of a more learned audience. And if that is the intended audience, that is fine. But I know, in my blog browsing experience, there is a very big gap in between the very basic posts and the super advanced Kotek-talking-to-Corfield posts.
A lot of times I will also see posts that talk about a neat "technique" for accomplishing "X", and the blogger will post a snippet of "Here is all you need to add to your ...", and then we are left to figure out the rest on our own. Maybe these types of posts are only intended for people that already know the rest, but for me, they are very frustrating, because I say to myself, "That is what I was looking for! Where is the rest of it?". I am not skilled enough yet to figure out the rest on my own.
I hope that I can get some of these questions answered. I also hope I am not making a fool of myself revealing how little I really know.