I suggest posting this to alt.net group too

[EMAIL PROTECTED]

I would do it by having IRuleStore which you can then implement for
nhibernate. You can associate an entity with a rule and have a default rule
which can handle non-complex things.

On Thu, Nov 13, 2008 at 7:39 PM, Jan Limpens <[EMAIL PROTECTED]> wrote:

> Hello,
>
> this question is not _directly_ castle related, more to the general topic
> of entities, services and ioc. I hope that is not a problem.
>
> I have the classes Order, Cart and a service CartToOrderCoversion.
>
> When the user places an Order, he will give a Cart to the
> CartToOrderCoversion.Execute(cart) and gets an Order in return.
> During this step I currently inject a list of IOrderRules into the service
> via IoC. These rules can do things like:
>
>    - if the order total is more than 300.00 you will get a discount of 10
>    or a gift. Or
>    - if your items are of  certain type, you will get another item for
>    free etc...
>
> These IOrderRules are configurable via regular Windsor xml more or less
> like this
>
>         <component type="Rules.BuySpecialItemGetGiftRule"
>                              service="IOrderRule">
>             <parameters>
>                 <mode>Rules.RuleModes.Always</mode>
>                 <description>If you buy an item that fulfills a very
> complicated condition the user gets an item with the id
> beyond.</description>
>                 <externalmessage>promo bla bla</externalmessage>
>                 <internalMessage>Rule BuySpecialItemGetGiftRule added 1 {0}
> to the order because {1} fulfills the complicated
> condition.</internalMessage>
>                 <giftArticleId>1546</giftArticleId>
>             </parameters>
>         </component>
>
> xBuySpecialItemGetGiftRule also gets injected an IArticleDao to get to the
> article of the id, which it would then add to the order, another IDao to
> check the condition (both in the .ctor) and an ILogger (setter) because we
> want to know whats going on.
>
> This is not very comfortable and flexible in terms of administration (needs
> app restart on changes, manual xml editing by business people).
>
> So on one hand I would prefer these rules to be normal (nhibernate
> persisted) entities in the db and directly hold references to entities
> (instead of ids), which would also help with data integrity. This would help
> me get rid of some of the services.
> On the other hand sometimes the conditions they have to check are so
> complicated, that only a direct query with a service can resolve it. So I
> would need to pass in these services (probably via an interceptor), but I
> have a feeling, that a business object should not have any knowledge of
> services.
>
> What do you think? Is my model already good? How would _you_ do that?
>
> --
> Jan
> ___________________
> [EMAIL PROTECTED]
> www.limpens.com
> +55 (11) 3082-1087
> +55 (11) 3097-8339
>
> >
>


-- 
Tuna Toksöz

Typos included to enhance the readers attention!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to