one to one to your Database Table.
person idea is best (i.e. creating each class for Visa, Mastercard and
On May 1, 7:06 am, Rizwan <Riz...@discussions.microsoft.com> wrote:
> Thanks Michael.
>
> One other person I consult with, thinks the first way is better. He is of
> the view that "your classes should match one-to-one with your tables". What
> do you think about that?
>
> > Hello Rizwan,
>
> > The second case is preferable, because u have the common data/logic for all
> > you classes which can be moved to the base class
>
> > Read about inheritance there
http://en.wikipedia.org/wiki/Inheritance_%28computer_science%29
>
> > ---
> > WBR, Michael Nemtsev [.NET/C# MVP].
> > My blog:
http://spaces.live.com/laflour > > Team blog:
http://devkids.blogspot.com/ >
> > "The greatest danger for most of us is not that our aim is too high and we
> > miss it, but that it is too low and we reach it" (c) Michelangelo
>
> > R> In the system I am working on, there are 3 credit cards: Visa,
> > R> MasterCard and
> > R> AmericanExpress. On the database side I have one table: credit_card
> > R> CREATE TABLE credit_card
> > R> ( credit_card_id int not null PRIMARY KEY,
> > R> credit_card_code varchar(30) not null,
> > R> description varchar(255) null )
> > R> Now I am building classes and i can do it in 2 ways:
> > R>
> > R> * Build a class "CreditCard".
> > R> public class CreditCard
> > R> {
> > R> private int _creditCardId;
> > R> private string _creditCardCode;
> > R> private string _description;
> > R> }
> > R> * Build a class "CreditCard" and then build 3 classes "Visa",
> > R> "MasterCard"
> > R> and "AmericanExpress" all inherited from "CreditCard".
> > R> public class CreditCard
> > R> {
> > R> private int _creditCardId;
> > R> private string _creditCardCode;
> > R> private string _description;
> > R> }
> > R> public class Visa : CreditCard
> > R> {
> > R> }
> > R> public class MasterCard : CreditCard
> > R> {
> > R> }
> > R> public class AmericanExpress : CreditCard
> > R> {
> > R> }
> > R> Which way is better and why?
> > R>
> > R> Thanks
> > R>