473,795 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritance and Shared Methods

1. I have a Base class that has a certain amount of functionality.
2. Then I have a CodeSmith generated class that inherits from the Base class
and adds functionality.
3. Since I want to be able to re-generate the classes on level 2 I have a
3rd level that inherits from them and implements specific hand coded
methods.
4. My colleague asked me to create a 4th level class that inherits the 3rd
level class so he can write custom functionality that overrides the "plain"
functionality at all levels above it.

I have 1-3 implemented as Shared methods.
To me, this enables simpler UI code.

For example:
strSQL = Level3ClassName .Select

In this way I do not need to instantiate an instance of the class I just use
the shared methods in levels 1-3.

=============== =============== =============== ==============
My problem (other than being new and not really understanding this well
enough yet <g> )
is I don't know how to implement Level 4 in a way that allows me to use
Shared methods in levels1-3 and yet Override them in Level 4.

Is it not possible?
=============== =============== =============== =============== ==

If I have to change Levels 1-3 what would you recommend?

=============== =============== =============== ===

Sample code:

Level 1
Public MustInherit Class Base

Public Shared Function DoSomething(ByV al Source As String) As String

End Function
=============== =============== =============== ===
Level 2
Public MustInherit Class GeneratedStuff

Inherits Base

Public Shared Function DoSomethingElse (ByVal Source As String) As String

End Function
=============== =============== =============== ===
Level 3
Public MustInherit Class HandCodedStuff

Inherits GeneratedStuff

Public Shared Function IWroteThis(ByVa l Source As String) As String

End Function
=============== =============== =============== ===
Level 4 (implements same functionality as Level 3 but also allows customized
changes by overriding methods or creating new ones that are specific to a
single client. Level 3 functionality is for all clients.)
Public MustInherit Class FinalLevel

Inherits HandCodedStuff

Overrides Function DoSomethingElse (ByVal Source As String) As String

End Function

Thanks for any advice!
--
Joe Fallon


Nov 20 '05
33 3501
Cor
Please
Nov 20 '05 #11
Good morning Herfried,

Joe gives reasons for wanting to use Shared methods. You may have chosen
to ignore them. The Singleton pattern, while suitable for situations like
this, means that Joe wouldn't continue to enjoy the benefits of avoidiug
object instances and the like.

Using Shadows is a single-word solution. It allows Joe to do exactly what
he asked.

Using the Singleton Pattern takes him into a different ball park. It would
have its own benefits, of course, but learning and implementing it means a
short diversion for Joe.

I hope that Joe learns the Singleton Pattern and continues to learn many
more Design Patterns. But whether he chooses to do so now or uses Shadows now
and learns more OOP later is his choice.

If you fail to see sense in my solution, I suggest that you study a bit
more.

Regards,
Fergus

ps. I was not aware that I had been corrected by anybody. To which post would
you like me to respond with a thank you?
Nov 20 '05 #12
Fergus,
I saw the sense in your suggestion ;-)

And as I stated to Scott, it may be what Joe needs.

Note there are ways to structure the Singleton to have an instance & still
present Shared methods to other developers. One of the easiest ways is to
use an inner class. Where the shared methods call methods on an instance of
a inner class object. I did not present them to Joe as I did not want to
scare him too much.

Jay

"Fergus Cooney" <fi*****@post.c om> wrote in message
news:ur******** *****@TK2MSFTNG P12.phx.gbl...
Good morning Herfried,

Joe gives reasons for wanting to use Shared methods. You may have chosen to ignore them. The Singleton pattern, while suitable for situations like
this, means that Joe wouldn't continue to enjoy the benefits of avoidiug
object instances and the like.

Using Shadows is a single-word solution. It allows Joe to do exactly what he asked.

Using the Singleton Pattern takes him into a different ball park. It would have its own benefits, of course, but learning and implementing it means a
short diversion for Joe.

I hope that Joe learns the Singleton Pattern and continues to learn many more Design Patterns. But whether he chooses to do so now or uses Shadows now and learns more OOP later is his choice.

If you fail to see sense in my solution, I suggest that you study a bit more.

Regards,
Fergus

