Entries Tagged as 'Learning'

Fancy Bread Blog Turns One Today!

Learning , Ideas 7 Comments »
Thanks to all the folks who have read and commented on this blog over the past year. I've met a lot great people and learned more than I imagined. A quick review of my stats for the year shows 44 posts with an average of 865 views and just under 2 comments per post. The top three categories are ColdFusion, ColdSpring and Transfer. I started blogging to share my learning experiences and ideas. Year two will be a lot more of the same. :)

ColdFusion 8 Application Mappings and Sub-folders

Learning , ColdFusion 2 Comments »
Now that I'm on a CF8 hosting plan, I've started leveraging some of that goodness in my applications. The first thing I have implemented is application level mappings to keep my configuration files and components out of the web root. Here's how my current project layout rolls.
/project
  /config <-- Coldspring and Transfer config files
  /model <-- model components
  /root <-- web root
    /admin  <-- secure admin screens
Basically, I want to create mappings to config and model. I did a little googlin' and found a nice snippet on Sean Corfield's blog on looping over a list to build the mappings. I aped that code with a slight mod for my setup. <cfif (ListLast(CGI.HTTP_HOST,".") eq "local")>
<cfset mapPath = "../">
<cfelse>
<cfset mapPath = "../" & this.name & "/">
</cfif>

<cfloop index="p" list="config,model">
<cfset this.mappings["/" & p] = expandPath(mapPath) & p />
</cfloop>
I dev on Mac and deploy on Windows and my local folder structure is slightly different from my host. The first part of the code is just a test of whether the site is being served up locally. When on the production server, the mapped folders are in a folder with the same name as the app. This is a great alternative to using Apache Alias or Virtual Directories in IIS for mappings. That is, until I tried using the mapping from within the admin folder. Suddenly the path was not recognized. I initially thought this was a transfer issue, but that was not the case. I tried several variations and workarounds. Eventually, I figured out that the mappings were fine for files in the web root where Application.cfc resides. So why was the path not available to files in a folder below the web root? The answer was pretty simple. The admin folder had no Application.cfc, thus no mappings. Remembering another gem by Mr. Corfield regarding extending Application.cfc via a Proxy, I created an Application.cfc in the admin folder and the required proxy in the web root. Instead of repeating the code for creating the mappings with only the path prefix changed, I wrapped the creation of mappings up in a method. <cffunction name="createMappings" access="private" output="false" returntype="void">
   <cfargument name="pathPrefix" type="string" required="false" default="../">
   <cfif (ListLast(CGI.HTTP_HOST,".") eq "local")>
      <cfset variables.mapPath = arguments.pathPrefix>
   <cfelse>
      <cfset variables.mapPath = arguments.pathPrefix & this.name & "/">
   </cfif>
   <cfloop index="p" list="config,model">
<cfset this.mappings["/" & p] = expandPath(variables.mapPath) & p />
   </cfloop>
</cffunction>
And call it from the Application.cfc in the admin folder using the appropriate prefix. <cfcomponent displayname="Application" extends="ApplicationProxy">

<!--- set mappings in this directory --->
<cfset createMappings(pathPrefix="../../")>

</cfcomponent>
Application level mappings are handy, but the per directory limitation does not make for a tad more code. Overall, I think it's a small price to pay for the benefit gained.

UPDATE:

After testing this on my Windows machine, it appears that using "this.mappings" inside a method does not properly set the mappings. I've changed things around so that the createMappings() method returns a struct and I set it as a pseudo-constructor. <cfset this.mappings = createMappings(pathPrefix="../") >

Of Views and Models and Working With Transfer ORM

Learning , Transfer , Modeling 2 Comments »
Yesterday, I asked Mark Mandel for some advice on tuning my object model for performance. Mark, being an ever-so-helpful (P)OSS author, gave me a few suggestions. Turns out that someone asked basically the same question on the transfer list today. Jaime Metcher made a couple of excellent points on choosing between queries and object composition. Paraphrasing, Jaime, when working with large data sets (the type of thing you might be tempted to use arrays of objects for), you will get better performance using a query. If you want to display a single instance of some object and the view is truly a composite, then your model should reflect that composition. Understanding this helps with choosing between onetomany or manytoone relationships for your object compositions.

Read more...

Two Utility Classes to Help Keep Your Controllers Lean

Learning , ColdFusion , Application Architecture 5 Comments »
I have really enjoyed reading the perspectives on application architecture that have sprouted up on the mailing lists lately. It comes a at good time for me, since I'm beginning my first fully OO MVC project. One of the best recommendations, I feel, is to keep your controllers as dumb as possible. While this is a fine aspiration, there are plug-ins and convenience methods available to frameworks that just make life easier. In particular, the availability of "beaner" methods. I'm currently using Model-Glue, so I'll use the makeEventBean() method as an example. MakeEventBean() is really useful for populating a bean with any setter methods that match the keys in the Model-Glue event. While convenient, I think it provides a slippery slope for business logic to slide into controller methods.

Read more...

My Learning Agenda: What's on yours?

Learning 8 Comments »
I've had this list on my white board for a couple of months. It's time to make some space, so I'm posting this so I can look back and see how long it takes to achieve a modest degree of proficiency for each subject (by my own measure). Some of the subjects I have a beginner to intermediate knowledge of. I'm listing them here because I want to reach an expert level.

Apache Ant

I've run a build.xml file, but I do not know a thing about how Ant works or how to leverage it for development. Sad, but true...

Subversion

I've used Subversion for a long time, but have always been petrified of using branches, tags and merging. I need to overcome that to reach the next level. Even if I start with a local repository first.

Unit Testing/TDD

I've made some headway in this department with CFCUnit, but my effort has been less that stellar. I'm radically changing my development work flow and this is one area that I definitely want to integrate without backsliding or excuses.

Regular Expressions

Oh, the shame. For I am lame when it comes to regex. It's just one of those things I've passed on learning in favour of something else.

Aspect-oriented Programming (AOP)

Like subversion, I'm familiar with ColdSpring, but mostly on a simple level. Over the next few months, I'm pretty serious about breaking out of the comfort zone and really learning how to harness the more powerful features ColdSpring has to offer.

Design Patterns

I grok a few patterns, but the majority of patterns, and OO concepts, are elusive to me. I might need to really focus on the basics before venturing into the pattern hinterland.

Flex

I have an AIR app in the HTML/Javascript category, but I have not sat down and worked at learning Flex. "I'll get to it", I keep telling myself. And with the demand for Flex developers these days, I'd be a damn fool not to add those skills to the arsenal sooner than later. ;)

Actionscript 3

Oh how I love and cherish my Essential Actionscript 2 book by Colin Moock. I know I'm going to dig working with AS3 as much, if not more. Why haven't I mastered it yet? Still searching for a good project that I can put a focused effort into.

jQuery

jQuery gets a lot of love and rightfully so. I've had a taste over the last few weeks and it can be an addictive.

UML

I have only scratched at UML, but I'd really like to be able to build UML into a standard part of my development process. Even if I only master class diagrams I'll be happy.

A programming language I don't know

Ruby and Python are high on the list. Regardless, I want to spend a little time working in a new language (static or dynamically typed) to improve my understanding of object oriented programming.

This agenda is subject to change. I haven't place a date or priority on any subject as it is likely that I'll focus on two or more at any given time. And it's entirely possible that I immerse myself deeply into one subject until I'm satisfied with my level of proficiency.

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds