473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

another inheritance question

I have a class named "Generic" and a second class named "Specific" which
inherits from Generic. I have a Save method in the Generic class. I don't
have an override in the Specific class. If I call Specific.Save, is there a
way for the Generic class's logic to route back to methods of the Specific
class?

Thanks,

Craig Buchanan
Nov 20 '05 #1
4 809
no
a eventual solution is

public mustinherit class generic
protected sub Save(someinfo as object)
....
end save
public mustoverride sub Save()
end class

public class specific
inherits generic
public overrides sub Save()
save(mySpecificExtraInfoObject)
end sub
end class
hope this helps

dominique
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:e3*************@TK2MSFTNGP11.phx.gbl...
I have a class named "Generic" and a second class named "Specific" which
inherits from Generic. I have a Save method in the Generic class. I don't have an override in the Specific class. If I call Specific.Save, is there a way for the Generic class's logic to route back to methods of the Specific
class?

Thanks,

Craig Buchanan

Nov 20 '05 #2
Or you could call

mybase.save

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:u9**************@tk2msftngp13.phx.gbl...
no
a eventual solution is

public mustinherit class generic
protected sub Save(someinfo as object)
...
end save
public mustoverride sub Save()
end class

public class specific
inherits generic
public overrides sub Save()
save(mySpecificExtraInfoObject)
end sub
end class
hope this helps

dominique
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:e3*************@TK2MSFTNGP11.phx.gbl...
I have a class named "Generic" and a second class named "Specific" which
inherits from Generic. I have a Save method in the Generic class. I don't
have an override in the Specific class. If I call Specific.Save, is there a
way for the Generic class's logic to route back to methods of the

Specific class?

Thanks,

Craig Buchanan


Nov 20 '05 #3
if i understand correctly you cannot :-)

in generic.save (mybase.save) he needs info only available in specific
so specific has to pass something to generic...
-> mybase.save("stuff")
or i didn't understand correctly and i'm telling a lot of junk :-)

"CJ Taylor" <no****@blowgoats.com> wrote in message
news:10************@corp.supernews.com...
Or you could call

mybase.save

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:u9**************@tk2msftngp13.phx.gbl...
no
a eventual solution is

public mustinherit class generic
protected sub Save(someinfo as object)
...
end save
public mustoverride sub Save()
end class

public class specific
inherits generic
public overrides sub Save()
save(mySpecificExtraInfoObject)
end sub
end class
hope this helps

dominique
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:e3*************@TK2MSFTNGP11.phx.gbl...
I have a class named "Generic" and a second class named "Specific" which inherits from Generic. I have a Save method in the Generic class. I

don't
have an override in the Specific class. If I call Specific.Save, is there
a
way for the Generic class's logic to route back to methods of the

Specific class?

Thanks,

Craig Buchanan



Nov 20 '05 #4
Craig,
In addition to Dominique's answer:

It sounds like what you want is a Template Method Pattern. (Dominique showed
a variation of a Template Method).

http://www.dofactory.com/Patterns/PatternTemplate.aspx

Another variation of the Template Method is:

Public MustInherit Class Generic

Public Sub Save()
BeforeSave()
' do the save
AfterSave()
End Sub

Protected MustOverride Sub BeforeSave()
Protected MustOverride Sub AfterSave()

End Class

Public Class Specific
Inherits Generic

Protected Overrides Sub BeforeSave
End Sub

Protected Overrides Sub AfterSave
End Sub

End Class

Alternative BeforeSave & AfterSave can be Overridable, allowing Generic to
offer a "default" implementation that Specific can replace if it needs to...

Of course BeforeSave & AfterSave could have parameters or be functions or
properties returning values.

Hope this helps
Jay

"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:e3*************@TK2MSFTNGP11.phx.gbl...
I have a class named "Generic" and a second class named "Specific" which
inherits from Generic. I have a Save method in the Generic class. I don't have an override in the Specific class. If I call Specific.Save, is there a way for the Generic class's logic to route back to methods of the Specific
class?

Thanks,

Craig Buchanan

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: KK | last post by:
Windows Forms Inheritance, Incomplete? I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can be used effectively if the...
2
by: KK | last post by:
** Posting it here cause after couple of days no body responded.** I was playing around with Windows Forms and found out this Forms Inheritance feature. The moment I saw that, I felt this can...
51
by: nospam | last post by:
THIS IS the DOTNETJUNKIES MESSAGE ------------------------- We're Sorry As many of you know we have recently launched SqlJunkies.com. We have overhauled our runtime and will be using it on...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
14
by: Bruno van Dooren | last post by:
Hi all, i am having a problems with inheritance. consider the following: class A { public: A(int i){;} };
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
14
by: Craig Buchanan | last post by:
If I have two custom vb.net classes, where 80% of the properties are alike and there is one method with a matching signature, can i cast between one and the other? do i need to have each class...
5
by: Noah Roberts | last post by:
Is there anything that says that if you virtually inherit from one class you have to virtually inherit from anything you inherit from?
3
by: RSH | last post by:
I have a simple question regarding inheritance in a web form. I have a DropDownList in an aspx form. It is called DropDownList1 I have a class that will be overriding the render event so I...
8
by: RSH | last post by:
Hi, I am working on some general OOP constructs and I was wondering if I could get some guidance. I have an instance where I have a Base Abstract Class, and 4 Derived classes. I now need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.