473,799 Members | 2,988 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An absence of IntelliSense in this situation

My turn to ask a question :)

Consider this class hierarchy:

'code starts
Public Class CEventSource
Public Event MyEvent()
End Class

Public Class CBaseEventSourc eContainer
Public WithEvents ces As CEventSource

End Class

Public Class CDerivedEventSo urceContainer
Inherits CBaseEventSourc eContainer

End Class
'code ends

If I position myself in the body of CBaseEventSourc eContainer, the
'object' dropdown at the top left of the code window correctly offers
me the ces object; if I select it, the 'procedures' dropdown at the top
right of the code window then offers me MyEvent, and selecting that
creates this code snippet within CBaseEventSourc eContainer:

Private Sub ces_MyEvent() Handles ces.MyEvent

End Sub

All nice and as expected.

However, if I position myself in the body of
CDerivedEventSo urceContainer - which, like its parent, has a WithEvents
member called ces - I am not offered ces in the 'object' dropdown :( If
I create a Sub line and type "Handles ", at that point I can ctrl+space
and be offered ces, so VS *does* know about it. But it will not create
the skeleton for me.

Not a showstopper I know, but any thoughts?

--
Larry Lard
Replies to group please

Nov 21 '05 #1
2 919
As you say you still have access to the base class event source so there no
actual restrictions to using this variable. However i think VS.Net is
working along the lines of best practise. You will also note that if you
inherit from Stream (or any other base class) you cannot directly WthEvents
their base class variables either. The reason for this I assume is OOP and
the principal of encapsulation.

You have declared your event source variable in public scope in the base
class. This is ugly to begin with. Its best declared private then wrapped
in a property.

If additional processing is required within/internal to the derived class
in addition to base class handling of the event then the base class should
provide an overridable method (possibly protected) that derived classes can
use to respond to the event source. This would obviously be called by the
base class when the event source fired.

If additional processing is required external to the event source container
and the listeners for this event have no way of registering at the primary
event source CEventSource, then an additonal event could be created in one
of the container classes at the most appropriately derived level.

Basically VS.Net will allow us to write poorly designed class libraries but
it doesn;t go out of its way to ensure that we do. Which makes sense from
Microsofts point of view because crap code = crap products = crap platform
perception = diminishing and/or negative growth.

Richard
"Larry Lard" <la*******@hotm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
My turn to ask a question :)

Consider this class hierarchy:

'code starts
Public Class CEventSource
Public Event MyEvent()
End Class

Public Class CBaseEventSourc eContainer
Public WithEvents ces As CEventSource

End Class

Public Class CDerivedEventSo urceContainer
Inherits CBaseEventSourc eContainer

End Class
'code ends

If I position myself in the body of CBaseEventSourc eContainer, the
'object' dropdown at the top left of the code window correctly offers
me the ces object; if I select it, the 'procedures' dropdown at the top
right of the code window then offers me MyEvent, and selecting that
creates this code snippet within CBaseEventSourc eContainer:

Private Sub ces_MyEvent() Handles ces.MyEvent

End Sub

All nice and as expected.

However, if I position myself in the body of
CDerivedEventSo urceContainer - which, like its parent, has a WithEvents
member called ces - I am not offered ces in the 'object' dropdown :( If
I create a Sub line and type "Handles ", at that point I can ctrl+space
and be offered ces, so VS *does* know about it. But it will not create
the skeleton for me.

Not a showstopper I know, but any thoughts?

--
Larry Lard
Replies to group please

Nov 21 '05 #2

Thanks for your thoughts, I find that you are reinforcing what that
little voice inside my head has been telling me about the dubiousness
of my original design :)

Richard Myers wrote:

So would this be better:
Well it depends entirley on use. If derived classes dont need access

to the event source and only need to know if and when it fires an event then you might well drop the property altogether or alternatively scope it at
Protected (if only derived classes need access to it). If its just about handling the event when fired then i'd be more inclined to code it up in the same manner as the framework uses.

Public Class CEventSource
Public Event MyEvent()
End Class

Public Class CBaseEventSourc eContainer
Private WithEvents m_ces As CEventSource

Private Sub MyEventHandler( sender as object, e as eventargs) Handles m_ces.MyEvent
OnMyEventOccura nce(e)
End Sub

Protected Overridable Sub OnMyEventOccura nce(e as eventargs)
' base event handling (possibly nothing at all)
End Sub
End Class

Public Class CDerivedEventSo urceContainer
Inherits CBaseEventSourc eContainer
Protected Overrides Sub OnMyEventOccura nce(e as Eventargs)
MyBase.OnMyEven tOccurance(e)
' specialised event handling
End Sub
End Class

I dont like the style of *handling* internal events or events fired by by base class variables. I think its ugly and a poor way to design an OOP class library. Inheritence and overriding provide a much cleaner interface and is also more consistent with .NET framework.

Richard

'code starts
Public Class CEventSource
Public Event MyEvent()
End Class

Public Class CBaseEventSourc eContainer
Private WithEvents m_ces As CEventSource
Public Property ces As CEventSource 'plus usual property stuff

Protected Sub MyEventHandler( ) Handles m_ces.MyEvent
' base event handling (possibly nothing at all)
End Sub

End Class

Public Class CDerivedEventSo urceContainer
Inherits CBaseEventSourc eContainer

Private Overrides Sub MyEventHandler( ) Handles m_ces.MyEvent
' specialised event handling
End Sub

End Class
'code ends


Richard Myers wrote:
As you say you still have access to the base class event source so
there no
actual restrictions to using this variable. However i think
VS.Net is working along the lines of best practise. You will also note that if you
inherit from Stream (or any other base class) you cannot directly