ps. I was not aware that I had been corrected by anybody. To which post would you like me to respond with a thank you?

Nov 20 '05 #13
* "Cor" <no*@non.com> scripsit:
Please


Did you forget to type some text to this post?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #14
Cor
Herfried,
Please

No maybe a sign
?
Cor
Nov 20 '05 #15
Cor
> If you fail to see sense in my solution, I suggest that you study a
bit
more.

Please?
Nov 20 '05 #16
Cor
Herfried and Fergus,

Please you both are working for the quality of this newsgroup. And we all
regulars are proud about it that we have such a good newsgroup, without
silly tic tac's .

Sometimes it gives some hard fights to show our ideas and to tell how hard
we stand for it.

But drink after the fight a beer or a wine and say. We both lost and won but
we learned a lot from it.

So let us be proud again.

Cor
Nov 20 '05 #17
* "Cor" <no*@non.com> scripsit:
If you fail to see sense in my solution, I suggest that you study a

bit
more.

Please?


I won't reply to an unqalified post like that written by Fergus. Fergus
is not able to cope with criticism. He always wants to have the last
word... I try to ignore him in future because he doesn't want to be
part of the community. He has chosen to stand outside it.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #18
* "Cor" <no*@non.com> scripsit:
Please

No maybe a sign
?


It seems that you don't want to hear the facts.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #19
* "Cor" <no*@non.com> scripsit:
Please you both are working for the quality of this newsgroup. And we all
regulars are proud about it that we have such a good newsgroup, without
silly tic tac's .

Sometimes it gives some hard fights to show our ideas and to tell how hard
we stand for it.

But drink after the fight a beer or a wine and say. We both lost and won but
we learned a lot from it.


I am waiting for Fergus to come back. Now he preferrs to stand outside
the community. I am sure he knows that he is welcome, but he needs some
more time to change his habits.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #20

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

Similar topics

20
10087
by: km | last post by:
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in advance for enlightment ... here's the snippet #!/usr/bin/python
3
1703
by: marv | last post by:
If I have abstract base classes like these: //--------- class IBase { public: virtual void Action(void) = 0; };
14
12921
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at all obvious in VBA which lacks inheritance. I'm trying the explanation again now. I often find cases where a limited form of inheritance would eliminate duplication my code that seems impossible to eliminate otherwise. I'm getting very...
5
2050
by: Invalidlastname | last post by:
Hi, I just read the pattern "Design and Implementation Guidelines for Web Clients" from MSDN. Here is my question. In chapter 3, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp , the article mentions using page inheritance to maintain common page layout. We currently use page inheritance approach to segment the function areas. In each function area, there is a base page to provide the common...
10
1250
by: John | last post by:
Hi, How can I achieve that a childs constructor is only callable from it's parent? Must I declare the class Private within A? Thanks in Advance Public MustInherit Class A Protected Sub New()
2
1204
by: rodchar | last post by:
hey all, i have a MustInherit class and a derived class. is it possible to have a shared method in the base class and use it? Note: this is not working for me but just going to explain. i have a base class that has a shared function that returns a connection string for a datasource. is there a way for the derived class to use that? when i try me.connStr it says i have to instantiate it.
5
1096
by: AWesner | last post by:
I've been working on a project to help myself better understand how inherited classes work. I think I've learned more about classes by doing this than any other effort I've made. I've tried to create a simple problem by creating a class named TestThis that inherits System.Windows.Forms.Form and then adding one shared procedure to this. I set the form to inherit TestThis instead and it gets everything plus the one procedure that I've...
6
1887
by: burningodzilla | last post by:
Hi all - I'm preparing to dive in to more complex application development using javascript, and among other things, I'm having a hard time wrapping my head around an issues regarding "inheritance" using the prototype property. I realize there are no classes in JS, that code therefore lives in objects instead of class definitions, and that "inheritance" must be achieved prototypically and not classically. That said, on with the code. Say I...
8
1312
by: tharringtonan | last post by:
I am compiling the following code, main.cpp, as follows: gcc main.cpp I get the following compile error: main.cpp: In function `int main()': main.cpp:28: no matching function for call to `CPolygon::area()' The code is listed below:
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7541
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.