Jay
Fri May 12 07:27:52 CDT 2006
Paul,
You are free to introduce your own partial classes. See partial in VB or C#.
Of course like any language feature it is easy to abuse. As Kevin suggests,
just because you can abuse something doesn't mean its bad. Look at multiple
inheritance in the languages that support it, its been known to be over used
& abused. That doesn't mean that MI is bad where you should use...
In fact they (partial classes) are rather useful in typed datasets, VB My
Settings, Resources... Any generated class that you want to add code to.
Even non-generated classes they can be useful for organization reasons:
I use them to separate nested classes into their own files.
' SomeCollection.vb
Public Class SomeCollection
...
End Class
' SomeCollection.Enumerator.vb
Partial Public Class SomeCollection
Private Class Enumerator
...
End Class
End Class
I also use them to separate out interface implementations that are required
in a specific class.
I've used them in VSTO projects to help organize code.
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Paul" <nonone@noone.com> wrote in message
news:%232k6TuPdGHA.4892@TK2MSFTNGP02.phx.gbl...
| What I tend to dislike about it (well more the concept) is that it seems
to
| have only been included to work with Visual Studio! I don't think anything
| should be included in a language just to make the editor work (or work
| better / worse depending upon your opinion)
|
| - Paul.
|
| "oshea00" <oshea00@discussions.microsoft.com> wrote in message
| news:5D06C446-F90D-4304-93BB-BE7BA7834354@microsoft.com...
| > Thanks Barry. The problem with the solution is that it's now a language
| > feature that can be used for other purposes than hiding machine
generated
| > code. It creates more problems than the one it was intended to solve.
| >
| > The machine generated code could have been placed in a separate class
| > (where
| > the private machine generated methods would have relevance) and included
| > as a
| > member in the "user friendly" class representing the Form.
| >
| > So, there would be one declaration in the user friendly class that could
| > be
| > accidentally deleted - a problem easily fixed by adding a check at build
| > time
| > that could replace the missing line or provide a build error message.
But
| > not
| > much more than that could be done unless the coder wanted to track down
| > the
| > generated class file and make changes to it directly.
| >
| > Well, even with the partial class solution, nothing prevents the coder
| > from
| > editing the generated partial class file. Using the more OO approach
| > above
| > wouldn't prevent the coder from editing the generated class either - at
| > least
| > it doesn't require a language spec change on top of everything else.
| >
| > See what I mean? The "solution" doesn't even solve the problem better
| > than
| > using a more OO approach already supported by the language.
| >
| > That's what I'm whining about.
| >
| > "Barry Kelly" wrote:
| >
| >> oshea00 <oshea00@discussions.microsoft.com> wrote:
| >>
| >> > Then I run across this partial class feature. What a mind bending
| >> > stupid
| >> > idea. This isn't an object oriented concept at all - it's very much
| >> > akin to
| >> > using a preprocessor to insert code.
| >>
| >> It's totally about hiding the code generated by machines, it isn't
| >> really for human use. One problem with using inheritance for this
| >> specific purpose is that the human driving the process may want some
| >> generated members may be private, and thus they wouldn't be accessible
| >> using other techniques.
| >>
| >> -- Barry
| >>
|
|