A Paradigm shift (Or how to learn OOP on the job with out screwing up).

I have been banging my head against CFOOP for about a year or two and thought I would share some of my tricks, trials and tribulations.

I just noticed how my thinking has changed when developing apps these days.

Huh... Thinking about thinking is meta-cognition. So what do you call thinking about what you are thinking about when thinking about metadata? I smell a cognitive infinite recursive loop in the making. (Note to self.. Tell brain to STFU for a minute so I can finish this blog entry FFS)

Anyways...

1. I write the procedural code to get the things I need done. I don't even think about OO at this point.

2. I turn everything into functions and try to atomize things as much as I can (where it makes sense to at least).

3. Then I create a CFC (or CFCs) to organise my functions

4. Then I rewrite my procedural code to incorporate my cfcs/functions

5. I turn THAT code into another function or set of functions

6. And then I turn THAT set of functions into another CFC (0ne ring to rule them all). IIRC this is your service layer.

I got into this whole head set from reading Head First Object-Oriented Analysis and Design.

Taking on this approach has really helped me a lot. When you are getting into a new discipline /paradigm shift /cognitive restructuring such as OOP it can be *VERY* overwhelming and it is *all too easy* to think yourself utterly stupid to the point where you are a quivering blob of "WTF?" before you even write your first line of code. So much so that you say fark it and go back to writing code like you used to (not good).

I have seen it time and time again both in my personal life and from reading interblargs.

What I find with this iterative, incremental approach is that if you get into time crunch, or think yourself stupid, or get in over your head, or get stuck, you can always bail out and still have a functioning app that you can go back to and clean up at a later date.

This approach has really allowed me to push my limits when I can (Read: on the clock) and bail out when I have/need to. And after a while you just start to think differently about code and writing OO code becomes a natural part of your daily affairs. I find myself looking at legacy code and thinking "What can I abstract into a function" or "How can I clean this heaping pile of spaghetti into something more useable". And the next thing you know you are seeing everything in those terms. Your thinking has changed.

The end result on my last foray into OOP was three tidy function calls to a cfc that turned (what was) 500 lines of copy and paste spaghetti code into:

usercfc.createAccount(somestruct)
usercfc.updateAccount(somestruct)
usercfc.deletedAccount(somestruct)

Fergolicious!

Portable version of the Safari Web Browser

I am a huge fan of portable apps. I like being able to drop an app in a folder and not have to install it. You just put them on a portable or thumb drive and you are good to go. Actually I have a version of almost my *entire* dev environment (sans MSSQL, that is next) on a thumb drive. I can literally set up shop anywhere (on a Win box).

Any who, I needed to test a design against the WebKit browser, the engine behind Chrome, Safari and (I think) it is used by DW for it's Live View feature. So here are links to versions for both Mac and Windows:

"http://www.thindownload.com/app-download/47/Safari-Browser (Win)

http://osxportableapps.sourceforge.net/p_safari/ (Mac)

Writing a super simple Login

I have an old wiki that I really like that had no login. I wanted to lock it down with out having to write a bunch of code. Nothing super important but important enough to keep people out. Just add a couple random vars and poof - problem solved.

<cfparam name="url.Action" default="">
<cfparam name="url.Snuggums" default="">
<cfparam name="session.logedin" default="false">

<cfif url.Action EQ "eamyrfg338645dddesdjft3" AND url.Snuggums EQ "phlarph">
   <cfset session.logedin = "true">
</cfif>

<cfif url.Action EQ "logout">
   <cfset session.logedin = "false">
</cfif>

<cfif session.logedin EQ "false">
   <cfabort>
</cfif>

That's right bitches!! A Free, KICK ASS, Open Source CFML Engine!!

Recent Entries

Calendar

Tags

NAVIGATION

Recent Comments

RSS

Search

Subscribe