By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 925 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

Class in a Class

P: n/a
What are the advantages of defining a class as part of another class
definition (nesting classes)?
Nov 21 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Mainly scope and tidyness. Some classes dont really belong anywhere else.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?

Nov 21 '05 #2

P: n/a
Scott,
I will nest one class inside another when the nested class is an
implementation detail of the outer class.

For example, the Node class of a LinkedList class. The Node class holds the
actual "links" in the linked list.

Public Class LinkedList

Private Class Node
Public Next As Node
Public Previous As Node
Public Data As Object
End Class

...

End Class

The various methods of LinkedList, such as Add, creates a new Node class and
adds the data to it. The Node class contains the previous & next references
to the other nodes in the list.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?

Nov 21 '05 #3

P: n/a
* "Scott M." <s-***@nospam.nospam> scripsit:
What are the advantages of defining a class as part of another class
definition (nesting classes)?


The "advantages" depend on the modifier of the nested class and its
constructor. I suggest to take a look at where nested classes are used
inside the .NET Framework.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4

P: n/a
If the nested class is small and used only by the enclosing class - if it
makes sense - and - If the 2 classes are tightly bound
-and- The nested class is not needed by other classes.
less source files

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004
Nov 21 '05 #5

P: n/a
Why not just make a strongly type collection that holds only "Nodes"?
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OR*************@TK2MSFTNGP11.phx.gbl...
Scott,
I will nest one class inside another when the nested class is an
implementation detail of the outer class.

For example, the Node class of a LinkedList class. The Node class holds
the
actual "links" in the linked list.

Public Class LinkedList

Private Class Node
Public Next As Node
Public Previous As Node
Public Data As Object
End Class

...

End Class

The various methods of LinkedList, such as Add, creates a new Node class
and
adds the data to it. The Node class contains the previous & next
references
to the other nodes in the list.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?


Nov 21 '05 #6

P: n/a
Where might those nested classes be in the .NET Framework? How would I find
them?
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
* "Scott M." <s-***@nospam.nospam> scripsit:
What are the advantages of defining a class as part of another class
definition (nesting classes)?


The "advantages" depend on the modifier of the nested class and its
constructor. I suggest to take a look at where nested classes are used
inside the .NET Framework.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7

P: n/a
Why would there be less source files since non-nested classes can be written
into one source module?
"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:m%**************@bignews1.bellsouth.net...
If the nested class is small and used only by the enclosing class - if it
makes sense - and - If the 2 classes are tightly bound
-and- The nested class is not needed by other classes.
less source files

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 7/29/2004

Nov 21 '05 #8

P: n/a
Scott,
Why not just make a strongly type collection that holds only "Nodes"? Because a strongly typed collection of Nodes is NOT a LinkedList! (CS 101)

First consider that you have a Widget class. You could create:
- an array (either an array or ArrayList) of Widgets
- a dictionary (HashTable) of Widgets
- a linked list of Widgets
- a strongly typed collection of Widgets (CollectionBase)
- a strongly typed dictionary of Widgets (DictionaryBase)
- a strongly typed linked list of Widgets

The above list excludes the fact there are binary trees, balanced trees,
graphs, and other "collections" that could hold & organize Widgets. It also
avoids the fact that you could have a keyed linked list or a non-keyed
linked list.

Within .NET most people create strongly typed collections with
CollectionBase (which is based on an ArrayList aka an Array) or
DictionaryBase (which is based on an Hashtable aka a dictionary). I hope you
remember that a LinkedList has performance characteristics that are
different then an array or a dictionary, meaning that a linked list may be
better in some cases. For example inserting into a linked listed is normally
faster then inserting into an array, while searching a sorted array (binary
search) is normally faster then searching a linked list (linear search).

Further you could have a single linked list or a double linked list.

Implementing LinkedList with a private Node class means that you do not need
to add Previous & Next fields to the Widget class itself, allowing your
LinkedList class to be reused for Wingdings in addition to Widgets. You
could even design LinkedList to be a base class, ala CollectionBase,
allowing you to create strongly typed linked lists!

When you are implementing the linted list of Widgets, you would use the Node
class to hold each Widget linking it to the next Widget. Only the Linked
List class itself needs to know about the Node class itself, hence you nest
it inside of LinkedList.

By hiding the details of Node within LinkedList you as a consumer of the
LinkedList only need to worry about adding, removing, inserting, and
indexing Widget objects, as you don't really care or need to know that a
Node object is how your Widgets themselves are organized internally to the
LinkedList, as Node is an implementation detail!

