CFUnited - Object Oriented ColdFusion - Nick Tunney and Hal Helms

Two separate presentations here with two completely different takes on the subject. I was asked by the members of the Tames Valley User Group to give a presentation on OO in CF so thought it would be good idea to attend these two presentations.

In the first one, Nick was very practical and after a short introduction to OO Nick covered how OO can be implemented in CF.

Nick showed how a CFC is used to create a class in CFML. Properties are then set up in the variables scope and a constructor for the class is built in a function which should be named init.

He showed how to create a getter and a setter for each property and how to create data access CRUD so that the object can persist itself.

Gateways are used to process multiple records and don't have to return objects.

Hal had a completely different take and described that kind of OO implentation as POO. Pseudo Object Oriented. Hell! I have been writing and generating POO!

Hal began by telling us how to go about learning OO and said beware of Gurus. We have to internalise the knowledge until we can do this properly. He said we should keep asking further questions and learn by doing rather than just from a Guru.

Having said that he said there is nothing wrong with procedural programming, but Procedural vs OO is like Newton vs Einstein

OO Features:

  • Encapsulation
  • Polymorphism
  • Inheritance

Hal said we should always think from the objects point of view and write the description of any component in the first person (I do this, Not the component does this).

There is a tendency to concentrate on the data. IE: Build the database. In the OO world we must think first about the methods. We need to think about the messages we send to the object. Interfaces are good beacause they specify a class's methods without any data.

Objects need to do things (more than just have getters and setters).

You should not have any algorithms outside of the CFC. The functionality should be provided within the CFC by sending it a message.

Hal closed with some examples of methods and the 'correct' way to implement them.

Comments
Brian Rinaldi's Gravatar Kevin, Thanks for the summaries. Funny, I had heard from someone else about varying takes on OO being presented....just goes to show you there is no one right way to do it (though there are a ton of wrong ways). Anyway, for your presentation I thought a series I did recently focused on OO and Composition might help you:

http://www.remotesynthesis.com/blog/index.cfm/2007...
http://www.remotesynthesis.com/blog/index.cfm/2007...
http://www.remotesynthesis.com/blog/index.cfm/2007...
# Posted By Brian Rinaldi | 6/28/07 1:25 PM
Kevin Roche's Gravatar Thanks Brian that's great.
# Posted By Kevin Roche | 6/28/07 2:21 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.