[squeak-dev] Re: [ANN] Filesystem 1.0

Denis Kudriashov dionisiydk at gmail.com
Tue Nov 24 11:33:06 UTC 2009


2009/11/24 Colin Putney <cputney at wiresong.ca>

>
> On 23-Nov-09, at 10:41 PM, Denis Kudriashov wrote:
>
>  2009/11/21 Colin Putney <cputney at wiresong.ca>
>> I really need to rewrite the tutorial to de-emphasize paths. You should
>> use FSReference for everything. Once I get Eliot's suggestion implemented,
>> the above will be:
>>
>> ref := FSReference D / 'Squeak' / '3.10'.
>>
>> Hi
>>
>> I don't like global objects referencess in code. I cant mock global object
>> in tests.
>> I like VW dsl for that. For FileSystem it's can be:
>>
>> 'd://squeak/3.10' asFileReference.
>>
>
> I'm not sure I follow. The only global here is the class FSReference. #D is
> an instance creation method. I don't see how the message you suggest is any
> more flexible. You can't mock out the implementation of asFileReference any
> more easily than that of #D, right?


No. But maybe it's not really problem. For method

writeMessageTo: filename
  FSReference / filename writeStreamDo: [:s | ... ]

I can't mock writing data to real file.
But I can rewrite this method with "filename" as FSReference:

writeMessageTo: filename
  filename writeStreamDo: [:s | ... ]

And now I can mock this behavior by pass mockobject as filename instead of
real FSReference.

 And I think syntax based on strings more simple and elegant:

'smalltalk' \ 'squeak' \ '3.10' writeStreamDo: [: f | ]

'smalltalk\squeak' \ '3.10' writeStreamDo: [: f | ]

'smalltalk\squeak' asFileReference

And last expression will hide work with disks on windows (when we wrote
   'c:/smalltalk' asFileReference
or
  'c:' \ 'smalltalk'
)

I use message #\ because #/ already used in String protocol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20091124/c457c763/attachment.htm


More information about the Squeak-dev mailing list