Looking around at places where filenames are used (in relation to the file name dialogs etc) I see some really ‘interesting’ methods relating to filing out source code.
The basic operation is to select the methods to file out (a class, a protocol, selections in a change set etc) and derive a leaf filename (in a couple of places asking the user for that) and then use FileStream class>>#writeSourceCodeFrom:baseName:isSt:useHtml: .
First oddness is that I can only find 1 case where the ‘isSt: is not ‘true’ (ChangeSet>>fileOut), which always makes me wonder if the factoring is sensible.
Second thing is that (almost) all this method does is work out what file extension to use anyway, something that might be better done higher up the call chain anyway.
Third, even when the html flag is true the code is simply dumped, so perhaps there is an old package somewhere that over-rode this to make actual html?
Fourth, the assumption is that `ChangeSet defaultChangeSetDirectory` is always where the user wants the code to go, which seems dubious. There is a Preference for this, though it doesn’t show up in the Preference Browser and it only gets used meaningfully in ChangeSet class>>#promptForDefaultChangeSetDirectoryIfNecessary. Even there the code pretty much guarantees that only the default directory will ever get used. It gets even more dubious in SystemOrganizer>>#fileOut where the base name given is derived explicitly from the state of the default directory, which in the (admittedly rare because of previous issues) case of a non-default destination could cause some interesting confusion of file names. Especially since it will make the leaf name be something like SystemOrganization.1.st.st
So, another fine mess I’ve dug into, Olly.
For the record, my proposal for a putative improvement here would be
- user interface initiated actions should open a file dialog to let the user choose where the file goes and then use…
- no-user-involvement methods that would be given a fully qualified filename and any required parameters, suitable for no-UI usage
tim
--
tim Rowledge;
[hidden email];
http://www.rowledge.org/timUseful random insult:- So dumb, he faxes face up.