Home All Groups Group Topic Archive Search About
Author
11 Jan 2006 7:50 AM
Kalim Julia
Public Class RichBigDaddy
   Public Sub PlayPolo()
      Trace.WriteLine("RichBigDaddy::PlayPolo")
   End Sub
End Class
Public Class TrustFundSnob
   Inherits RichBigDaddy

   Public Sub PlayPolo()
      Trace.WriteLine("TrustFundSnob::PlayPolo")
   End Sub
End Class=================================================If I want the
output be :RichBigDaddy::PlayPoloTrustFundSnob::PlayPoloAny sub declaration
method should be added ? (like shadows, overrides, overloads, etc)I've tried
to use them all, but the output is only
Show quoteHide quote
:RichBigDaddy::PlayPoloORTrustFundSnob::PlayPolo

Author
11 Jan 2006 8:50 AM
Pieter
You want it to print the two lines when calling the PlayPolo of the
TrustFundSnob?
Than change it to this:

Public Class TrustFundSnob
   Inherits RichBigDaddy
    Public Sub PlayPolo()
        MyBase.PlayPolo4    '-> ADD THIS LINE
         Trace.WriteLine("TrustFundSnob::PlayPolo")
    End Sub
End Class

I hope this is what you want?


Show quoteHide quote
"Kalim Julia" <kalim.ju***@gmail.com> wrote in message
news:OhT$cPoFGHA.2704@TK2MSFTNGP15.phx.gbl...
> Public Class RichBigDaddy
>   Public Sub PlayPolo()
>      Trace.WriteLine("RichBigDaddy::PlayPolo")
>   End Sub
> End Class
> Public Class TrustFundSnob
>   Inherits RichBigDaddy
>
>   Public Sub PlayPolo()
>      Trace.WriteLine("TrustFundSnob::PlayPolo")
>   End Sub
> End Class=================================================If I want the
> output be :RichBigDaddy::PlayPoloTrustFundSnob::PlayPoloAny sub
> declaration
> method should be added ? (like shadows, overrides, overloads, etc)I've
> tried
> to use them all, but the output is only
> :RichBigDaddy::PlayPoloORTrustFundSnob::PlayPolo
>
>
Author
11 Jan 2006 9:42 AM
Cor Ligthert [MVP]
Kalim,

Is this what you want to do?

\\\\
Public Class RichBigDaddy
    Public Overridable Sub PlayPolo()
        Trace.WriteLine("RichBigDaddy::PlayPolo")
    End Sub
End Class
Public Class TrustFundSnob
    Inherits RichBigDaddy
    Public Overrides Sub PlayPolo()
        MyBase.PlayPolo()
        Trace.WriteLine("TrustFundSnob::PlayPolo")
    End Sub
End Class
///

I hope this helps,

Cor
Author
11 Jan 2006 10:13 AM
Kalim Julia
Any other way instead of using MyBase.PlayPolo() ?

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:ut9pGNpFGHA.3792@TK2MSFTNGP10.phx.gbl...
> Kalim,
>
> Is this what you want to do?
>
> \\\\
> Public Class RichBigDaddy
>     Public Overridable Sub PlayPolo()
>         Trace.WriteLine("RichBigDaddy::PlayPolo")
>     End Sub
> End Class
> Public Class TrustFundSnob
>     Inherits RichBigDaddy
>     Public Overrides Sub PlayPolo()
>         MyBase.PlayPolo()
>         Trace.WriteLine("TrustFundSnob::PlayPolo")
>     End Sub
> End Class
> ///
>
> I hope this helps,
>
> Cor
>
>
Author
11 Jan 2006 10:22 AM
Cor Ligthert [MVP]
> Any other way instead of using MyBase.PlayPolo() ?

Why?


Show quoteHide quote
"Kalim Julia" <kalim.ju***@gmail.com> schreef in bericht
news:ee2PpfpFGHA.1312@TK2MSFTNGP09.phx.gbl...
> Any other way instead of using MyBase.PlayPolo() ?
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:ut9pGNpFGHA.3792@TK2MSFTNGP10.phx.gbl...
>> Kalim,
>>
>> Is this what you want to do?
>>
>> \\\\
>> Public Class RichBigDaddy
>>     Public Overridable Sub PlayPolo()
>>         Trace.WriteLine("RichBigDaddy::PlayPolo")
>>     End Sub
>> End Class
>> Public Class TrustFundSnob
>>     Inherits RichBigDaddy
>>     Public Overrides Sub PlayPolo()
>>         MyBase.PlayPolo()
>>         Trace.WriteLine("TrustFundSnob::PlayPolo")
>>     End Sub
>> End Class
>> ///
>>
>> I hope this helps,
>>
>> Cor
>>
>>
>
>
Author
11 Jan 2006 10:52 AM
Kalim Julia
I design this and hoping that my programmers won't do any mistakes like
forgetting put MyBase.PlayPolo().
I just want to reduce the mistakes (something like trigger or store
procedure in database system).
Why people made it, because they want to reduce problems.


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23aOlQjpFGHA.1676@TK2MSFTNGP09.phx.gbl...
> > Any other way instead of using MyBase.PlayPolo() ?
>
> Why?
>
>
> "Kalim Julia" <kalim.ju***@gmail.com> schreef in bericht
> news:ee2PpfpFGHA.1312@TK2MSFTNGP09.phx.gbl...
> > Any other way instead of using MyBase.PlayPolo() ?
> >
> > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> > news:ut9pGNpFGHA.3792@TK2MSFTNGP10.phx.gbl...
> >> Kalim,
> >>
> >> Is this what you want to do?
> >>
> >> \\\\
> >> Public Class RichBigDaddy
> >>     Public Overridable Sub PlayPolo()
> >>         Trace.WriteLine("RichBigDaddy::PlayPolo")
> >>     End Sub
> >> End Class
> >> Public Class TrustFundSnob
> >>     Inherits RichBigDaddy
> >>     Public Overrides Sub PlayPolo()
> >>         MyBase.PlayPolo()
> >>         Trace.WriteLine("TrustFundSnob::PlayPolo")
> >>     End Sub
> >> End Class
> >> ///
> >>
> >> I hope this helps,
> >>
> >> Cor
> >>
> >>
> >
> >
>
>
Author
11 Jan 2006 11:34 AM
Cor Ligthert [MVP]
As your programmers use that class than that myBase.PlayPolo is in it so
what is the trouble?

