473,837 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Collection vs. List vs. ??

I'm managing "collection s" / "lists" (??) of objects that are internally
bound by an XML document, but I do NOT intend to offer an IEnumerator
interface.

For instance, with a root XML document, I might have:

<employees>
<employee><name >bob</name></employee>
<employee><name >carl</name></employee>
<employees>

... and I might have a C# class as such:

public class Employee {
public Employee(XmlNod e employeeNode) {
InnerEmployeeNo de = employeeNode;
}
private XmlNode InnerEmployeeNo de;

public string Name {
get {
return InnerEmployeeNo de.SelectSingle Node("name").In nerText;
}
}
}

.... and so now I have a "list" or "collection " of sorts as such:

public class EmployeeList {
public EmployeeList (XmlNode employeesNode) {
InnerEmployeesN ode = employeesNode;
}
private XmlNode InnerEmployeesN ode;
public Employee this[string name] {
get {
XmlNodeList employeeNodes =
InnerEmployeesN ode.SelectNodes ("employee") ;
foreach (XmlNode node in EmployeeNodes) {
if (node.SelectSin gleNode("name") == name) {
return new Employee(node);
}
}
return null;
}
}
}

So now my question is, what should I call this list type?
"EmployeeCollec tion"? "EmployeeLi st"? "EmployeeAr ray" in such a way that it
is not confusing. I myself am confused.

Thanks,
Jon
Nov 13 '05 #1
7 16884
EmployeeNodeLis t since you are returning XmlNode.

"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message
news:ON******** ******@TK2MSFTN GP12.phx.gbl...
I'm managing "collection s" / "lists" (??) of objects that are internally
bound by an XML document, but I do NOT intend to offer an IEnumerator
interface.

For instance, with a root XML document, I might have:

<employees>
<employee><name >bob</name></employee>
<employee><name >carl</name></employee>
<employees>

.. and I might have a C# class as such:

public class Employee {
public Employee(XmlNod e employeeNode) {
InnerEmployeeNo de = employeeNode;
}
private XmlNode InnerEmployeeNo de;

public string Name {
get {
return InnerEmployeeNo de.SelectSingle Node("name").In nerText;
}
}
}

... and so now I have a "list" or "collection " of sorts as such:

public class EmployeeList {
public EmployeeList (XmlNode employeesNode) {
InnerEmployeesN ode = employeesNode;
}
private XmlNode InnerEmployeesN ode;
public Employee this[string name] {
get {
XmlNodeList employeeNodes =
InnerEmployeesN ode.SelectNodes ("employee") ;
foreach (XmlNode node in EmployeeNodes) {
if (node.SelectSin gleNode("name") == name) {
return new Employee(node);
}
}
return null;
}
}
}

So now my question is, what should I call this list type?
"EmployeeCollec tion"? "EmployeeLi st"? "EmployeeAr ray" in such a way that it is not confusing. I myself am confused.

Thanks,
Jon

Nov 13 '05 #2
Why bother making an employee list at all ?

You've got a clear class here, Employee, that contains the name member
variable.

Instead of thinking of EmployeeList as an instance of a class, think
of listing employees as a static (global) method of Employee.