WthEvents
their base class variables either. The reason for this I assume
is OOP and
the principal of encapsulation.

You have declared your event source variable in public scope in
the base
class. This is ugly to begin with. Its best declared private then

wrapped
in a property.

If additional processing is required within/internal to the
derived class
in addition to base class handling of the event then the base
class should
provide an overridable method (possibly protected) that derived

classes can
use to respond to the event source. This would obviously be
called by the
base class when the event source fired.

If additional processing is required external to the event source

container
and the listeners for this event have no way of registering at
the primary
event source CEventSource, then an additonal event could be
created in one
of the container classes at the most appropriately derived level.

Basically VS.Net will allow us to write poorly designed class

libraries but
it doesn;t go out of its way to ensure that we do. Which makes
sense from
Microsofts point of view because crap code = crap products = crap

platform
perception = diminishing and/or negative growth.

Richard
"Larry Lard" <la*******@hotm ail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
> My turn to ask a question :)
>
> Consider this class hierarchy:
>
> 'code starts
> Public Class CEventSource
> Public Event MyEvent()
> End Class
>
> Public Class CBaseEventSourc eContainer
> Public WithEvents ces As CEventSource
>
> End Class
>
> Public Class CDerivedEventSo urceContainer
> Inherits CBaseEventSourc eContainer
>
> End Class
> 'code ends
>
> If I position myself in the body of CBaseEventSourc eContainer,
the > 'object' dropdown at the top left of the code window correctly

offers
> me the ces object; if I select it, the 'procedures' dropdown at the top
> right of the code window then offers me MyEvent, and selecting
that > creates this code snippet within CBaseEventSourc eContainer:
>
> Private Sub ces_MyEvent() Handles ces.MyEvent
>
> End Sub
>
> All nice and as expected.
>
> However, if I position myself in the body of
> CDerivedEventSo urceContainer - which, like its parent, has a

WithEvents
> member called ces - I am not offered ces in the 'object'

dropdown :( If
> I create a Sub line and type "Handles ", at that point I can

ctrl+space
> and be offered ces, so VS *does* know about it. But it will
not create
> the skeleton for me.
>
> Not a showstopper I know, but any thoughts?
>
> --
> Larry Lard
> Replies to group please
>


Nov 21 '05 #3

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

Similar topics

8
2406
by: andrew.queisser | last post by:
Yesterday I typed in some C++ code that called a function with two ints. Intellisense (auto-complete) helpfully told me that the first formal parameter was called "frontLight" and the second "ringLight". It occurred to me that I'm getting some semantic help here on top of the obvious type safety. It seems to me that the existance of this kind of support is tied to the static typing nature of C++. I've always been interested in the...
1
1780
by: Guy | last post by:
I've written a DLL assembly in C#. I've built the DLL, and reference it from other projects. The assembly contains a single file, containing a single abstract class. This class contains loads of static "helper" methods, as well as a load of nested abstract classes that also contain static "helper" methods. This set up allows me to write code like the following FormMethods.BusinessObjectEvents.HandleIsEditChanged()...
0
976
by: ArtB | last post by:
Hello I am having severe problems with Intellisense. It keeps failing in my project. If I recompile, it works maybe once. If I close and reopen, it may work for a short while. In addition to Intellisense failing Undo sometimes fails with an error message. I am working in C# on a windows application I have tried two fixes mentioned in forums, I checked my device drivers and I deleted all objects. These did not fix the problems ...
0
1104
by: Erik Tamminga | last post by:
Hi Microsoft, I think Intellisense is great, couldn't live without it anymore (well, if I have too ...). But I have one small "problem" with Intellisense. Somehow, I'm hitting Escape all day long! Whenever I browse my code and alter small things (ex. parameters of a method call) Intellisense kicks in and displays me the list of method-variants available. At the same time it doesn't allow me to use my cursorkeys to go one line up or down...
5
1148
by: GD | last post by:
I have a situation where I have renamed a HTML Label from "Label1" to "lblResult2 in an aspx page. However when I write code in the code behind module the control name "Label1" still appears in the intellisense list and I get the error "System.NullReferenceException: Object reference not set to an instance of an object." when I try to access the properties of the lblResults control. I've searched through MSDN for a solution/bugfix for...
2
14829
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but for some it just suddenly stopped working. After a build it'll work maybe once or twice, then stop. I've tried repairing my installation of Visual Studio 2003 but that didn't help. Is Microsoft working on a fix for this, or is there something...
12
4838
by: Peteroid | last post by:
I was creating my application just fine for the last 3 weeks or so. Then, starting this morning, IntelliSense seems to be having problems. It goes into a locked 'Updating IntelliSense..." mode. When this happens its time to close VS C++.NET, which can only be done via the Windows Task Manager. I tried repairing C++. It did seem to help, but the problem is back a few hours later. I will try creating a new project, copy over source files,...
4
5051
by: David C | last post by:
This coincides with installing third party software from Infragistics (infragistics.com), and running their utility for the tool tab. Intellise no longer works. I have done uninstalling and re-installing Visual Studio.NET 2003. Has not helped. I cannot get intellisense to work. Any help will be greatly appreciated. *** Sent via Developersdex http://www.developersdex.com ***
5
3473
by: dk60 | last post by:
I am using visual C++ .NET 2005 for programming in C++. despite the fact that my project contains a VC++ intellisense database, intellisense does not work. What could go wrong. IN the same framework, if I program in C# intellisense works just fine. Thanks
0
9686
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
10475
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
10250
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...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
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
6805
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();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.