Note .NET has System.Collections.Specialized.ListDictionary &
System.Collections.Specialized.HybridDictionary that offer LinkedList
functionality. I use HybridDictionary in a few places where I need the
performance of a linked list for small lists, and the performance of a
hashtable for longer lists. HybridDictionary internally changes from a
ListDictionary to a Hashtable based on the number of elements in the
HybridDictionary.

System.Collections.Specialized.NameObjectCollectio nBase.KeysCollection is an
example of a nested class, as KeysCollection is tied closes to
NameObjectCollectionBase, yet is publicly usable.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl... Why not just make a strongly type collection that holds only "Nodes"?
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OR*************@TK2MSFTNGP11.phx.gbl...
Scott,
I will nest one class inside another when the nested class is an
implementation detail of the outer class.

For example, the Node class of a LinkedList class. The Node class holds
the
actual "links" in the linked list.

Public Class LinkedList

Private Class Node
Public Next As Node
Public Previous As Node
Public Data As Object
End Class

...

End Class

The various methods of LinkedList, such as Add, creates a new Node class
and
adds the data to it. The Node class contains the previous & next
references
to the other nodes in the list.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OC*************@TK2MSFTNGP11.phx.gbl...
What are the advantages of defining a class as part of another class
definition (nesting classes)?



Nov 21 '05 #9

P: n/a

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...
Scott,
Why not just make a strongly type collection that holds only "Nodes"? Because a strongly typed collection of Nodes is NOT a LinkedList! (CS 101)


Ok Jay...breathe a little buddy!

So, would it be fair to say that nested classes are for very specific
situations and not extremely mainstream?

First consider that you have a Widget class. You could create:
- an array (either an array or ArrayList) of Widgets
- a dictionary (HashTable) of Widgets
- a linked list of Widgets
- a strongly typed collection of Widgets (CollectionBase)
- a strongly typed dictionary of Widgets (DictionaryBase)
- a strongly typed linked list of Widgets

The above list excludes the fact there are binary trees, balanced trees,
graphs, and other "collections" that could hold & organize Widgets. It
also
avoids the fact that you could have a keyed linked list or a non-keyed
linked list.

Within .NET most people create strongly typed collections with
CollectionBase (which is based on an ArrayList aka an Array) or
DictionaryBase (which is based on an Hashtable aka a dictionary). I hope
you
remember that a LinkedList has performance characteristics that are
different then an array or a dictionary, meaning that a linked list may be
better in some cases. For example inserting into a linked listed is
normally
faster then inserting into an array, while searching a sorted array
(binary
search) is normally faster then searching a linked list (linear search).

Further you could have a single linked list or a double linked list.

Implementing LinkedList with a private Node class means that you do not
need
to add Previous & Next fields to the Widget class itself, allowing your
LinkedList class to be reused for Wingdings in addition to Widgets. You
could even design LinkedList to be a base class, ala CollectionBase,
allowing you to create strongly typed linked lists!

When you are implementing the linted list of Widgets, you would use the
Node
class to hold each Widget linking it to the next Widget. Only the Linked
List class itself needs to know about the Node class itself, hence you
nest
it inside of LinkedList.

By hiding the details of Node within LinkedList you as a consumer of the
LinkedList only need to worry about adding, removing, inserting, and
indexing Widget objects, as you don't really care or need to know that a
Node object is how your Widgets themselves are organized internally to the
LinkedList, as Node is an implementation detail!

Note .NET has System.Collections.Specialized.ListDictionary &
System.Collections.Specialized.HybridDictionary that offer LinkedList
functionality. I use HybridDictionary in a few places where I need the
performance of a linked list for small lists, and the performance of a
hashtable for longer lists. HybridDictionary internally changes from a
ListDictionary to a Hashtable based on the number of elements in the
HybridDictionary.

System.Collections.Specialized.NameObjectCollectio nBase.KeysCollection is
an
example of a nested class, as KeysCollection is tied closes to
NameObjectCollectionBase, yet is publicly usable.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...
Why not just make a strongly type collection that holds only "Nodes"?
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:OR*************@TK2MSFTNGP11.phx.gbl...
> Scott,
> I will nest one class inside another when the nested class is an
> implementation detail of the outer class.
>
> For example, the Node class of a LinkedList class. The Node class holds
> the
> actual "links" in the linked list.
>
> Public Class LinkedList
>
> Private Class Node
> Public Next As Node
> Public Previous As Node
> Public Data As Object
> End Class
>
> ...
>
> End Class
>
> The various methods of LinkedList, such as Add, creates a new Node
> class
> and
> adds the data to it. The Node class contains the previous & next
> references
> to the other nodes in the list.
>
> Hope this helps
> Jay
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:OC*************@TK2MSFTNGP11.phx.gbl...
>> What are the advantages of defining a class as part of another class
>> definition (nesting classes)?
>>
>>
>
>