Cor
Author
11 Jan 2006 11:54 AM
Armin Zingler
"Kalim Julia" <kalim.ju***@gmail.com> schrieb
> I design this and hoping that my programmers won't do any mistakes
> like forgetting put MyBase.PlayPolo().
> I just want to reduce the mistakes (something like trigger or store
> procedure in database system).
> Why people made it, because they want to reduce problems.


In VB 2005, the IDE automatically inserts mybase.proc if you override a
procedure.


Armin
Author
11 Jan 2006 11:34 AM
Herfried K. Wagner [MVP]
"Kalim Julia" <kalim.ju***@gmail.com> schrieb:
> Any other way instead of using MyBase.PlayPolo() ?

No.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Jan 2006 11:03 PM
alantolan
Sort of....

It depends upon how many levels of inheritance you want / will allow.

If your developers are just going to inherit from it ONCE and you will
ALWAYS want the base functionality to be called then you can try


Public Class RichBigDaddy
    Public Sub PlayPolo()
        Trace.WriteLine("RichBigDaddy::PlayPolo")
         PlayPoloEx()
    End Sub
    Protected Overridable Sub PlayPoloEx()
    End Sub
End Class

Public Class TrustFundSnob
    Inherits RichBigDaddy

    Protected Overrides Sub PlayPoloEx()
        Trace.WriteLine("TrustFundSnob::PlayPolo")
    End Sub

End Class


Your developers implement the nnnEx() version of the function.
If you want to enforce implementing it, then make it MustOverrride in
the base class, else just leave as is.


Dim x as New RichBigDaddy
x.PlayPolo()

=>  "RichBigDaddy::PlayPolo"

Dim y as New TrustFundSnob
y.PlayPolo()

=>  "RichBigDaddy::PlayPolo"
      "TrustFundSnob::PlayPolo"


In more complicated cases - multiple levels of inheritance; want to
invoke the method at each level - I would not swear that one could not
use reflection to invoke each version but I would REALLY advise against
it. The cure would be solution would be worse thant the original
problem

hth,Alan
Author
13 Jan 2006 4:17 PM
Jay B. Harlow [MVP - Outlook]
Alan,
Instead of PlayPoloEx, I would consider calling it PlayPoloCore, as using
Core is one of the "patterns" that the framework uses. For example
Control.Scale calls Control.ScaleCore to do the "heavy lifting".

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformscontrolclassscalecoretopic.asp

I want to say the above "pattern" is in the "Framework Design Guidelines",
however I'm not seeing a specific reference for it in either .NET 1.x or 2.0
Design Guidelines...

I've also used the convention of calling the overridable method DoPlayPolo &
OnPlayPolo...

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


<alanto***@users.com> wrote in message
Show quoteHide quote
news:1137020608.140111.60970@g44g2000cwa.googlegroups.com...
|
|
| Sort of....
|
| It depends upon how many levels of inheritance you want / will allow.
|
| If your developers are just going to inherit from it ONCE and you will
| ALWAYS want the base functionality to be called then you can try
|
|
| Public Class RichBigDaddy
|    Public Sub PlayPolo()
|        Trace.WriteLine("RichBigDaddy::PlayPolo")
|         PlayPoloEx()
|    End Sub
|    Protected Overridable Sub PlayPoloEx()
|    End Sub
| End Class
|
| Public Class TrustFundSnob
|    Inherits RichBigDaddy
|
|    Protected Overrides Sub PlayPoloEx()
|        Trace.WriteLine("TrustFundSnob::PlayPolo")
|    End Sub
|
| End Class
|
|
| Your developers implement the nnnEx() version of the function.
| If you want to enforce implementing it, then make it MustOverrride in
| the base class, else just leave as is.
|
|
| Dim x as New RichBigDaddy
| x.PlayPolo()
|
| =>  "RichBigDaddy::PlayPolo"
|
| Dim y as New TrustFundSnob
| y.PlayPolo()
|
| =>  "RichBigDaddy::PlayPolo"
|      "TrustFundSnob::PlayPolo"
|
|
| In more complicated cases - multiple levels of inheritance; want to
| invoke the method at each level - I would not swear that one could not
| use reflection to invoke each version but I would REALLY advise against
| it. The cure would be solution would be worse thant the original
| problem
|
| hth,Alan
|