|
Ummm ... something to say here. What you'll *always* need, no matter how you break your code apart, is some bit of code that tells the other bits what to do and when to do it. Now, you can spread that out all over the place, CodeChunkA tells CodeChunkB to do something and then CodeChunkB tells CodeChunkC and CodeChunkD to do something, and then CodeChunkA tells CodeChunkE and F to do something and so on until you get to CodeChunkZCZR ... but then when you or someone else comes along in 5 or 6 months and looks at that, they'll have a really hard time figuring out how it all works. Coding in this style has come to be known in some circles as "pasta" of the long stringy kind. Spaghetti. It's a very Italian way of dealing with things. Everybody tells everybody else what to do. (Ciao Massimo, just joking a little! Don't take me seriously ;-) So in the example above, we don't have a single (or several) well defined controller(s), but we still have chunks of code telling other chunks of code what to do and when to do it. So ... you always need that "hey you, do this" stuff in your code. The only question is if you encapsulate it in one place, or spread it all around. Many programmers, even Italian ones, seem to feel after a few years of experimentation that they are much better off encapsulating that necessary "hey you, do this" stuff in one place in their code, so they can easily come back to it down the line and see fairly quickly how the whole thing works. So no, you don't need *A Controller*, but you will always need chunks of code telling other chunks of code what to do. Nando :) PS ... A good way to understand how a controller works is to take a good look at model glue. The controller is implemented in a very simple and straightforward way as ModelGlue.xml and the controller cfc's. I don't think many of us on this list would be able to implement a decent MVC app from scratch without a framework to guide us. So i wouldn't start there, unless you are very gifted at implementing abstract ideas in code from scratch. I have a friend who teaches artistic painting classes. He always has someone in the class who comes up to him and tells him they're having trouble coming up with something to paint. So he tells them, always, "Relax, Just copy what i'm doing." And he turns the painting he's working on and points at it with a smile so the student has a good view of it. The student goes back and starts copying. But the funny thing is, my painter friend tells me with a big grin on his knowing face, "they always paint something totally unique." The only trick out here is to choose carefully who you "copy" from! Here's a short list from this copy cat: Hal Helms (his newsletters) Joe Reinhart (his tutorials but you have to search his blog for them, the arf framework, the model glue framework) Sean Corfeld (his sample apps) Ben Edwards (the machII framework) Once you've been copying for awhile, if you're gifted, you might graduate to being an originator. But don't worry if it takes you a little while to get there. :) Peter Bell wrote: Yep. Controller is indeed traffic cop. Also, if there is EVER any chance of a non-HTML interface to your site (web services, flash remoting, whatever), you will want two elements to the controller. A "framework" piece will handle the junk you need to handle to read and speak HTML with a web browser and the "orchestration" piece will call the right model methods in the right order based upon business rules in a way that does not assume there is a HTML request (think sessions, cookies, form variables, URL variables, HTML as part of the response messages, etc.).Best Wishes, Peter -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Aaron Roberson Sent: Friday, June 09, 2006 3:19 PM To: [email protected] Subject: Re: [CFCDev] Do I Really Need A Controller? So, you are saying that I should submit my form to the controller, and then the controller will run the email evaluation and send an error if not valid, or pass the form structure to the service to be inserted in the database if the email is valid. Is that correct? >From what I gather from your example, I think I am beginning to see how the "traffic cop" works... -Aaron On 6/9/06, Dustin Tinney <[EMAIL PROTECTED]> wrote: |
- [CFCDev] Do I Really Need A Controller? Aaron Roberson
- Re: [CFCDev] Do I Really Need A Controller? Dustin Tinney
- Re: [CFCDev] Do I Really Need A Controller? Aaron Roberson
- Re: [CFCDev] Do I Really Need A Controller? Dustin Tinney
- Re: [CFCDev] Do I Really Need A Controller... Aaron Roberson
- Re: [CFCDev] Do I Really Need A Contr... Dustin Tinney
- Re: [CFCDev] Do I Really Need A C... Aaron Roberson
- RE: [CFCDev] Do I Really Need... Peter Bell
- Re: [CFCDev] Do I Really Need... Nando
- RE: [CFCDev] Do I Really Need... Peter Bell
- Re: [CFCDev] Do I Really Need... Nando
- RE: [CFCDev] Do I Really Need... Peter Bell
- RE: [CFCDev] Do I Really Need... Peter Bell
- RE: [CFCDev] Do I Really Need... Peter Bell
- Re: [CFCDev] Do I Really Need... Joe Rinehart
- RE: [CFCDev] Do I Really Need... Peter Bell
- Re: [CFCDev] Do I Really Need A Controller... Cody Caughlan
- RE: [CFCDev] Do I Really Need A Controller? Peter Bell
- FW: [CFCDev] Do I Really Need A Controller? Peter Bell

