are directories files?

From: Tum (spam_at_spam.com)
Date: 02/26/04


Date: Thu, 26 Feb 2004 22:39:06 +1300

Hi folks,

I've been trying to make a decision and it's driving me crazy.

Is a directory a file or is a directory NOT a file but a node?

Should I have

A)

public interface IFile
{
   IFileName FileName;
   IFileContent GetContent();
}

public interface IDirectory
   extends IFile
{
}

or

B)

public interface INode
{
   INodeName NodeName;
}

public interface IFile
  extends INode
{
  IFileContent GetContent();
}

public interface IDirectory
  extends INode
{
}

Method A is nice cause IFile becomes the base "Node" type and you can use
names like "IFileName" which sounds nice compared to "INodeName" and fits
with the "FileSystem" moniker. A has the disadvantage that IDirectory has a
GetContent() method which isn't bad but can be considered a bit weird. It
probably wouldn't be too hard to make users think of everything as a file.

Method B is nice cause IDirectory doesn't have GetContent() -- that honour
belongs only to IFile. B is at a disadvantage when it comes to naming:
everything becomes a "Node". INodeName sounds rude compared to IFileName
and it's a bit weird to have everything based on something called a "Node"
when the system is called a "File System" but this method feels more "pure"
in the OO sense cause you're specialising features completely.

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...

^Tum



Relevant Pages