以下の2つの例の長所と短所を特定することができません。空派生クラスVs型プロパティ
例1(タイププロパティ):
public abstract class Animal : /* all relevant interfaces*/
{
/*
All necessary implementations
*/
}
Public class Dog : Animal
{
Public string Name {get; set;}
Public Breed Type {get; set;}
/*
All necessary implementations
*/
}
Public Type Breed
{
Bulldog,
Chihuahua,
Labrador,
/*
So on……
This can grow without limitation,
you dno't know how much it will grow into, or
what breed you will have tomorrow e.g BulldogChihuahuaCross,
or BulldogLabradorCross.
*/
}
例2(空の派生クラス):
public abstract class Animal : /* all relevant interfaces*/
{
/*
All necessary implementations
*/
}
Public class Dog : Animal
{
Public string Name {get; set;}
/*
All necessary implementations
*/
}
Public class Bulldog : Dog
{
/* Empty Class */
}
Public class Chihuahua: Dog
{
/* Empty Class */
}
Public class Labrador: Dog
{
/* Empty Class */
}
理想的には私は最高のデザインと高い重どの知っていただきたいと思います編集:
例1では、Dogのインスタンスが作成され、その型がプロパティとして割り当てられます。例2では、その特定の型のインスタンスが作成されます。
私はいくつかのindepth引数、スケーラビリティ、maintainablity、1000種類の品種がある場合はCPUのコスト、実行クエリのコストなどを探しています。
これは実際にはほとんどの人が尋ねることを気にしない非常に良い質問です。私はあなたのために良い答えだと思っているものを持っていますが、今日まではそれを正しく書くための時間がありません。乞うご期待。 –
@ JimL.私はあなたの答えを楽しみにしています。 – Jegan
@ JimL。または、フェルマーが言ったように:私は優れた証拠を持っていますが、ここのマージンはそれを書き留めるにはあまりにも狭いです;-) –