473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Collection vs. List vs. ??

I'm managing "collections" / "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(XmlNode employeeNode) {
InnerEmployeeNode = employeeNode;
}
private XmlNode InnerEmployeeNode;

public string Name {
get {
return InnerEmployeeNode.SelectSingleNode("name").InnerTe xt;
}
}
}

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

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

So now my question is, what should I call this list type?
"EmployeeCollection"? "EmployeeList"? "EmployeeArray" in such a way that it
is not confusing. I myself am confused.

Thanks,
Jon
Nov 13 '05 #1
7 16847
EmployeeNodeList since you are returning XmlNode.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ON**************@TK2MSFTNGP12.phx.gbl...
I'm managing "collections" / "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(XmlNode employeeNode) {
InnerEmployeeNode = employeeNode;
}
private XmlNode InnerEmployeeNode;

public string Name {
get {
return InnerEmployeeNode.SelectSingleNode("name").InnerTe xt;
}
}
}

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

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

So now my question is, what should I call this list type?
"EmployeeCollection"? "EmployeeList"? "EmployeeArray" 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,empInstance].

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.EmployeeListReader(XmlNode someNode) and it returns a
collection to you.

HTH

MMM

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message news:<ON**************@TK2MSFTNGP12.phx.gbl>...
I'm managing "collections" / "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******@hotmail.com> wrote in message
news:ei**************@tk2msftngp13.phx.gbl...
EmployeeNodeList since you are returning XmlNode.

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ON**************@TK2MSFTNGP12.phx.gbl...
I'm managing "collections" / "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(XmlNode employeeNode) {
InnerEmployeeNode = employeeNode;
}
private XmlNode InnerEmployeeNode;

public string Name {
get {
return InnerEmployeeNode.SelectSingleNode("name").InnerTe xt;
}
}
}

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

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

So now my question is, what should I call this list type?
"EmployeeCollection"? "EmployeeList"? "EmployeeArray" 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****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om... 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,empInstance].

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.EmployeeListReader(XmlNode someNode) and it returns a
collection to you.

HTH

MMM

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

news:<ON**************@TK2MSFTNGP12.phx.gbl>...
I'm managing "collections" / "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<listtype> not equivalent to Collection of Employee ?

If you're going to create employee<sometypeoflist>, 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<listtype> 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 EmployeeCollection, but is it indeed a collection if it
does not implement IList, ICollection(??), and so on?

Jon
"Mark Mullin" <mu****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om... Why is Employee<listtype> not equivalent to Collection of Employee ?

If you're going to create employee<sometypeoflist>, 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<listtype> 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****************@TK2MSFTNGP12.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<listtype> 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 EmployeeCollection, but is it indeed a collection if it
does not implement IList, ICollection(??), and so on?

Jon
"Mark Mullin" <mu****@vibrant3d.com> wrote in message
news:32**************************@posting.google.c om...
Why is Employee<listtype> not equivalent to Collection of Employee ?

If you're going to create employee<sometypeoflist>, 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
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...
3
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...
6
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
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...
2
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
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
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...
3
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 ? ...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.