njapp

njapp

0p

1 comments posted · 0 followers · following 0

17 years ago @ Rob Conery - Kona 3: Learning Behav... · 0 replies · +1 points

Rob, great job with the MVC Storefront and the move to Kona. Most of us appreciate your hard work and understand you'd probably rather be surfing.

I really love the screencasts and appreciate the solid advice giving by all of your partners in crime, especially Ayende!
[ I'm still waiting for Fowler to create a pattern to siphon Ayende's knowledge while he sleeps via Skype ]

I have a quick question about the state machine you are using with your Product model, specially the CurrentInventory property. Is there a reason why the CurrentInventory setter is not marked private? Wouldn't you want this code to fail?

Product p = new Product("TEST", "test", true, 10, 0, DateTime.Now.AddDays(-7), true, true); // this would put the Product in OnBackOrder
p.CurrentInventory = new InStock( p ); // easily set the incorrect state

FYI: All Unit Tests pass if you change the Product.Currentinventory set modifier to private and then remove the following methods from InventoryState

public virtual void SetAsAvalable()
public virtual void PutOnBackOrder()
public virtual void PutOnPreOrder()
public virtual void TakeOffline()

Of course to make these changes completely functional you would have to call InventoryState.SetState whenever a Product property is set.

Any thoughts?