473,406 Members | 2,710 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,406 software developers and data experts.

are directories files?

Tum
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

Jul 17 '05 #1
5 1962
"Tum" <sp**@spam.com> wrote in message
news:%8********************@news02.tsnz.net...
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

Since java.io.File covers both files and directories, it's not exactly a new
way of thinking.
Jul 17 '05 #2
nos

"Ryan Stewart" <zz********@gSPAMo.com> wrote in message
news:p8********************@texas.net...
"Tum" <sp**@spam.com> wrote in message
news:%8********************@news02.tsnz.net...
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

Since java.io.File covers both files and directories, it's not exactly a

new way of thinking.

This works

File f = new File(".");

Jul 17 '05 #3
> > > 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?
Jul 17 '05 #4
nos

"S Manohar" <sg*******@hotmail.com> wrote in message news:2e**************************@posting.google.c om...
> 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?


rewrite routines twice???
Jul 17 '05 #5
sg*******@hotmail.com (S Manohar) wrote in message news:<2e**************************@posting.google. com>...
[snipped...]
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?


It would appear that the only difference between files and directories
is their content type. A file has binary content, and the content
length is the number of bytes. A directory has list content, and the
content length is the number of entries in the list. Aside from this
there is practically no difference. Both have names, attributes and
permissions. Both can be 'soft' and 'hard' linked. Both can be
created, copied, moved and deleted.

So, you *can* think of them as one type of object with two content
type variations. Whether or not your *do* think of them in this way
is entirely dependent upon what you are doing!
-FISH- ><>
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
1
by: huzz | last post by:
I need to write script in c# that will scan directories for files and insert the files and directory names in the database.. I've have two tables tblDir and tblDocs. Example: -Directory1...
1
by: mark4asp | last post by:
Hello, I have an eBook which I need to create a CHM version for. It contains hundreds of HTML files. Can anyone recommend a HTML authoring tool which will allow me to create new directories...
4
by: Grant Harmeyer | last post by:
How would I set up an httpHandler so that it would only apply to certain child directories of the application? I.E: <httpHandlers> <add verb="*" path="/files/*/*/*/*.aspx"...
5
by: rbt | last post by:
What is the most efficient way to recursively remove files and directories? Currently, I'm using os.walk() to unlink any files present, then I call os.walk() again with the topdown=False option...
4
by: rn5a | last post by:
I have a ListBox which should list all the files & directories that exist in a particular directory. The problem is I can get the ListBox to list either all the files or all the directories but not...
1
by: rn5a | last post by:
A ListBox lists all the folders & files existing in a directory named 'MyDir' on the server. Assume that the ListBox lists 2 directories - 'Dir1' & 'Dir2' i.e. these 2 directories reside in the...
5
by: Jandre | last post by:
Hi I am a python novice and I am trying to write a python script (most of the code is borrowed) to Zip a directory containing some other directories and files. The script zips all the files fine...
4
by: Edwin Velez | last post by:
http://msdn.microsoft.com/en-us/library/806sc8c5.aspx The URL above gives sample code for use within a Console Application. What I would like to do is use this code within a Windows Form. That...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.