2009/7/29 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
2009/7/29 Igor Stasenko <siguctua@gmail.com>:
2009/7/29 Damien Cassou <damien.cassou@gmail.com>:
2009/7/29 Mariano Martinez Peck <marianopeck@gmail.com>:
On Tue, Jul 28, 2009 at 5:39 PM, Igor Stasenko <siguctua@gmail.com> wrote:
I think that all such kind of queries (like isXXXPlatform) should be not included and not used in a well-designed system. If you want some capability - then you should ask directly for it, irrespectively on what platform you are currently running.
I am agree. I really believe in the phrase "tell don't ask". However, I have a couple of things to say:
1) It is not as easy as it seems. If you want to delegate to another object and be polymorphic regarding the platform you must reify a couple of classes (in your slash it is easy because you have the File hierarchy). I mean, you cannot put everything in the Platform class. And this must be done in every place. You must really understand that piece of code to change it. I can do this in my projects, but I don't know about to do it everywhere.
The class OSPlatform is quite small. I would vote for:
- implementing the following methods
OSPlatform>>isMacOSX  ^ false OSPlatform>>isWin32  ^ false OSPlatform>>isUnix  ^ false
and then
MacOSXPlatform>>isMacOSX  ^ true UnixPlatform>>isUnix  ^ true Win32Platform>>isWin32  ^ true
- when you want to test the platform, just do:
OSPlatform current isMacOSX
or
OSPlatform current isWin32
What do you think?
How about shortcut methods then?
OSPlatform class>>isMacOSX Â ^ self current isMacOSX
etc...
Or let it be a global? like Smalltalk, Processor, etc... Do we write SystemDictionary current?
you mean global var 'Platform'? there is OSPlatform global var. Why not use it instead? Or, someone please tell me, why everyone tend to mis-use the singleton pattern in a form: 'Foo current' , whereas the Foo is already a singleton???
-- Damien Cassou http://damiencassou.seasidehosting.st
"Lambdas are relegated to relative obscurity until Java makes them popular by not having them." James Iry
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.