SimpleNTier sample - need changes?

SimpleNTier sample - need changes?

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


rfcdejong posted on Friday, November 12, 2010

SimpleNTier shows:
- the ObjectFactory basics
- clean business objects
- simple silverlight frontend
- simple wpf frontend
- simple winforms frontend

But:
It doesn't compile out of the box, for people who are new to csla they will still have some work to do make it work.

How to make it work
1) Download bfx (http://bxf.codeplex.com/)
2) Reference the silverlight Bxf.dll from the silverlight project.
3) Reference the DotNET Bxf.dll from the WPF dll
4) Add a cross-domain policy file to the WcfHost project.


What i suggest to change is make it work out of the box (so include the bxf dll's) and the way business rules are used.

The Order and LineItem class are using DataAnnotations.. why?
Shouldn't BusinessRules be used?
Or is the SimpleNTier sample just out of date (less then ProjectTracker sample)

Order class:
protected override void AddBusinessRules()
{
  BusinessRules.AddRule(
new Csla.Rules.CommonRules.Required(CustomerNameProperty));
}

LineItem class:
protected override void AddBusinessRules()
{
  BusinessRules.AddRule(
new Csla.Rules.CommonRules.MinValue<int>(IdProperty, 1));
  BusinessRules.AddRule(
new Csla.Rules.CommonRules.MaxValue<int>(IdProperty, 9999));
  BusinessRules.AddRule(
new Csla.Rules.CommonRules.Required(NameProperty));
}

RockfordLhotka replied on Friday, November 12, 2010

I agree about putting the Bxf.dll files into a Dependendies folder. I've been considering doing this for all the samples - including putting the CSLA assemblies in a known location so the binaries come down in the Samples zip file.

The cross-domain file... Maybe. If people are going to do SL development, they'd better learn how to change the default startup project to the web project. This info gets lost continually in solutions, and it has to be reset a lot - I'm not sure coddling people in this regard is the best approach.

I use DataAnnotations a lot. I tend to prefer them to CSLA rules, when they work. As you can see, the addition of WP7 has complicated matters because WP7 has no DataAnnotations.

I am considering creating a subset of DataAnnotations for WP7 though, specifically to increase the cross-platform compatibility of code. In short, I like them enough that I don't want to give them up just because WP7 doesn't have them.

Copyright (c) Marimer LLC