Introducing "the CFArgument" with Brian Rinaldi
CF Argument is all about taking two sides of an argument and seeing where it leads. The first installment covers the iterating business object. Hopefully we'll be able to make this a weekly thing . . .
CF Argument is all about taking two sides of an argument and seeing where it leads. The first installment covers the iterating business object. Hopefully we'll be able to make this a weekly thing . . .
After some pressure I finally uploaded a ZIP file to the project. It is just a single cfc with all of the key methods and I haven't had a chance to test it on its own, but it should give a pretty good idea of my implementation for anyone who wants to do something like this.
Two design decisions that are most arguable (IMO):
Of course, you could argue with the whole generic getter/setter approach as making the API of the bean less explicit, but for my use case there's no way I'm going to generate a bunch of dumb getters and setters to bulk up a code base that human beings really aren't supposed to be looking at most of the time anyway.
Then there is the question of why bother with this at all rather than just a collection of actual business objects. Answer is instantiation costs for displaying lists and by having a performant approach to instantiation what appears to be a collection of business objects it means I can ALWAYS use the same approach rather than having to start with queries and then refactor my views and other code as I find a business object has more calculated properties than I realized.
Thoughts?
My IBO had gotten a little overstuffed with tangential concerns, but as part of a rewrite of my framework I've cut it down to its core concerns while making some improvements to its functionality (adding class properties) and I have decided to release it as a project on RIAForge - ibo.riaforge.org . . .
Personally, I am too lazy to write the delegates in the business object (hmmm, suppose you could generate and then mix them in if you wanted to :->), but in terms of ease of dropping into a project this is definitely a good solution and worth playing with.
Help/Input requested!!!
Because I like writing a small amount of code that solves a large number of problems, I really don't like coding special cases unless it is necessary. For instance, many people write scaffolding forms that allow you to edit a single object using all of its fields. But what happens if you just want to change the price and title of ten products using a single form? Of course, you could hand code that, or you could just pass a property name list to your form (the fields to include in this instance) and automatically make all of your forms support editing of a collection of n-records (including the special and most common case - where n=1).
This issue has come up as I try to decide how to implement my business objects. I need to have a base business object with generic getters and setters, and I need a collection object (I used to call it an Iterating Business Object) with my updated iterating methods - first(), next() and hasMore(). . . .