Click here to Skip to main content
15,888,351 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: C# teamwork coding style Pin
comiscience6-Jan-14 20:19
comiscience6-Jan-14 20:19 
GeneralRe: C# teamwork coding style Pin
Eddy Vluggen7-Jan-14 9:27
professionalEddy Vluggen7-Jan-14 9:27 
GeneralRe: C# teamwork coding style Pin
comiscience7-Jan-14 20:41
comiscience7-Jan-14 20:41 
AnswerRe: C# teamwork coding style Pin
Pete O'Hanlon7-Jan-14 22:46
mvePete O'Hanlon7-Jan-14 22:46 
GeneralRe: C# teamwork coding style Pin
comiscience7-Jan-14 23:02
comiscience7-Jan-14 23:02 
QuestionBase class method access VS. abstract class Method access Pin
netfed4-Jan-14 22:28
netfed4-Jan-14 22:28 
AnswerRe: Base class method access VS. abstract class Method access Pin
Kornfeld Eliyahu Peter5-Jan-14 2:14
professionalKornfeld Eliyahu Peter5-Jan-14 2:14 
GeneralRe: Base class method access VS. abstract class Method access Pin
netfed5-Jan-14 3:01
netfed5-Jan-14 3:01 
Alright. I've managed to cram it in there, the abstract Properties, and I've changed the Whole lot to look a lot more similar With regards to content. Now here is what I got:

C#
// -------- Ordinary class
public class animal1
{
    protected string name1 = "Poultry";
    protected string ssn1 = "Mostly flying creatures";

    public virtual void GetInfo()
    {
        Console.WriteLine("Name1: {0}", name1);
        Console.WriteLine("SSN1: {0}", ssn1);
    }
}
class Seagull1 : animal1
{
    public string id = "ABC567EFG";
    public override void GetInfo()
    {
        // Calling the base class GetInfo method:
        base.GetInfo();
        Console.WriteLine("Specimen ID: {0}", id);
    }
}

// -------abstract class
public abstract class animal2
{
    public abstract string name2 { get; }
    public abstract string ssn2 { get; }
    public abstract void GetInfo();
}
class Seagull2 : animal2
{
    public string id = "ABC567EFG";
    public override string ssn2
    {
        get { return "Mostly flying creatures"; }
    }
    public override string name2
    {
        get { return "Poultry"; }
    }

    public override void GetInfo()
    {
        // Calling the base class GetInfo method:
        Console.WriteLine("Name2: {0}", name2);
        Console.WriteLine("SSN2: {0}", ssn2);
        Console.WriteLine("Specimen ID: {0}", id);
    }
}


The implementation and output follows:

C#
public class implementation
{
 // the constructor
 public implementation()
 {
// This is base class access of the getinfo() method
   Seagull1 E = new Seagull1();
   E.GetInfo();

// The following is abstract class access of the getinfo() method
   Seagull2 A = new Seagull2();
   A.GetInfo();
 }
}


Resulting text output:
Quote:
Name1: Poultry
SSN1: Mostly flying creatures
Specimen ID: ABC567EFG
Name2: Poultry
SSN2: Mostly flying creatures
Specimen ID: ABC567EFG


It seems to me that the use of abstract classes in this case is redundant, and the first track is sufficient, let alone more efficient. I am wondering then when the abstract classes kicks in with their possible advantages?
Could it be, if I introduced the Penguin which is not able to fly, that the flyingability becomes an issue urging the use of abstract classes?

modified 5-Jan-14 9:18am.

AnswerRe: Base class method access VS. abstract class Method access Pin
Kornfeld Eliyahu Peter5-Jan-14 3:17
professionalKornfeld Eliyahu Peter5-Jan-14 3:17 
AnswerRe: Base class method access VS. abstract class Method access Pin
Shameel6-Jan-14 3:53
professionalShameel6-Jan-14 3:53 
GeneralRe: Base class method access VS. abstract class Method access Pin
netfed9-Jan-14 2:49
netfed9-Jan-14 2:49 
GeneralRe: Base class method access VS. abstract class Method access Pin
Richard MacCutchan9-Jan-14 4:43
mveRichard MacCutchan9-Jan-14 4:43 
AnswerRe: Base class method access VS. abstract class Method access Pin
Shameel10-Jan-14 3:36
professionalShameel10-Jan-14 3:36 
GeneralRe: Base class method access VS. abstract class Method access Pin
netfed12-Jan-14 0:51
netfed12-Jan-14 0:51 
GeneralRe: Base class method access VS. abstract class Method access Pin
Ron Beyer12-Jan-14 4:33
professionalRon Beyer12-Jan-14 4:33 
GeneralRe: Base class method access VS. abstract class Method access Pin
netfed12-Jan-14 6:17
netfed12-Jan-14 6:17 
GeneralRe: Base class method access VS. abstract class Method access Pin
Ron Beyer12-Jan-14 6:40
professionalRon Beyer12-Jan-14 6:40 
GeneralRe: Base class method access VS. abstract class Method access Pin
Shameel12-Jan-14 4:54
professionalShameel12-Jan-14 4:54 
AnswerRe: Base class method access VS. abstract class Method access Pin
Keld Ølykke9-Jan-14 14:33
Keld Ølykke9-Jan-14 14:33 
GeneralRe: Base class method access VS. abstract class Method access Pin
netfed12-Jan-14 1:16
netfed12-Jan-14 1:16 
GeneralRe: Base class method access VS. abstract class Method access Pin
Keld Ølykke12-Jan-14 8:06
Keld Ølykke12-Jan-14 8:06 
QuestionImplementation of Loose Coupling Pattern Pin
User 905247816-Dec-13 14:41
User 905247816-Dec-13 14:41 
AnswerRe: Implementation of Loose Coupling Pattern Pin
Antonio Ripa27-Dec-13 2:25
professionalAntonio Ripa27-Dec-13 2:25 
GeneralRe: Implementation of Loose Coupling Pattern Pin
jschell27-Dec-13 12:57
jschell27-Dec-13 12:57 
GeneralRe: Implementation of Loose Coupling Pattern Pin
Kornfeld Eliyahu Peter4-Jan-14 23:13
professionalKornfeld Eliyahu Peter4-Jan-14 23:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.