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/Inherit...ter_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>