That is to say, the static gets called with the XmlNode, gobbles up
and instantiates the employees records, instantiating employees as it
does so (poof you're an employee), and then returns a Employee[] (or
ArrayList of.;. (or even Hashtable[empname,empInst ance].

If it turns out that you're _only_ creating employees within the
EmployeeList logic, then you can even go further, by making the
Employee constructor private. You call a public static
Employee.Employ eeListReader(Xm lNode someNode) and it returns a
collection to you.

HTH

MMM

"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message news:<ON******* *******@TK2MSFT NGP12.phx.gbl>. ..
I'm managing "collection s" / "lists" (??) of objects that are internally
bound by an XML document, but I do NOT intend to offer an IEnumerator
interface.

Nov 13 '05 #3
No, in this[int index] I'm returning an Employee object, and I intend to
make the XML binding transparent to users of this assembly.

Jon
"Jay Glynn" <jl******@hotma il.com> wrote in message
news:ei******** ******@tk2msftn gp13.phx.gbl...
EmployeeNodeLis t since you are returning XmlNode.

"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message
news:ON******** ******@TK2MSFTN GP12.phx.gbl...
I'm managing "collection s" / "lists" (??) of objects that are internally
bound by an XML document, but I do NOT intend to offer an IEnumerator
interface.

For instance, with a root XML document, I might have:

<employees>
<employee><name >bob</name></employee>
<employee><name >carl</name></employee>
<employees>

.. and I might have a C# class as such:

public class Employee {
public Employee(XmlNod e employeeNode) {
InnerEmployeeNo de = employeeNode;
}
private XmlNode InnerEmployeeNo de;

public string Name {
get {
return InnerEmployeeNo de.SelectSingle Node("name").In nerText;
}
}
}

... and so now I have a "list" or "collection " of sorts as such:

public class EmployeeList {
public EmployeeList (XmlNode employeesNode) {
InnerEmployeesN ode = employeesNode;
}
private XmlNode InnerEmployeesN ode;
public Employee this[string name] {
get {
XmlNodeList employeeNodes =
InnerEmployeesN ode.SelectNodes ("employee") ;
foreach (XmlNode node in EmployeeNodes) {
if (node.SelectSin gleNode("name") == name) {
return new Employee(node);
}
}
return null;
}
}
}

So now my question is, what should I call this list type?
"EmployeeCollec tion"? "EmployeeLi st"? "EmployeeAr ray" in such a way that

it
is not confusing. I myself am confused.

Thanks,
Jon


Nov 13 '05 #4
> Why bother making an employee list at all ?
You've got a clear class here, Employee, that contains the name member
variable.
Instead of thinking of EmployeeList as an instance of a class, think
of listing employees as a static (global) method of Employee.
Why is irrelevant. The code sample is not what I'm using. And I intend to
make the XML binding transparent to the users of my assembly.

Jon
"Mark Mullin" <mu****@vibrant 3d.com> wrote in message
news:32******** *************** ***@posting.goo gle.com... Why bother making an employee list at all ?

You've got a clear class here, Employee, that contains the name member
variable.

Instead of thinking of EmployeeList as an instance of a class, think
of listing employees as a static (global) method of Employee.

That is to say, the static gets called with the XmlNode, gobbles up
and instantiates the employees records, instantiating employees as it
does so (poof you're an employee), and then returns a Employee[] (or
ArrayList of.;. (or even Hashtable[empname,empInst ance].

If it turns out that you're _only_ creating employees within the
EmployeeList logic, then you can even go further, by making the
Employee constructor private. You call a public static
Employee.Employ eeListReader(Xm lNode someNode) and it returns a
collection to you.

HTH

MMM

"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message

news:<ON******* *******@TK2MSFT NGP12.phx.gbl>. ..
I'm managing "collection s" / "lists" (??) of objects that are internally
bound by an XML document, but I do NOT intend to offer an IEnumerator
interface.

Nov 13 '05 #5
Why is Employee<listty pe> not equivalent to Collection of Employee ?

If you're going to create employee<somety peoflist>, what distinguishes
this list of employees from any other list beyond the contents of the
list? Is the list expected to perform operations on the set of
employees that cause it to be a specialization of an existing list
class ? If so, you may want to consider derivation from one of the
existing classes. What in your proposed architecture cares about a
set of employees as a tangible thing providing functionality distinct
from other sets of homogenous data ? Answers to those questions
should make the appropriate name leap out at you.

All that said, Employees might be perfectly fine, since you're trying
to have the name represent what it is, and you've indicated that the
nature of the list (list of XML nodes) ain't what it is.

Entia non sunt multiplicanda praeter necessitatem
Nov 13 '05 #6
What in your proposed architecture cares about a
set of employees as a tangible thing providing functionality distinct
from other sets of homogenous data ?
None. I suppose I should ask in another way:

If I have a set of homogenous data that is indexed with this[...] and
nothing more (i.e. no IEnumerator), what is the base suffix for C# that is
considered legal in terms of standardization and readability? "-Collection"?
"-Set"?

Are you saying that the correct suffix is "-s"?
Why is Employee<listty pe> not equivalent to Collection of Employee ?
I could call it "collection of employee", but C# class names cannot be named
as such (with spaces) and it would break the conventions. So in translation
you're suggesting EmployeeCollect ion, but is it indeed a collection if it
does not implement IList, ICollection(??) , and so on?

Jon
"Mark Mullin" <mu****@vibrant 3d.com> wrote in message
news:32******** *************** ***@posting.goo gle.com... Why is Employee<listty pe> not equivalent to Collection of Employee ?

If you're going to create employee<somety peoflist>, what distinguishes
this list of employees from any other list beyond the contents of the
list? Is the list expected to perform operations on the set of
employees that cause it to be a specialization of an existing list
class ? If so, you may want to consider derivation from one of the
existing classes. What in your proposed architecture cares about a
set of employees as a tangible thing providing functionality distinct
from other sets of homogenous data ? Answers to those questions
should make the appropriate name leap out at you.

All that said, Employees might be perfectly fine, since you're trying
to have the name represent what it is, and you've indicated that the
nature of the list (list of XML nodes) ain't what it is.

Entia non sunt multiplicanda praeter necessitatem

Nov 15 '05 #7
> > Why is Employee<listty pe> not equivalent to Collection of Employee ?

Incidentally, if you mean why shouldn't I just use a generic collection, the
answer is that a generic collection does not bind to specific XML like I
intend for it to. Nor do I want users of my assembly to have to futz with
type casting from Object.

(Please don't suggest that I just read the XML and spit out a set of objects
and throw it into a container, that is NOT disciplined C# coding. I bind to
XML because if an object changes, I want the XML to change immediately. It
is thread-safe, it is instance-safe, and it thereby eliminates a heck of a
lot of hassles. XML synchronization is the product I am selling!
http://www.powerblog.net/ )

Jon
"Jon Davis" <jo*@REMOVE.ME. PLEASE.jondavis .net> wrote in message
news:eH******** ********@TK2MSF TNGP12.phx.gbl. ..
What in your proposed architecture cares about a
set of employees as a tangible thing providing functionality distinct
from other sets of homogenous data ?
None. I suppose I should ask in another way:

If I have a set of homogenous data that is indexed with this[...] and
nothing more (i.e. no IEnumerator), what is the base suffix for C# that is
considered legal in terms of standardization and readability?

"-Collection"? "-Set"?

Are you saying that the correct suffix is "-s"?
Why is Employee<listty pe> not equivalent to Collection of Employee ?
I could call it "collection of employee", but C# class names cannot be

named as such (with spaces) and it would break the conventions. So in translation you're suggesting EmployeeCollect ion, but is it indeed a collection if it
does not implement IList, ICollection(??) , and so on?

Jon
"Mark Mullin" <mu****@vibrant 3d.com> wrote in message
news:32******** *************** ***@posting.goo gle.com...
Why is Employee<listty pe> not equivalent to Collection of Employee ?

If you're going to create employee<somety peoflist>, what distinguishes
this list of employees from any other list beyond the contents of the
list? Is the list expected to perform operations on the set of
employees that cause it to be a specialization of an existing list
class ? If so, you may want to consider derivation from one of the
existing classes. What in your proposed architecture cares about a
set of employees as a tangible thing providing functionality distinct
from other sets of homogenous data ? Answers to those questions
should make the appropriate name leap out at you.

All that said, Employees might be perfectly fine, since you're trying
to have the name represent what it is, and you've indicated that the
nature of the list (list of XML nodes) ain't what it is.

Entia non sunt multiplicanda praeter necessitatem


Nov 15 '05 #8

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

Similar topics

7
2720
by: juli | last post by:
I have strings variables in a collection list and I want to create new collection but to add to it only strings that are distinct (no common strings). For example I have an object sentense which is the base for a collection and there are words in it and I want to create a new collection of sentenses where there is no similar secound word in those sentenses. How do I do this distinct selection from a collection of object? Thanks!
3
4589
by: jason | last post by:
Hello. I've got this simple collection populate code I downloaded from the net (sorry can't find source now) I'm trying to test, but I can't seem to get it to work. Any help would be greatly appreciated. I've compiled the following VB.NET into a DLL: Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Collections
6
1215
by: Christoph Boget | last post by:
Consider the following: class MyClass { public string Var1; public string Var 2; } class MyClassList : System.Collections.CollectionBase { // requisite access methods }
0
1288
by: R. Nachtsturm | last post by:
Hi, I would like to create a workable ExpandableObjectConverter for a String Collection (class inheriting from CollectionBase for example and only accepting/returning Strings via Add/Remove/Item/DefaultProprty) and a fitting Descriptor (implementing ICustomTypeDescriptor)... now i created it and it somewhat works.. my big problem is that i the String classs does not have a default constructor and so the "Add" item in the collection pop...
2
1442
by: pmelanso | last post by:
hello, I am working on a web application and would like to empty a list collection when the browser window closes... is there any way to do this??? Pam
1
1333
by: Jure Bogataj | last post by:
Hello! This may be a silly question, but anyway: If I have collection / list of objects: public class MyCollection : List<MyObject> { }
0
786
by: darrel | last post by:
I've been trying to configure mysites and now I can no longer get into our root site collection. If I go into APP MANAGEMENT in CENTRAL ADMIN, click on the SITE COLLECTION LIST and view the root SITE COLLECTION it states the PRIMARY ADMIN is 'OURDOMAIN\MOSSSETUP' If I log in as that user, I get permission denied. Any idea what might be happening or what to check for?
3
7782
by: Dansk | last post by:
Hi all, Can I assume that when I loop throw a Collection, List, IList, ICollection, ... by using foreach, I first get the element of index 0, then index 2, and so on until the last one ? Thanks for your answers, Dansk.
4
1174
by: Clive Lumb | last post by:
Hi, I'm having a problem while adding objects to a collection. (VB.net 2005) I am reading data in from a file to a temporary variable (eg MyClass) and then adding it to a collection. When I then enumerate the collection, all the entries are equal to the last one added. The same thing happens with lists and with a generic list(of type). Obviously the collection or list is storing a reference to the variable, rather than the values -...
1
2444
by: Humakt | last post by:
I've seen the solution to do this vice versa, but what if I have an object that has collection and I want to return the objects from query using where clause where I check if any of the items in object's collection (list for example) have certain value? How can I do it in single HQL query?
0
9844
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
9683
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10883
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
10578
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...
1
10631
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10276
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5670
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
5851
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4049
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.