G
Guest
In the system I am working on, there are 3 credit cards: Visa, MasterCard and
AmericanExpress. On the database side I have one table: credit_card
CREATE TABLE credit_card
( credit_card_id int not null PRIMARY KEY,
credit_card_code varchar(30) not null,
description varchar(255) null )
Now I am building classes and i can do it in 2 ways:
* Build a class "CreditCard".
public class CreditCard
{
private int _creditCardId;
private string _creditCardCode;
private string _description;
}
* Build a class "CreditCard" and then build 3 classes "Visa", "MasterCard"
and "AmericanExpress" all inherited from "CreditCard".
public class CreditCard
{
private int _creditCardId;
private string _creditCardCode;
private string _description;
}
public class Visa : CreditCard
{
}
public class MasterCard : CreditCard
{
}
public class AmericanExpress : CreditCard
{
}
Which way is better and why?
Thanks
AmericanExpress. On the database side I have one table: credit_card
CREATE TABLE credit_card
( credit_card_id int not null PRIMARY KEY,
credit_card_code varchar(30) not null,
description varchar(255) null )
Now I am building classes and i can do it in 2 ways:
* Build a class "CreditCard".
public class CreditCard
{
private int _creditCardId;
private string _creditCardCode;
private string _description;
}
* Build a class "CreditCard" and then build 3 classes "Visa", "MasterCard"
and "AmericanExpress" all inherited from "CreditCard".
public class CreditCard
{
private int _creditCardId;
private string _creditCardCode;
private string _description;
}
public class Visa : CreditCard
{
}
public class MasterCard : CreditCard
{
}
public class AmericanExpress : CreditCard
{
}
Which way is better and why?
Thanks