Nov 21 '05 #10

P: n/a
Scott,
As I stated (attempted to) in my original post, nested classes are primarily
for implementation details.

So yes they are for specific situations.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ez**************@TK2MSFTNGP09.phx.gbl...
Scott,
Why not just make a strongly type collection that holds only "Nodes"? Because a strongly typed collection of Nodes is NOT a LinkedList! (CS 101)
Ok Jay...breathe a little buddy!

So, would it be fair to say that nested classes are for very specific
situations and not extremely mainstream?

First consider that you have a Widget class. You could create:
- an array (either an array or ArrayList) of Widgets
- a dictionary (HashTable) of Widgets
- a linked list of Widgets
- a strongly typed collection of Widgets (CollectionBase)
- a strongly typed dictionary of Widgets (DictionaryBase)
- a strongly typed linked list of Widgets

The above list excludes the fact there are binary trees, balanced trees,
graphs, and other "collections" that could hold & organize Widgets. It
also
avoids the fact that you could have a keyed linked list or a non-keyed
linked list.

Within .NET most people create strongly typed collections with
CollectionBase (which is based on an ArrayList aka an Array) or
DictionaryBase (which is based on an Hashtable aka a dictionary). I hope
you
remember that a LinkedList has performance characteristics that are
different then an array or a dictionary, meaning that a linked list may

be better in some cases. For example inserting into a linked listed is
normally
faster then inserting into an array, while searching a sorted array
(binary
search) is normally faster then searching a linked list (linear search).

Further you could have a single linked list or a double linked list.

Implementing LinkedList with a private Node class means that you do not
need
to add Previous & Next fields to the Widget class itself, allowing your
LinkedList class to be reused for Wingdings in addition to Widgets. You
could even design LinkedList to be a base class, ala CollectionBase,
allowing you to create strongly typed linked lists!

When you are implementing the linted list of Widgets, you would use the
Node
class to hold each Widget linking it to the next Widget. Only the Linked
List class itself needs to know about the Node class itself, hence you
nest
it inside of LinkedList.

By hiding the details of Node within LinkedList you as a consumer of the
LinkedList only need to worry about adding, removing, inserting, and
indexing Widget objects, as you don't really care or need to know that a
Node object is how your Widgets themselves are organized internally to the LinkedList, as Node is an implementation detail!

Note .NET has System.Collections.Specialized.ListDictionary &
System.Collections.Specialized.HybridDictionary that offer LinkedList
functionality. I use HybridDictionary in a few places where I need the
performance of a linked list for small lists, and the performance of a
hashtable for longer lists. HybridDictionary internally changes from a
ListDictionary to a Hashtable based on the number of elements in the
HybridDictionary.

System.Collections.Specialized.NameObjectCollectio nBase.KeysCollection is an
example of a nested class, as KeysCollection is tied closes to
NameObjectCollectionBase, yet is publicly usable.

Hope this helps
Jay

"Scott M." <s-***@nospam.nospam> wrote in message
news:OG**************@TK2MSFTNGP09.phx.gbl...
Why not just make a strongly type collection that holds only "Nodes"?
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:OR*************@TK2MSFTNGP11.phx.gbl...
> Scott,
> I will nest one class inside another when the nested class is an
> implementation detail of the outer class.
>
> For example, the Node class of a LinkedList class. The Node class holds > the
> actual "links" in the linked list.
>
> Public Class LinkedList
>
> Private Class Node
> Public Next As Node
> Public Previous As Node
> Public Data As Object
> End Class
>
> ...
>
> End Class
>
> The various methods of LinkedList, such as Add, creates a new Node
> class
> and
> adds the data to it. The Node class contains the previous & next
> references
> to the other nodes in the list.
>
> Hope this helps
> Jay
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:OC*************@TK2MSFTNGP11.phx.gbl...
>> What are the advantages of defining a class as part of another class
>> definition (nesting classes)?
>>
>>
>
>



Nov 21 '05 #11

P: n/a
* "Scott M." <s-***@nospam.nospam> scripsit:
Why would there be less source files since non-nested classes can be written
into one source module?


