Hey Ronan, my comments below. On Thu, Jul 10, 2008 at 10:16 AM, Ronan Lucio <[EMAIL PROTECTED]> wrote:
> Hi All, > > I've read the Brian's comments in the Ben Nadel's blog about some > interesting points about architecture. > http://www.bennadel.com/index.cfm?dax=blog:1275.view > > It raised me doubts about the OO and code's abstraction. > > *"Every time you call a getter or setter you are drifting away from the > real point of OOP, which is to *tell objects what to do*, not to *ask them > for data about themselves*." > * > So in a correct OO approach app has to *tell objects what to do*. Right. > Thinking about that, ins't it > > order = serviceOrder.new(); > *order.populate( form );* > order.validate(); > > a better abstraction than > > order= serviceOrder.new(); > *serviceOrder.populate( order, form );* > order.validate(); > > In the first example we're saying "Hey, take this form and populate > yourself with these values". > Yes I would say that it is. There's no reason ask another object (the OrderService) to populate the Order object when you can just tell the Order object to populate itself. > > Bellow to the comment Brian suggests if it's a need to check if a special > situation was confirmed of not, use a method "isConfirmed()". > > So I need another method inside the object: > > order = serviceOrder.new(); > order.populate( form ); > order.validate(); > if (*order.isConfirmed()*) { > serviceOrder.save( order ); > } else { > errorMessage = "You need to confirm the order"; > } > > or use a Service Layer > > order = serviceOrder.new(); > serviceOrder.populate( order, form ); > order.validate(); > if (*serviceOrder.isConfirmed( order )*) { > serviceOrder.save( order ); > } else { > errorMessage = "You need to confirm the order"; > } > Again, yes I would check the confirmation in the Business Object not the Service, as in your first example. I actually create a Result object that I pass along with things like this that has an isSuccess() method, as well as a getErrors() method. So that I can do something like: order = factory.create('Order', id); result = factory.create('Result'); order.populate(data); // gateway will call order.validate() and if all is OK, call order.save() and set isSuccess to true. // if validation fails, the errors are set on the result object and returned gateway.save(order, result); if(result.isSuccess()) { result.setSuccessMessage('Order was saved successfully'); } return result; > > Brian, I really liked your comments and your suggestions. > I'm just talking about how this suggest should be done/implemented. > > In one hand putting some logic inside beans looks a betters abstraction. > In the other hand it doesn't gives us a good encapsulation because it's one > more CFC to handle part of the business's rules. > I'm not sure I follow. What do you mean by "one more CFC to handle the business's rules"? Does what I'm showing above answer your question? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
