Thanks for all the advice on this Guys,

I DID end up encapsulating this in its own object. It's true that some of
the functions are just wrappers for other cffunctions but I also found
myself coding more complex items like conditional loops to count elements of
the array with particular properties and things. Portability was also
something to take into consideration as you say Brian, I passed the first
draft of the class over to a friend who plugged it straight into their
application for testing with only a couple of lines of code needed.

Thanks again for your advice on this one guys, another similar challenge
I've thought about in the past is the classic 'shopping cart' scenario where
you have a cart.cfc which contains an array for all the products, but should
this be an array of structs? Or can you perhaps do an array of product.cfc
objects? Hehe, it's like the old proverb which I believe goes like this:

Each flea has another on his back to bite 'im, and THAT flea has another on
his back to 'im, and so on, and so forth into infinitum.

I've done some work with other languages, in particular 'python' which is
very OO based and they seem to turn everything into an object, and to be
honest I really like that approach.

Thanks,

Rob

-----Original Message-----
From: Brian Kotek [mailto:[EMAIL PROTECTED] 
Sent: 23 May 2007 21:15
To: CF-Talk
Subject: Re: An OO Too Far?

I would still go the route of creating an object to handle this and just
calling add() or remove() on that object in onSessionStart and onSessionEnd
(I'm assuming that is where you're handling this). I'd do this for three
reasons:

First, it's much easier to test if you have the logic wrapped up in an
object. You can test it with CFUnit/CFCUnit, rather than having some odd
test case where you have to run your application just to see if this
actually is working correctly.

Second, it's more portable. You can use the object in any other application
very easily, instead of having to copy and paste actual code (creating the
array, adding to the array, deleting from the array, etc.).

And lastly, once this is encapsulated you are free to change how you are
doing this any time you want to. For example, if you want to insert or
delete this in a database instead of keeping it in an array, you only need
to change the internal implementation of the object and no other code would
ever know the difference.

Hope that helps.

Brian

On 5/23/07, Robert Rawlins - Think Blue
<[EMAIL PROTECTED]>
wrote:
>
> Guys,
>
>
>
> I'm hoping to answer a bit of an old age question that I've been toiling
> with for time with reference to OO methods and how deeply they should be
> applied. I'm going to take a reasonably simple examples and try and get
> your
> thoughts on the best way to achieve this. For my example I'm thinking
> about
> an extension to my user authentication system, which will allow me to
> store
> basic details on what users on the system are currently doing.
>
>
>
> Now in my old application which was not OO I achieved this by creating an
> array in the application scope, this then help a bunch of user_id's, when
> a
> users session was created it placed them into this array as a 'guest' and
> when the session ended I would remove them from the array, nice and
> simple,
> but not OO.
>
>
>
> So if I were to write this in an OO fashion would I replace my simple
> array
> with an object? One of who's properties would be the array? And then
> supply
> myself with a few new functions, like add() remove() changeStatus() and
> some
> more group functions like getAll() countGuests() and things like this. I'm
> just wondering if this is all overkill? Or is this the normal way to
> achieve
> something like this in an OO app design?
>
>
>
> I'd be interested to hear your thoughts on this kind of thing, I'm sure
> you've all come across similar tasks where you have a simple working model
> and wonder if you really need to go the whole hog of wrapping it in a load
> of object code.
>
>
>
> Thanks for your thoughts guys,
>
>
>
> Rob
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:279040
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to