The nested class' code is part of the surrounding class' code.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #12

P: n/a
On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* "Scott M." <s-***@nospam.nospam> scripsit:
Why would there be less source files since non-nested classes can be written
into one source module?


The nested class' code is part of the surrounding class' code.


True, but to answer Scott's question, there wouldn't necessarily be
fewer source files with nested classes. You could always put multiple
non-nested classes into a single source file (unlike java).

I'm not sure I like the idea of multiple classes in a single file, but
I'll sometimes put simple enums or structs into the same file as a class
even when their definitions aren't nested.
Nov 21 '05 #13

P: n/a
I usually like to put classes from the same namespace into the same source
code file, unless there is some compelling reason not to (like too many to
keep track of, etc.).

"David" <df*****@woofix.local.dom> wrote in message
news:slrnchqagj.rgn.df*****@woofix.local.dom...
On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* "Scott M." <s-***@nospam.nospam> scripsit:
Why would there be less source files since non-nested classes can be
written
into one source module?


The nested class' code is part of the surrounding class' code.


True, but to answer Scott's question, there wouldn't necessarily be
fewer source files with nested classes. You could always put multiple
non-nested classes into a single source file (unlike java).

I'm not sure I like the idea of multiple classes in a single file, but
I'll sometimes put simple enums or structs into the same file as a class
even when their definitions aren't nested.

Nov 21 '05 #14

P: n/a
Wait until VS2005 comes out, in that you have 'Partial' classes, which
allows you to split the implementation of a class over many source files.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I usually like to put classes from the same namespace into the same source
code file, unless there is some compelling reason not to (like too many to
keep track of, etc.).

"David" <df*****@woofix.local.dom> wrote in message
news:slrnchqagj.rgn.df*****@woofix.local.dom...
On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* "Scott M." <s-***@nospam.nospam> scripsit:
Why would there be less source files since non-nested classes can be
written
into one source module?

The nested class' code is part of the surrounding class' code.


True, but to answer Scott's question, there wouldn't necessarily be
fewer source files with nested classes. You could always put multiple
non-nested classes into a single source file (unlike java).

I'm not sure I like the idea of multiple classes in a single file, but
I'll sometimes put simple enums or structs into the same file as a class
even when their definitions aren't nested.


Nov 21 '05 #15

P: n/a
I've seen that. While is opens up possibilities, I believe I'll use that
sparingly.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Wait until VS2005 comes out, in that you have 'Partial' classes, which
allows you to split the implementation of a class over many source files.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I usually like to put classes from the same namespace into the same
source
code file, unless there is some compelling reason not to (like too many
to
keep track of, etc.).

"David" <df*****@woofix.local.dom> wrote in message
news:slrnchqagj.rgn.df*****@woofix.local.dom...
> On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote: >> * "Scott M." <s-***@nospam.nospam> scripsit:
>>> Why would there be less source files since non-nested classes can be
>>> written
>>> into one source module?
>>
>> The nested class' code is part of the surrounding class' code.
>
> True, but to answer Scott's question, there wouldn't necessarily be
> fewer source files with nested classes. You could always put multiple
> non-nested classes into a single source file (unlike java).
>
> I'm not sure I like the idea of multiple classes in a single file, but
> I'll sometimes put simple enums or structs into the same file as a
> class
> even when their definitions aren't nested.
>
>



Nov 21 '05 #16

P: n/a
One really good use for it is to segment desinger code

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
I've seen that. While is opens up possibilities, I believe I'll use that
sparingly.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Wait until VS2005 comes out, in that you have 'Partial' classes, which
allows you to split the implementation of a class over many source files.
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I usually like to put classes from the same namespace into the same
source
code file, unless there is some compelling reason not to (like too many
to
keep track of, etc.).

"David" <df*****@woofix.local.dom> wrote in message
news:slrnchqagj.rgn.df*****@woofix.local.dom...
> On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at>

wrote:
>> * "Scott M." <s-***@nospam.nospam> scripsit:
>>> Why would there be less source files since non-nested classes can be >>> written
>>> into one source module?
>>
>> The nested class' code is part of the surrounding class' code.
>
> True, but to answer Scott's question, there wouldn't necessarily be
> fewer source files with nested classes. You could always put multiple > non-nested classes into a single source file (unlike java).
>
> I'm not sure I like the idea of multiple classes in a single file, but > I'll sometimes put simple enums or structs into the same file as a
> class
> even when their definitions aren't nested.
>
>



Nov 21 '05 #17

