String value holders: useful or memory hogs?
From: Oliver Plohmann (oliver_at_plohmann.com)
Date: 10/30/04
- Previous message: Darryl L. Pierce: "Re: KVM NOT READY"
- Next in thread: xarax: "Re: String value holders: useful or memory hogs?"
- Reply: xarax: "Re: String value holders: useful or memory hogs?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 30 Oct 2004 12:19:33 -0700
I have a lot of collections in my application that hold strings which
represent objects. These objects are often on remote machines, which
is the reason why I plug in their id strings into some collections
instead of the objects themselves. This makes it possible that coding
errors may happen, which the compiler cannot find. Example:
List<String> nodeIds = new Array<String>();
List<String> agentIds = new Array<String>();
String nodeId = "uniqueNodeId";
agentIds.add(nodeId); // logical coding error and compiler would not
complain
The compiler would find these kind of errors if string value holders
were used:
public class NodeId {
protected String id = null;
// remaining code omitted for brevity
}
public class AgentId {
protected String id = null;
// remaining code omitted for brevity
}
List<NodeId> nodeIds = new Array<NodeId>();
List<AgentId> agentIds = new Array<AgentId>();
NodeId nodeId = new NodeId("uniqueNodeId");
agentIds.add(nodeId); // ==> compiler error !!
Now I'm expecting memory consumption to raise because of these value
holder classes like NodeId and AgentId. I wonder whether it will make
a difference. I guess so, but I wonder how much. Did any body out
there already try something similar and has some recommendations?
Thanx for any feed-back,
Oliver
- Previous message: Darryl L. Pierce: "Re: KVM NOT READY"
- Next in thread: xarax: "Re: String value holders: useful or memory hogs?"
- Reply: xarax: "Re: String value holders: useful or memory hogs?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|