Want to learn OOP?

July 06, 2009

I saw a post from someone wanting to learn Object Orientated Programming over on the Drewcorp Coding blog. I started posting a comment but it got a bit long and I figured it deserved it's own post. So here are my thoughts on learning OO.

A couple of people had commented on the blog that Andrew should download Coldbox and check out the CodexWiki. Whist I think ColdBox and the CodexWiki are great examples of good code, I also think they are bad place to start. CodexWiki use ColdBox, Transfer and ColdSpring so it's a lot to learn in one go and will probably scare you off never to return.

First off, good luck to anyone who embarks on the OO path. It's a never ending journey (you just keep learning) and it gets tough in places but is worth the effort. I'm relatively new to OO and so I know the pain of getting started, when it just seems to be a blur of jargon.

Can I suggest that you start simple and look at some really simple examples to get the concepts in your brain before you even look at what frameworks can do for you.

Some framework agnostic things to check out:

Blog Posts

Doug Boude's OO Terms In a ColdFusion Context
http://www.dougboude.com/documents/dougboudeslexicon.cfm

Matt Woodward's CFC-101: An Introduction to OOP in CFMX
http://www.mattwoodward.com/blog/index.cfm?event=showEntry&entryId=0192EF43-AD5D-07AE-533106DEB4F48B37

Nando's mini OOP series
http://aria-media.com/blog/index.cfm/oo-in-cf

Online Presentations on UGTV

Michael Dinowitz's OO Programming with CFCs:
http://adobechats.adobe.acrobat.com/p90923191/

Bob Silverberg's Building An Object Oriented Model:
https://admin.na3.acrobat.com/_a204547676/p21244086/

Once you've got a handle on those things, then I recommend look at an ORM like Transfer or Reactor. The Transfer sample blog doesn't use any frameworks so is great for learning how to use objects, as there is nothing to distract you. After that you will probably have a pretty good idea of how OOP works so you'll have a good idea what you want to learn next, but an MVC framework like ColdBox would be a good choice as it has some great sample apps.

Whilst I'm not as clever as the guys listed above, I have written a few posts a while back on OO terminology which may help as knowing the lingo definitely helps when you read other material. The posts are here. I've also done a couple of presentations which you can see here

Of course, the most important thing of all is to write some code. Yes you're going to make mistakes (I make loads), but there is no better way of learning. You can always ask some really smart people what you're doing wrong on the via the CFCDev mailing list.

If anyone else has any recommendations please let me (and others) know!


10 comments

  1. Hey from Drewcorp Coding!
    I really appreciate the post.
    I was starting to wonder if I should put off frameworks until I've mastered ColdFusion a bit more thoroughly. Perhaps with the articles you noted I could figure a place to start.

    I especially liked Doug Boude's OO Terms article - it really puts it in perspective.

    I'm still wondering, though, how people learn this stuff? Do self-taught programmers usually structue their own code for a few years before recognizing a problem that frameworks solve? Or would it be best to start learing CFML and a framework simultaneously?

    Thanks again for your great response.

    Comment by amclean – July 06, 2009
  2. Adrian Moreno has an excellent guide that helped me get started.

    www.iknowkungfoo.com/blog/index.cfm/2007/8/22/Object-Oriented-Coldfusion--1--Intro-to-Objectcfc

    Comment by Dutch Rapley – July 06, 2009
  3. I agree, it seems like whenever someone shows an interest in OOP in the ColdFusion community, there's always the mention of some "framework" as if that will be the magic bullet. Sorry, that really doesn't work for me ... if anything, it's just more code to look at and figure out, more documentation to review, etc.

    I also agree that OO is an ongoing-ever-evolving-journey. Before embarking on that journey, I highly recommend "Fundamentals of Object-Oriented Design in UML" by Meilir Page-Jones. I wrote a brief review of it back in January (www.stephenwithington.com/blog/index.cfm/2009/1/5/Quick-Review-of-Fundamentals-of-ObjectOriented-Design-in-UML), but in summary, the first 50 pages alone are worth buying the whole book for.

    Cheers!

    Comment by Steve Withington – July 06, 2009
  4. The following website has some useful articles, but I don't think it's been updated for a while.

    www.cfoop.org/

    Comment by Simon Bingham – July 07, 2009
  5. Thanks for the comments guys :)

    @amclean, I started out writing websites in ColdFusion "spaghetti code", using includes for headers and footers and putting everything else in one script. After that I started writing ASP.net which promotes separating your code into presentation (views) and model (the bit that does all the work). When I came back to doing ColdFusion, I choose the Fusebox framework as it allows your write OO or procedural code and split it up into layouts/views and queries/actions (model) and controllers (MVC).

    The recent Fusebox version uses cfcs as controllers and is quite similar in syntax to ColdBox, so if XML puts you off try one of these.

    @Dutch, yeah I was very tempted to add Adrian's series of posts. I didn't because I think if you read it before you understand objects, relationships and responsibilities you can end up writing code that is just procedural code wrapped up in a CFC. It is definitely worth reading, just read some other stuff first :)

    @Steve, glad you agree! I read another of Meilir Page-Jones' books, Object Orientated Technology: A manager's guide, which is also an excellent introduction to the concepts of OO. As developers we all just want to dive in and write code, but sometimes it is best to step back and take to time to understand the concepts behind what we want to achieve.

    Comment by John Whish – July 07, 2009
  6. @Simon, thanks for the link. The cfOOP.org website has some good stuff on it, although like you say it doesn't seem to have been updated for a while.

    Comment by John Whish – July 07, 2009
  7. @John, is it actually necessary to use a framework in order to separate the presentation layer from the application layer? It seems to me like I've done that already in a lot of cases. Granted they weren't the most complex of application...
    Is it only intended to make things easier?

    Comment by amclean – July 07, 2009
  8. @Amclean, no it isn't neccessary to use a framework to seperate layers.

    Frameworks are born out of repetitive code and solving the same problems. They do a lot of the "heavy lifting" for you, but you can do it yourself. A lot of people use frameworks because they are proven, standardised and simply save you time - why reinvent the wheel? Having said that it is always good to try to do it yourself as you'll learn a lot and also find out the problems that frameworks have already solved.

    Comment by John Whish – July 07, 2009
  9. @amclean - No matter what anybody may say to the contrary, the only way to truly be able to learn to use any tool is to, well, use it. :) Take archery, for instance; First, you acquire a bow. Next (ideally), you have an experienced person explain to you how to use it while simultaneously demonstrating what they're talking about. All of this does nothing more than provide you a foundation upon which you will build your own understanding and ability to use the tool, craft, or skill. I venture to say that EVERYBODY has gained the skills they possess the exact same way: acquiring information, and then exercising themselves in it. It is the exercising portion that provides you with true knowledge. Fortunately for those of us using CF, we are immersed in a very supportive and knowledgeable community, so assistance is always just a google search, email, IM, or tweet away. :)

    Comment by Doug Boude – July 11, 2009
  10. Hey Doug, thanks for the comment. I like the analogy with a dangerous weapon :)

    I totally agree that the best way to become skillful with a tool is to practice. I don't think that anyone disagrees with that (I hope I didn't give that impression).

    My experience of starting out on the OO path (and I've a long way to go!) is that it would have been a lot easier with a mentor. As you say, the cf community have been great at answering any questions I've asked, however, sometimes you need to have a little knowledge to even ask the right question!

    Comment by John Whish – July 12, 2009

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.