P: n/a
Well, isn't that the reason MS came up with them? Part of the class is
defined in the .aspx page (the designer part) and the logic part is defined
in the code-behind.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
One really good use for it is to segment desinger code

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
I've seen that. While is opens up possibilities, I believe I'll use that
sparingly.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Wait until VS2005 comes out, in that you have 'Partial' classes, which
> allows you to split the implementation of a class over many source files. >
>
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> I usually like to put classes from the same namespace into the same
>> source
>> code file, unless there is some compelling reason not to (like too
>> many
>> to
>> keep track of, etc.).
>>
>> "David" <df*****@woofix.local.dom> wrote in message
>> news:slrnchqagj.rgn.df*****@woofix.local.dom...
>> > On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at>
> wrote:
>> >> * "Scott M." <s-***@nospam.nospam> scripsit:
>> >>> Why would there be less source files since non-nested classes can be >> >>> written
>> >>> into one source module?
>> >>
>> >> The nested class' code is part of the surrounding class' code.
>> >
>> > True, but to answer Scott's question, there wouldn't necessarily be
>> > fewer source files with nested classes. You could always put multiple >> > non-nested classes into a single source file (unlike java).
>> >
>> > I'm not sure I like the idea of multiple classes in a single file, but >> > I'll sometimes put simple enums or structs into the same file as a
>> > class
>> > even when their definitions aren't nested.
>> >
>> >
>>
>>
>
>



Nov 21 '05 #18

P: n/a
Erm, not just that, I know we have regions to segment classes but some
classes become unweidly even with regions.--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, isn't that the reason MS came up with them? Part of the class is
defined in the .aspx page (the designer part) and the logic part is defined in the code-behind.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
One really good use for it is to segment desinger code

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
I've seen that. While is opens up possibilities, I believe I'll use that sparingly.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Wait until VS2005 comes out, in that you have 'Partial' classes, which > allows you to split the implementation of a class over many source

files.
>
>
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> I usually like to put classes from the same namespace into the same
>> source
>> code file, unless there is some compelling reason not to (like too
>> many
>> to
>> keep track of, etc.).
>>
>> "David" <df*****@woofix.local.dom> wrote in message
>> news:slrnchqagj.rgn.df*****@woofix.local.dom...
>> > On 2004-08-13, Herfried K. Wagner [MVP] <hi***************@gmx.at>
> wrote:
>> >> * "Scott M." <s-***@nospam.nospam> scripsit:
>> >>> Why would there be less source files since non-nested classes can
be
>> >>> written
>> >>> into one source module?
>> >>
>> >> The nested class' code is part of the surrounding class' code.
>> >
>> > True, but to answer Scott's question, there wouldn't necessarily

be >> > fewer source files with nested classes. You could always put

multiple
>> > non-nested classes into a single source file (unlike java).
>> >
>> > I'm not sure I like the idea of multiple classes in a single file,

but
>> > I'll sometimes put simple enums or structs into the same file as a
>> > class
>> > even when their definitions aren't nested.
>> >
>> >
>>
>>
>
>



Nov 21 '05 #19

P: n/a
I don't think it was a matter of regions or unweidly-ness. The response I
got from MS after asking them about the reson for partial classes was so the
"designer" stuff like control declarations, etc. could be in the .aspx page
and the logic could be in the .aspx.vb page. I was told that by splitting
the class this way, it increased performance and reduced the "bugs" that
sometimes popped up when the control declaration (vb) was separated from the
control design (html).

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Erm, not just that, I know we have regions to segment classes but some
classes become unweidly even with regions.--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, isn't that the reason MS came up with them? Part of the class is
defined in the .aspx page (the designer part) and the logic part is

