I'm from a non-computer background, and I'm struggling to think about the approaches and structures of MVC in general. I "get" code reuse and separation of logic from the display, and I "get" encapsulation and decoupling, but I donβt understand this.
At the moment, I just put everything in the root, separate subfolders for images, cfcs and _includes, all database interaction through cfcs. I do all my processing at the top of the page, then the comment line, then display / page layout below that.
Most of the frameworks I looked at seem to prefer the front controller, so my simplified version of the MVC design of the top controller will be a subfolder for cfcs, controllers and views, and the big switch statement in index.cfm
<cfif not IsDefined("URL.event")> <cflocation url="index.cfm?event=home" addtoken="No"> </cfif> <cfswitch expression="#url.event#"> <cfcase value="home"> <cfinclude template="controllers/home.cfm"/> <cfinclude template="views/home.cfm"/> </cfcase> <cfcase value="about"> <cfinclude template="controllers/about.cfm"/> <cfinclude template="views/about.cfm"/> </cfcase> </cfswitch>
.. but what real advantage does this give me over the design of the page controller? If these are not just the sites that I write, it always seems to me that the controller logic is presentation-specific, it does not look like one controller can correspond to several views, or several controllers can display one view, so what will the point be divided them?
The light has not yet appeared for me, no signs?
Saul
source share