Refactoring FileSystem related classes Was-[BUG] FileDirectory>>exists

Anthony Adachi adachipro at yahoo.com
Thu May 22 17:55:26 UTC 2003


Ned Konz wrote:
 
>  On Thursday 22 May 2003 08:48 am, Julian Fitzell
wrote:
>  > Anthony Adachi wrote:
>  > [...]
>  >
>  > > Although, I'm not sure what a good name might
be
>  > > Filename sounds, to my ears at least, too much
like
>  > > simply a class without any further
responsibilities
>  > > other than naming. It seems to me that an
object which
>  > > might also be responsible for such things like
moving
>  > > or copying speaks out for an name which sounds
more
>  > > like an entity rather than a label or id.
>  >
>  > This is exactly my concern as well.

>  We have several different things being discussed:
>  
>  * file names themselves and operations on them
(like converting
>  between platforms). With no context, this doesn't
work well
>  (different filesystems have different rules), so
you also have:
>  
>  * file/directory structure information. Tied to a
particular
>  filesystem, this can answer structure queries, ask
about name
>  bindings (like providing stat() information), and
gives operations
>  relating to existence testing, creation, deletion,
renaming/moving,
>  etc. These can be files, or directories that can be
iterated.
>  
>  * files themselves. These are what's stored in a
filesystem. They
>  don't necessarily have unique names. Operations on
these would
>  including opening a stream, copying (kind of a
meta-operation), etc.

Tim Rowledge also wrote:

>  But that would be the point of Filename; separate
out the ludicrously
>  complex task of handling the naming of files so
that other classes can
>  deal with the other parts. Plain good factoring.
>  
>  You don't ask a Filename to rename or delete or
whatever. You just
>  expect it to get the name right - which is not
simple.

Perhaps, this suggests at least three different kinds
of classes for dealing with files?

In the order which Ned made his point about "different
things"...

*Filename

* DirectoryItem with DirectoryNode/DirectoryContainer
and DirectoryFile subclasses 

*FileContents or FileStream

I'm not trying to imply that these particular names
should be used but just to illustrate an idea of what
they might be responsible for.

Just something to consider,

Anthony

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com



More information about the Squeak-dev mailing list