Re: Need help: about OOP inheritance/abstract class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Elementary Penguin (singing_at_hare.krishna)
Date: 01/28/05


Date: Fri, 28 Jan 2005 16:56:11 GMT

Tee wrote:

>> Have you ever used the /interface/ keyword though?
> Yes, I know what is it and used it before. Since I can't force a class to
> implements an interface, I don't think this is what I am looking for.
>
>> No, but you can create a class that instantiates the user control in the
>> constructor, or that inherits it, and inherit the interfaces.
> Sorry I am somehow a bit lost in this, I can't figure it out. Can you tell
> me how to instantiates user control in constructor?

I used this trick when I was trying to get an XmlDocument to load at runtime
(static), by instantiating it. Normally, I had to run the .Load method --
but I can't run a method when I declare, I have to declare, then .Load.

So, I created a new class with a constructor that did the load.

In my calling class

CustomXmlDocClass myXml = new CustomXmlDocClass()

Then in the constructor of the instantiated class:

CustomXmlDocClass
{

        public XmlDocument xd;

        CustomXmlDocCalss()
        //the constructor
        {
                XmlDocument _xd = new XmlDocument();
                _xd.Load("whatever.xml");
                xd = _xd;
        }

}

Now myXml is loaded with whatever.xml at run time.

> I think this should be what I need, greatly appreciate if you could
> elaborate on this.
>
>
> Thanks,
> Tee
>
>
>
> "Elementary Penguin" <singing@hare.krishna> wrote in message
> news:uP%Jd.6676$YD5.1145@newsread3.news.pas.earthlink.net...
>> Tee wrote:
>>
>>
>> > Is stub method a keyword?
>>
>> Sorry, bad choice of words.
>>
>> Have you ever used the /interface/ keyword though?
>>
>> You define methods, but just in terms of the input parameters.
>>
>> Then, its up to the inheriting classes to implement. Similar to, but
>> not exactly, to an abstract class.
>>
>> And there's no *default* implementation.
>>
>>
>> > What I am doing is a usercontrol, what I meant "I can't open the
>> > usercontrol in VS designer" is because when it opens up the
>> > form/usercontrol, it actually called it as "new", and abstract class
> can't
>> > be declared as new"
>>
>> No, but you can create a class that instantiates the user control in the
>> constructor, or that inherits it, and inherit the interfaces.
>>
>>
>>
>> >
>> > Thanks.
>> >
>> >
>> > "Elementary Penguin" <singing@hare.krishna> wrote in message
>> > news:RZYJd.6531$YD5.6364@newsread3.news.pas.earthlink.net...
>> >> Tee wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > I have a base usercontrol with a method (blank method, no code), I
> have
>> >> > another few usercontrols that will inherit this base usercontrol,
>> >> > but
> I
>> >> > want to force all the usercontrol that inheriting this base
> usercontrol
>> > to
>> >> > override the method with its own code. How do I do it?
>> >>
>> >> If you are going to /force/ them to override it ( polymorphism ) why
> have
>> > it
>> >> in the first place?
>> >>
>> >> You should define an *interface* with a stub method and force them to
>> >> implement it.
>> >>
>> >> I do this in one of my web service applications. There are two
>> >> interfaces
>> >> and a base abstract class. The interface accounts for methods that
> must
>> >> be implemented in the derived classes, but which have no default
>> >> method in
>> >> the abstract class. So each derived class has one abstract class and
>> >> two interfaces to inherit from.
>> >>
>> >>
>> >> --
>> >> http://texeme.com
>> >> Textcasting Technology
>> >> Incognito Blog
>> >> http://incognito.texeme.com
>> >>
>>
>> --
>> http://texeme.com
>> Textcasting Technology
>> Incognito Blog
>> http://incognito.texeme.com
>>

-- 
Texeme
http://texeme.com


Relevant Pages

  • Re: Need help: about OOP inheritance/abstract class
    ... > constructor, or that inherits it, and inherit the interfaces. ... >> Is stub method a keyword? ...
    (microsoft.public.dotnet.general)
  • Re: A Java "interface" declaration does not allow a constructor to be specified in it ...
    ... > This suggested extension to Java has been discussed in the group before. ... > for the interface could make it impossible to call the constructor for the ... super class ... > onerous restriction than the current restriction on the two interfaces having ...
    (comp.lang.java.programmer)
  • Re: Useful classical inheritance example?
    ... have implicit reference to Object.prototype. ... What are you mean about "parent"? ... constructor: In class-based inheritance, ... constructed inherits through the prototype chain. ...
    (comp.lang.javascript)
  • Re: A Java "interface" declaration does not allow a constructor to be specified in it ...
    ... and thus inherits the method transport from both ... The child class is the one causing the name conflict. ... the conflicting methods in one of the parent classes. ... multiple interfaces with the same method signature can ...
    (comp.lang.java.programmer)
  • Re: Question about inheritance and constructors.
    ... Now, let's say that I have class B that inherits from A. B automagically gets all of the properties and methods of A, but I cannot leverage any of A's contructors without redefining them on B and delegating. ... Public Class DownloadClient ... Public Sub New(ByVal UserName As String) ... inherit the constructor of 'DownloadClient', ...
    (microsoft.public.dotnet.languages.vb)