Re: are directories files?
From: S Manohar (sgmanohar_at_hotmail.com)
Date: 02/29/04
- Next message: Sveta: "J2ME question:how i can catch command event"
- Previous message: Doug van Vianen: "Re: Deprecated hide and show for Choice"
- In reply to: nos: "Re: are directories files?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Feb 2004 23:49:34 -0800
> > > Do you reckon I can get away with Method A? It doesn't seem as pure
> unless
> > > you spend a long time convincing yourself that (for all intents and
> > > purposes) a file *is* a node (it's just got a different name) and a
> > > directory *is* a file.
> > >
> > > A penny for anyone's thoughts...
> > >
> > Since java.io.File covers both files and directories, it's not exactly a
> new
> > way of thinking.
> >
> This works
>
> File f = new File(".");
Wow, profound and epigrammatic replies, but of course it depends a lot
on how you are going to implement the interfaces.
E.g., are you going to have many functions that are common to both
files and directories (e.g. delete, move, attributes etc.)? And is
there much code that needs to be used by both classes? Code
economy/reuse is my major consideration when making these decisions;
it would be bad to rewrite routines twice that would operate on both
files and directories, e.g. recursive copying etc.
Since files have properties that directories do not (as you describe
with getContents), and Dirs have some that files do not, a common Node
interface sounds more attractive to me. Directories might also have
extras that files do not, e.g. the ability to add leaf 'nodes' to
them, and the ability to retrieve a list of their children - methods
which files do not.
Any more pennies?
- Next message: Sveta: "J2ME question:how i can catch command event"
- Previous message: Doug van Vianen: "Re: Deprecated hide and show for Choice"
- In reply to: nos: "Re: are directories files?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|