473,396 Members | 2,036 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,396 software developers and data experts.

OOP: True hierarchical parent/child class interaction? Namespaces?

Hello,

I'm coming from a PHP background and am working on a large-scale VB.NET
project. One of the cornerstones of this project is a reusable form
class, to standardize our web forms.

My goal is to have a true hierarchical parent form class with child
form element classes. The programmatic code would be something like
this, ideally (sorry about the lame names, but it's just for demo):

MyForm = New SuperFormClass()
MyFormRadio1 = New SuperFormClass.RadioButton()
MyFormRadio1.Label = "Please select something."
MyFormRadio1.Id = "radio_blah"
MyFormRadio1.AppendToParent()
MyForm.Render()

So I want the child form element to work extensively with *that
particular instance* of the parent form class. I can't make a
RadioButton without a SuperFormClass, so I want SuperFormClass to act
as a container - with its own properties and methods.

I need to know the most practical way to pull this off. My research so
far has steered me towards nested classes, but I'm now investigating
namespaces. Most of the issue right now is syntax; I know how I'd code
this in PHP, for sure, and need to essentially translate it. I also of
course need to know if VB.NET will support this type of structure!

If anyone can help I'd appreciate it - and I'd be happy to answer more
specific questions. Thanks.

- Paul

Nov 21 '05 #1
7 2518
Hi Paul,

If I don't understand your requirement or am making a 'stupid' suggestion
then just ignore me and I'll go away! :-)

With vb.net (as with other oop languages) you can create a default class, as
in your SuperFormClass. You can then create other classes based on this
class by using the inherits keyword. By inheriting a class you can (or will)
have the functionality of the base 'inherited' class as well as being able
to add additional code (and objects) to the new class.

When you create a new form, by default it inherits from
system.windows.forms.form. Therefore your code will show:-

Inherits System.Windows.Forms.Form

Change this to Inherits SuperFormClass

Does this help?

Good luck, Phil

"Paul" <pa*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hello,

I'm coming from a PHP background and am working on a large-scale VB.NET
project. One of the cornerstones of this project is a reusable form
class, to standardize our web forms.

My goal is to have a true hierarchical parent form class with child
form element classes. The programmatic code would be something like
this, ideally (sorry about the lame names, but it's just for demo):

MyForm = New SuperFormClass()
MyFormRadio1 = New SuperFormClass.RadioButton()
MyFormRadio1.Label = "Please select something."
MyFormRadio1.Id = "radio_blah"
MyFormRadio1.AppendToParent()
MyForm.Render()

So I want the child form element to work extensively with *that
particular instance* of the parent form class. I can't make a
RadioButton without a SuperFormClass, so I want SuperFormClass to act
as a container - with its own properties and methods.

I need to know the most practical way to pull this off. My research so
far has steered me towards nested classes, but I'm now investigating
namespaces. Most of the issue right now is syntax; I know how I'd code
this in PHP, for sure, and need to essentially translate it. I also of
course need to know if VB.NET will support this type of structure!

If anyone can help I'd appreciate it - and I'd be happy to answer more
specific questions. Thanks.

- Paul

Nov 21 '05 #2
Thanks, Phil.

This is a web form, so I'm not working with System.Windows.Forms.Form
at all. What I'm doing in the interim here is using nested classes
(which may change later), and having all of the form element classes
inherit SuperFormClass - pretty much per your recommendation.

The only downside I can see is that I can also go ahead and declare new
instances of those form elements without declaring a new instance of
the SuperFormClass. Thus, I think my question has shifted from the
above to, "How can I restrict children to require the parent to be
declared, first?"

- Paul

Nov 21 '05 #3
I'm thinking that I'm getting out of my depth but, if I'm on the right lines
then you need to create an interface for your elements.

Rgds, Phil
"Paul" <pa*********@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Thanks, Phil.

This is a web form, so I'm not working with System.Windows.Forms.Form
at all. What I'm doing in the interim here is using nested classes
(which may change later), and having all of the form element classes
inherit SuperFormClass - pretty much per your recommendation.

The only downside I can see is that I can also go ahead and declare new
instances of those form elements without declaring a new instance of
the SuperFormClass. Thus, I think my question has shifted from the
above to, "How can I restrict children to require the parent to be
declared, first?"

- Paul

Nov 21 '05 #4
Paul,

I have never seen the posibilities to use an inherited 'form' in aspnet.
(a Webform exist from a template in html and the so called code behind)

Try to use as less forms as necessary in ASPNET. A user is always
communicationg with one form at a time with the server. Simple hiding of
panels gives much more performance and makes your life easier.

However you can of course create your template forms.

Another thing is that ASPNET designing will dramaticly change with the
version 2.0.

We where not able to use an Iframe until that we saw a simple message from
Terry Burns (OHM) in another newsgroup how to do that. Still we are not
lucky because we needs to much access to use it. AFAIK will the masterpage
in 2.0 implements this.

This is our website by the way.
http://www.windowsformsdatagridhelp.com/default.aspx

From which will probably change the look completly short after the official
release of Net 2.0

I hope that this gives some information.

Cor


"Paul" <pa*********@gmail.com> schreef in bericht
news:11*********************@g14g2000cwa.googlegro ups.com...
Hello,

I'm coming from a PHP background and am working on a large-scale VB.NET
project. One of the cornerstones of this project is a reusable form
class, to standardize our web forms.

My goal is to have a true hierarchical parent form class with child
form element classes. The programmatic code would be something like
this, ideally (sorry about the lame names, but it's just for demo):

MyForm = New SuperFormClass()
MyFormRadio1 = New SuperFormClass.RadioButton()
MyFormRadio1.Label = "Please select something."
MyFormRadio1.Id = "radio_blah"
MyFormRadio1.AppendToParent()
MyForm.Render()

So I want the child form element to work extensively with *that
particular instance* of the parent form class. I can't make a
RadioButton without a SuperFormClass, so I want SuperFormClass to act
as a container - with its own properties and methods.

I need to know the most practical way to pull this off. My research so
far has steered me towards nested classes, but I'm now investigating
namespaces. Most of the issue right now is syntax; I know how I'd code
this in PHP, for sure, and need to essentially translate it. I also of
course need to know if VB.NET will support this type of structure!

If anyone can help I'd appreciate it - and I'd be happy to answer more
specific questions. Thanks.

- Paul

Nov 21 '05 #5
"Paul" <pa*********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
So I want the child form element to work extensively with *that
particular instance* of the parent form class. I can't make a
RadioButton without a SuperFormClass, so I want SuperFormClass
to act as a container - with its own properties and methods.


Change the Access Specifiers for Controls' Constructors to be Friend
(only your Assembly can create them) and add Public Functions to the
SuperFormClass to create and return you an instance of each Control.

Class SuperForm
Protected Function AddRadioButton() as CustomRadioButton

Class CustomRadioButton
Friend Sub New( ByVal oaParent as SuperForm )

The only down-side to this is that the IDE will insist on having a niladic,
[probably] Public Constructor before you can Design the Control.

HTH,
Phill W.
Nov 21 '05 #6
Heh... I thought I had a handle on this, and now I'm not sure about any
of it.

When it gets distilled, what I ultimately want (or believe I want!) is
an object that can have subobjects. Those subobjects shouldn't be able
to be created without the containing object - but, more importantly - I
should be able to create them programmatically, as in my root post on
this thread.

I did spot an error in my original post, too, which might be leading to
some of the confusion. Here is the end goal in code.
Paul Aug 19, 10:11 am show options
Newsgroups: microsoft.public.dotnet.languages.vb
From: "Paul" <paulmcal...@gmail.com> - Find messages by this author
Date: 19 Aug 2005 08:11:33 -0700
Local: Fri, Aug 19 2005 10:11 am
Subject: OOP: True hierarchical parent/child class interaction?
Namespaces?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Hello,

I'm coming from a PHP background and am working on a large-scale VB.NET
project. One of the cornerstones of this project is a reusable form
class, to standardize our web forms.

My goal is to have a true hierarchical parent form class with child
form element classes. The programmatic code would be something like
this, ideally (sorry about the lame names, but it's just for demo):

MyForm = New SuperFormClass()
MyFormRadio1 = New MyForm.RadioButton()
MyFormRadio1.Label = "Please select something."
MyFormRadio1.Id = "radio_blah"
MyFormRadio1.AppendToParent()
MyForm.Render()

Note that when I declare MyFormRadio1, I'm calling for a new
RadioButton under MyForm - not SuperFormClass. This makes sense to me
logically.

Now, if anyone feels I'm barking up the wrong tree that's quite fine
and I'm open to alternatives. As I said before, the goal is to have a
bunch of little subobjects that can amass into one big object.

- Paul

Nov 21 '05 #7
.... and Google Groups seemed to barf on my message. Sorry about that.
Here's the whole thing once again:

Heh... I thought I had a handle on this, and now I'm not sure about any
of it.

When it gets distilled, what I ultimately want (or believe I want!) is
an object that can have subobjects. Those subobjects shouldn't be able
to be created without the containing object - but, more importantly - I
should be able to create them programmatically, as in my root post on
this thread.

I did spot an error in my original post, too, which might be leading to
some of the confusion. Here is the end goal in code.

MyForm = New SuperFormClass()
MyFormRadio1 = New MyForm.RadioButton() ' note this line is updated
MyFormRadio1.Label = "Please select something."
MyFormRadio1.Id = "radio_blah"
MyFormRadio1.AppendToParent()
MyForm.Render()

Note that when I declare MyFormRadio1, I'm calling for a new
RadioButton under MyForm - not SuperFormClass. This makes sense to me
logically.

Now, if anyone feels I'm barking up the wrong tree that's quite fine
and I'm open to alternatives. As I said before, the goal is to have a
bunch of little subobjects that can amass into one big object.

- Paul

Nov 21 '05 #8

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

Similar topics

3
by: Ksenia Marasanova | last post by:
I get this kind of list from a database. (The tuple structure is: id, name, parent_id) I would like to transfer it (in Python) into a tree structure. I don't care much about format, as long...
7
by: artifact | last post by:
Can anyone tell me how to access a variable in a parent class from within a nested class? Note: this snippet is only to illustrate my problem... I realize there's no need to get at the parent name...
6
by: Bharat Sharma | last post by:
Hello All Wise Persons. I don't know wheather my question is okay or i need to revisit my OOP fundamentals. AS we have read till now in OOP that Every Parent Class can see and execute the...
7
by: | last post by:
Hi all I have a class Parent, and two child classes class Child1 and class Child2 derived from Parent class. In Parent class there is a method that will instantiate child classes based on the...
1
by: Dean L. Howen | last post by:
Ex: I have 2 classes like this: class Parent { private string msg; public string Message { get { return this.msg;
11
by: John M. Gabriele | last post by:
Consider the following: #!/usr/bin/python #----------------------------------------------------------------- class Grand_parent( object ): def speak( self ): print 'Grand_parent.speak()'...
2
by: Nicholas Sherlock | last post by:
Hey all, I wrote a class to represent a node in a site navigation tree which contains methods for building the tree from the database. I also wrote some routines to print out the whole tree,...
12
by: Peter Cranz | last post by:
hello, I've got the following problem: I have a construct similar like this: namespace A { class X {
2
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hi misters, I need to implement Hierarchical DropDownList , like this Option Parent 1 Option Child 1 Option Child 2 Option Parent 2 Option Child 1 Option Child 2
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.