What are the advantages of defining a class as part of another class
definition (nesting classes)? 20 1410
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)?
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)?
* "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/>
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
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)?
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/>
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
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)?
"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)? >> >> > >
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)? >> >> > >
* "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/>
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.
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.
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.
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. > >
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. > >
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. >> > >> > >> >> > >
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. >> > >> > >> >> > >
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. >> >> > >> >> > >> >> >> >> >> > >> > >> >> > >
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. >> >> > >> >> > >> >> >> >> >> > >> > >> >> > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fernando Rodriguez |
last post by:
Hi,
I need to traverse the methods defined in a class and its superclasses. This
is the code I'm using:
# An instance of class B should be able to check all the methods defined in B
#and A,...
|
by: John M. Gabriele |
last post by:
I've done some C++ and Java in the past, and have recently learned
a fair amount of Python. One thing I still really don't get though
is the difference between class methods and instance methods. I...
|
by: Oplec |
last post by:
Hi,
I'm learning C++ as a hobby using The C++ Programming Language : Special
Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that
deal with templates. Exercise 13.9 asks for me...
|
by: Bryan Parkoff |
last post by:
I have created three classes according to my own design. First class
is called CMain. It is the Top Class. Second class and third class are
called CMemory and CMPU. They are the sub-classes....
|
by: Banaticus Bart |
last post by:
I wrote an abstract base class from which I've derived a few other
classes. I'd like to create a base class array where each element is
an instance of a derived object. I can create a base class...
|
by: Bryan Parkoff |
last post by:
I find an interesting issue that one base class has only one copy for
each derived class. It looks like that one base class will be copied into
three base classes while derived class from base...
|
by: Jon Slaughter |
last post by:
I have a class that is basicaly duplicated throughout several files with
only members names changing according to the class name yet with virtually
the exact same coding going on.
e.g.
class...
|
by: Andy |
last post by:
Hi all,
I have a site with the following architecture:
Common.Web.dll - Contains a CommonPageBase class which inherits
System.Web.UI.Page
myadd.dll - Contains PageBase which inherits...
|
by: Hamilton Woods |
last post by:
Diehards,
I developed a template matrix class back around 1992 using Borland C++ 4.5
(ancestor of C++ Builder) and haven't touched it until a few days ago. I
pulled it from the freezer and...
|
by: emin.shopper |
last post by:
I had a need recently to check if my subclasses properly implemented
the desired interface and wished that I could use something like an
abstract base class in python. After reading up on metaclass...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |