On Aug 2, 2012, at 9:29 PM, Chris Muller <asqueaker@gmail.com> wrote:
- FileDirectory uses Strings as path descriptions, FileSystem uses real Objects for that.
Nope, it uses DirectoryEntry.
- The main entry point for FileSystem is the FileReference, the old way is String + FileDirectory
No, DirectoryEntry is like a FileReference. But some folks may prefer just to use simple Strings in some cases. Strings are a *real* part of any modern filesystem domain, so you've got to deal with them at SOME point. And, since there is shorthand syntax for Strings understood by the Compiler, it can actually make code *cleaner* in some cases than having to instantiate an object model every time just to, for example, get a list of directory contents (not to mention allocation expense).
It is a matter of taste, or maybe not, which design is better. Maybe FD uses DE, but that is internally. In your programs, you do: FileDirectory on: 'a/path/to/a/file', which gives you a FileDirectory instance, on which you can do operations, like a C library. For instance, FileDirectory default readOnlyFileNamed: 'Blah'. Unless you uses specifically #entries, you never see the DE instances... With FileSystem, you have the reference concept reified into something that represents a file entry, and that object can understand operations related to a file reference. In the same example, with FileSystem you do: 'blah' asFileReference readStream. That of course, gives you the easy of using strings, in a much better design, IMO. Also, DirectoryEntry is *not* like FileReference... maybe in their intentions, but for real DE works more like a data structure with no much behavior remaining (for instance, a DirectoryEntryDirectory cannot give you the directory entries, you have to go back to a FileDirectory to do that). Notice that even FileDirectory creates internally DirectoryEntry instances (as you said), so... the optimization you claim does not occur there either, unless I'm missing something (?) I do believe FileSystem design can be improved, but I think is a huge step in the right direction. Cheers, Esteban