|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
InheritancePublic 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 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 > > 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 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 > > > 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 >> >> > > 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 > >> > >> > > > > > > As your programmers use that class than that myBase.PlayPolo is in it so
what is the trouble? Cor "Kalim Julia" <kalim.ju***@gmail.com> schrieb In VB 2005, the IDE automatically inserts mybase.proc if you override a > 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. procedure. Armin "Kalim Julia" <kalim.ju***@gmail.com> schrieb: No.> Any other way instead of using MyBase.PlayPolo() ? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> 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 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... -- Show quoteHide quoteHope this helps Jay [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net <alanto***@users.com> wrote in message 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 |
Re-post, Help really needed here ! Dataview binded to Textbox for edits, I can't save the change.
What happened to the Class view in VS2005? Drag and Drop to SysTray ? array in dataset VB 2005 - How to hook into Windows to intercept all mouse events? Hide Window form (top most) Handling Events in VB.Net VB.Net Web Service uint32 conversion on win32_pingstatus database records into an array |
|||||||||||||||||||||||