defined
in the code-behind.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@tk2msftngp13.phx.gbl...
> One really good use for it is to segment desinger code
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:Ob**************@TK2MSFTNGP11.phx.gbl...
>> I've seen that. While is opens up possibilities, I believe I'll use that >> sparingly.
>>
>>
>> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
> message
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> > Wait until VS2005 comes out, in that you have 'Partial' classes, which >> > allows you to split the implementation of a class over many source
> files.
>> >
>> >
>> >
>> > --
>> >
>> > OHM ( Terry Burns )
>> > . . . One-Handed-Man . . .
>> > If U Need My Email ,Ask Me
>> >
>> > Time flies when you don't know what you're doing
>> >
>> > "Scott M." <s-***@nospam.nospam> wrote in message
>> > news:%2****************@TK2MSFTNGP12.phx.gbl...
>> >> I usually like to put classes from the same namespace into the same
>> >> source
>> >> code file, unless there is some compelling reason not to (like too
>> >> many
>> >> to
>> >> keep track of, etc.).
>> >>
>> >> "David" <df*****@woofix.local.dom> wrote in message
>> >> news:slrnchqagj.rgn.df*****@woofix.local.dom...
>> >> > On 2004-08-13, Herfried K. Wagner [MVP]
>> >> > <hi***************@gmx.at>
>> > wrote:
>> >> >> * "Scott M." <s-***@nospam.nospam> scripsit:
>> >> >>> Why would there be less source files since non-nested classes can > be
>> >> >>> written
>> >> >>> into one source module?
>> >> >>
>> >> >> The nested class' code is part of the surrounding class' code.
>> >> >
>> >> > True, but to answer Scott's question, there wouldn't necessarily be >> >> > fewer source files with nested classes. You could always put
> multiple
>> >> > non-nested classes into a single source file (unlike java).
>> >> >
>> >> > I'm not sure I like the idea of multiple classes in a single
>> >> > file,
> but
>> >> > I'll sometimes put simple enums or structs into the same file as
>> >> > a
>> >> > class
>> >> > even when their definitions aren't nested.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 21 '05 #20

P: n/a
Well, they also have mentioned that it allows more than one person to work
on the class. Although I dont buy that for one minute

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:e4***************@TK2MSFTNGP09.phx.gbl...
I don't think it was a matter of regions or unweidly-ness. The response I
got from MS after asking them about the reson for partial classes was so the "designer" stuff like control declarations, etc. could be in the .aspx page and the logic could be in the .aspx.vb page. I was told that by splitting
the class this way, it increased performance and reduced the "bugs" that
sometimes popped up when the control declaration (vb) was separated from the control design (html).

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Erm, not just that, I know we have regions to segment classes but some
classes become unweidly even with regions.--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Scott M." <s-***@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Well, isn't that the reason MS came up with them? Part of the class is
defined in the .aspx page (the designer part) and the logic part is

defined
in the code-behind.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in

message
news:%2****************@tk2msftngp13.phx.gbl...
> One really good use for it is to segment desinger code
>
> --
>
> OHM ( Terry Burns )
> . . . One-Handed-Man . . .
> If U Need My Email ,Ask Me
>
> Time flies when you don't know what you're doing
>
> "Scott M." <s-***@nospam.nospam> wrote in message
> news:Ob**************@TK2MSFTNGP11.phx.gbl...
>> I've seen that. While is opens up possibilities, I believe I'll use

that
>> sparingly.
>>
>>
>> "One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
> message
>> news:%2****************@TK2MSFTNGP12.phx.gbl...
>> > Wait until VS2005 comes out, in that you have 'Partial' classes,

which
>> > allows you to split the implementation of a class over many source
> files.
>> >
>> >
>> >
>> > --
>> >
>> > OHM ( Terry Burns )
>> > . . . One-Handed-Man . . .
>> > If U Need My Email ,Ask Me
>> >
>> > Time flies when you don't know what you're doing
>> >
>> > "Scott M." <s-***@nospam.nospam> wrote in message
>> > news:%2****************@TK2MSFTNGP12.phx.gbl...
>> >> I usually like to put classes from the same namespace into the same >> >> source
>> >> code file, unless there is some compelling reason not to (like too >> >> many
>> >> to
>> >> keep track of, etc.).
>> >>
>> >> "David" <df*****@woofix.local.dom> wrote in message
>> >> news:slrnchqagj.rgn.df*****@woofix.local.dom...
>> >> > On 2004-08-13, Herfried K. Wagner [MVP]
>> >> > <hi***************@gmx.at>
>> > wrote:
>> >> >> * "Scott M." <s-***@nospam.nospam> scripsit:
>> >> >>> Why would there be less source files since non-nested classes

can
> be
>> >> >>> written
>> >> >>> into one source module?
>> >> >>
>> >> >> The nested class' code is part of the surrounding class' code.
>> >> >
>> >> > True, but to answer Scott's question, there wouldn't necessarily
be
>> >> > fewer source files with nested classes. You could always put
> multiple
>> >> > non-nested classes into a single source file (unlike java).
>> >> >
>> >> > I'm not sure I like the idea of multiple classes in a single
>> >> > file,
> but
>> >> > I'll sometimes put simple enums or structs into the same file

as >> >> > a
>> >> > class
>> >> > even when their definitions aren't nested.
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 21 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.