New to the concept

New to the concept

Old forum URL: forums.lhotka.net/forums/t/3673.aspx


webjedi posted on Monday, October 08, 2007

Hi there!

I'm an old school classic asp developer making the switch to .NET and I'm investigating this framework.  I'm reading the book now and I'm starting to grasp the concept of making my object behavior driven rather than data driven.  If I could outline a short scenario and how I'm thinking it would work in this construct, I'd appreciate some feedback.

Consider an auction application.  There are ITEMS, CUSTOMERS and BIDS.  Customers place bids on items, there's some business logic to determine if the bid is the high bid etc...  Cool...easy enough.  ITEMS would be parent to BIDS, and all the behaviors of placing bids would be contained in the CUSTOMER object.  The business logic concerning if the bid is valid (ie, meets the rules) would be countained in the BID object.

Am I close or on another planet?

Ryan

Wal972 replied on Monday, October 08, 2007

Hi Ryan,

Your BOs should be about the activity, rather than the data as your first comment states. However the implementation is reverting back to data driven. (I still do that sometimes). So a sample BO would be PlaceBid. BOs like customer or Item would enable the editing of the Customer or Item only. Bid as a BO may not even be necessary depending on the situation. The business logic (rules etc) are related to the activity of placing a bid not the bid itself. In the data storage side your would have the item, customer and bids etc.

Hope that helps

Ellie

ajj3085 replied on Tuesday, October 09, 2007

Sorta on the right track.  You build objects to satisfy one and only one use case. 

So for a bidding use case, I'd say that Bid is a root object.  Its factory create method would likely take a customer id and item id (or readonly versions of the customer / item objects... depends on how your use case goes).   Then the client can set things like bid amount, and other attributes.  Saving it would be the equivolent of placing the bid.

Based on what you said so far, none of your editable objects would likely have child objects.

Copyright (c) Marimer LLC