root@myvserver:~$ java -jar myprogram.jar &
[1] 9388
[1]+ Killed java -jar myprogram.jar
Winston Gutkowski wrote:
M Bryan wrote:The trees are saved in a database, with ID and parent ID.
So you've already got a database then. Even more reason for using it as God (or is that Codd?) intended, I would have thought.
Winston Gutkowski wrote:
M Bryan wrote:I can see your point. Our use cases are way bigger than just customer and names, everything is much more complex, which legitimates the file system.
I'd be interested to see that justification in full, because it'd be the first time I've ever heard a claim that a flat file system is faster than a db substantiated.
Jeff Verdegan wrote:First off, it sounds like a database might be a better choice than a file system.
But if you're going to stick with the file system, then you definitely should NOT be writing code like node.getChild(56). That's just asking for all kinds of trouble.
Define a layer to translate from meaningful names to those IDs. It might be an enum, so that you can do [/b]node.getChild(NodeId.NAME)[/b] or it might be some kind of mapping of Strings so you can do [/b]node.getChild("name")[/b] (which is more error prone but might also be somewhat more flexible) or just specific methods like node.getNameChild(). You may even implement one of these approaches on top of another.
Which specific approach is right for your situation, I cannot say, but if you're not using consistent, meaningful, centralized names for these things, then you're doing it wrong.