Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
N

netfed

@netfed
About
Posts
15
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • language
    N netfed

    What programming language is used to create Codeproject Workspaces?

    Workspaces Forum question

  • Invite developers and member
    N netfed

    Fantastic idea this, with an enormous potential I'd say. Although more focused on UI, I started coding something similar a few months back, but now I will follow this one and see if I don't have to make my own. Interesting is it to se how the collaboration on coding is. If there will be some sort of versioning feature, where a team can compare and discuss the code in focus. Great stuff CodeProject! Keep on the good work!

    Workspaces Forum question

  • I would panic.
    N netfed

    Great. Wonder how the ATM machine would be like for the ones speaking Khoisan language. It'll bring a new meaning to the phrase: "Click here ..."

    The Lounge csharp html com

  • I went on..
    N netfed

    I think he lost a few kilos

    The Lounge com tools question

  • I went on..
    N netfed

    Me too, and now my eyebrows are vertical

    The Lounge com tools question

  • Base class method access VS. abstract class Method access
    N netfed

    public class D
    {
    public virtual void DoWork(int i)
    {
    // Original implementation.
    }
    }

    public abstract class E : D
    {
    public abstract override void DoWork(int i);
    }

    public class F : E
    {
    public override void DoWork(int i)
    {
    // New implementation.
    }
    }

    You can't call DoWork in class D from F. Which brought me to a new reason for using abstract classes: an abstract class can force derived classes to provide new method implementations for virtual methods.

    Design and Architecture question visual-studio

  • Base class method access VS. abstract class Method access
    N netfed

    Thank you for the code, although it had to be modified a bit to run, but what do you mean by the following: - (derived class) always call base in overriden virtual method/property? This I do get, and I find it a good OO-realted advice: (abstract class) only declare fields as private. Thanks for the link that lead to this: [^] ... which talks about the usefulness of it all.

    Design and Architecture question visual-studio

  • Base class method access VS. abstract class Method access
    N netfed

    Thanks for that link. The article showed some variation there in the end, that brought in some ideas on how abstract classes could be useful (the IEnumerable). I think I will play With several code blocks and compare the use of them. I will read some books on the subject. I can also now can conclude on of my problems: - abstract classes without any implementations just look like Interfaces - It seems to me that using abstract classes in a small context is shear silliness, but in a larger "code-stretch" they are beneficial, as my second code post and it's answer shows. - A class that inherits from an abstract class cannot access the original implementation of a method

    Design and Architecture question visual-studio

  • Base class method access VS. abstract class Method access
    N netfed

    Well yes. But what would be really cool is, if someone would be willing to take the time, to suggest a new code block, which could show where the abstract track is better. Anyone?

    Design and Architecture question visual-studio

  • Base class method access VS. abstract class Method access
    N netfed

    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:

    // -------- 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:

    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?

    Design and Architecture question visual-studio

  • Base class method access VS. abstract class Method access
    N netfed

    Refering to the following two pair of classes:

    public class Person
    {
    protected string ssn = "444-55-6666";
    protected string name = "John L. Malgraine";

        public virtual void GetInfo()
        {
            Console.WriteLine("Name: {0}", name);
            Console.WriteLine("SSN: {0}", ssn);
        }
    }
    class Employee : Person
    {
        public string id = "ABC567EFG";
        public override void GetInfo()
        {
            // Calling the base class GetInfo method: 
            base.GetInfo();
            Console.WriteLine("Employee ID: {0}", id);
        }
    }
    

    //---------------------------------------------------------
    public abstract class animal
    {
    protected string ssn = "Poultry";
    protected string name = "Mostly flying creatures";

        public abstract void GetInfo();
    }
    class Seagull : animal
    {
        public string id = "ABC567EFG";
        public override void GetInfo()
        {
            // Calling the base class GetInfo method: 
            Console.WriteLine("Name: {0}", name);
            Console.WriteLine("SSN: {0}", ssn);
            Console.WriteLine("Specimen ID: {0}", id);
        }
    }
    

    Implementing them:

    Public class A2Implementation {

    public A2Implementation()
    {
    // This is base class access of the getinfo() method
    Employee E = new Employee();
    E.GetInfo();
    // The following is abstract class access of the getinfo() method
    // animal A = new animal(); // this would be wrong (instantiating it) instead, (if I were to use this) use a derive-keyword on this implementing class
    Seagull A = new Seagull();
    A.GetInfo(); // getinfo() is accessed through the Seagull class
    }

    Question I get the exact same result in the implementation of the two pairs (unclear, albeit intentionally). Now what are the pros and cons of using an abstract definition here (the animal-Seagull track), or what is best; just using ordinary base class Access (the Person-Employee track)? Could I be mistaken in assuming that there is a concordance here.

    Design and Architecture question visual-studio

  • Invitation to a colloquy on Abstract classes
    N netfed

    Anyone with an interest in discussing (here on Code Project or at codeplex) what abstract classes are and how they can be used are hereby invited to Link to page [^] The purpos of this is to compile information from Your posts or find concensus for a proper whitepaper on the subject

    Design and Architecture com

  • Life is tough
    N netfed

    Painters, musicians, and bunch of other artists perform well under the influence of alcohol, programmers do not. Ergo, programming is not art. :rolleyes:

    The Lounge

  • Finally! Fast internet access at work!
    N netfed

    Pure happiness that. I then have to share my sorrow. My download speed is 25kb per second. When it snows I get 14kb or so. This is in a country where the teleco's brag about excellent coverage. What I should get is 384kb/s, but HSDPA is largely overrated when you're more than "two meters" away from the base station. So, a sad story, this one. :)

    The Lounge performance

  • Are we, as Developers, bored?
    N netfed

    Where would you like to place Opera in all this? I would like to see a browser properly adressing the presentation problem, a browser that rendering pages the way we expected them to be. How hard is it just to read the CSS spesification and really TRY to implement it. A great idea would be to build a unified rendering engine. THIS is what McCain and Obama should be concerned about these days. (edited for spelling errors)

    modified on Saturday, March 12, 2011 9:51 PM

    The Lounge csharp c++ database sql-server com
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups