non-CSLA BindingList or derived object from BusinessListBase

non-CSLA BindingList or derived object from BusinessListBase

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


jupp posted on Tuesday, August 15, 2006

What me confused is when to use a non-Csla- BindingList for a collection of Objects an when to use a derived object from BusinessListBase.

I have a class Address.  The Address class has various fields.  In addition to these fields, the address class has a collection of AddressLines for customizing localisation issues. Each address line is a String. 

 

I have to cases to design this class.

1.

 public class Address : BusinessBase<Address>

{

   private string _street;

   private string _postalCode;

....

   BindingList<string> _addressLines;

}

2.

public AddressLine : BusinessBase<AddressLine>

{

   string _line;

}

 

public AddressLines : BusinessListBase<AddressLines, AddressLine>

{

}

public Address : BusinessBase<Address>

{

    private string _street;

   private string _postalCode;

   AddressLines _addressLines;   

}

How to do? Which is best?

ajj3085 replied on Tuesday, August 15, 2006

Well, normally I'd say go with the BLB class.. as each item in the collection should know how to persist itself (and likely is stored differently from the other data).

In this particular case though, I have to ask.. will you ever have more than say three address lines?  Its been my expierence you won't... which seems to lend itself to creating your class just to hard code AddressLine1, AddressLine2, etc and having a column for each in the db (although there's no reason you couldn't store the lines differently to allow any number of lines.. it just doen't seem like it'd buy you much).

So, I'd suggest rethinking if you really want to allow more than three or so address lines, especially given that a standard sized envelop only has so much room, and the postal codes in your country may limit how many you can have.

HTH
Andy

jupp replied on Wednesday, August 16, 2006

Thank you.

Copyright (c) Marimer LLC