I've recently been kicking about a small Ruby console app that will merge the contents of two directory structures. I've been doing this for two reasons: -
- I want to sync the music folder on my network with the one on my MacBook.*
- I want a sandbox app that I can use to learn RSpec, Cucumber and various other technologies.**
So, why am I telling you all this? Well, I learned an important lesson today and I thought I would share it because it bears repeating.
ALWAYS DESIGN EACH OF YOUR APPS FROM SCRATCH! Don't start a project by nicking the design from a previous one. There will be differences, many of them subtle, that will mean that sooner or later (likely later) you will realise that the two apps are actually different and that a redesign is in order.
The sandbox app I'm building just now seemed to be similar enough to the Codebreaker app in The RSpec book for me to nick at least the bin file from it as a starting point. Wrong! Obviously there is very little an app designed to let you guess a secret code has in common with an app to synchronise two directory trees. Even the part that I thought they had in common, the means of running and accepting commands from the user, is clearly different as soon as you chuck the first couple of use cases at it. I had assumed the model to be used for user interaction would be for them to call the program passing in the source directory and the destination directory. They could thereafter type commands at the given prompt to view the differences between the directories, sync them or exit the program. But this is not intuitive. Nor does it fit the Unix paradigm where I would be running the program most often (and where any others downloading it would most likely be running it as well). So I'm going to have to do a redesign so that the program is run from the shell prompt, passing in a switch to dictate the use (i.e. -d to see the diff, -s to sync), as well as the directories.
However, before I do that, I'm going to map out the use cases on the whiteboard to make sure I'm happy with them first!
* Yes, I know that there are already multiple apps out there that can do this for me (and the vast majority will be better than mine no doubt), but I want a sandbox app and this fits the bill nicely.
** Yes, I am aware that a shell script will probably be faster, however it's Ruby that I want to play about in and not shell script. Besides, I may well want to run this on my Windows machine as well (although it's dual boot so all file ops could be done in the Linux kernel instead).
The sandbox app I'm building just now seemed to be similar enough to the Codebreaker app in The RSpec book for me to nick at least the bin file from it as a starting point. Wrong! Obviously there is very little an app designed to let you guess a secret code has in common with an app to synchronise two directory trees. Even the part that I thought they had in common, the means of running and accepting commands from the user, is clearly different as soon as you chuck the first couple of use cases at it. I had assumed the model to be used for user interaction would be for them to call the program passing in the source directory and the destination directory. They could thereafter type commands at the given prompt to view the differences between the directories, sync them or exit the program. But this is not intuitive. Nor does it fit the Unix paradigm where I would be running the program most often (and where any others downloading it would most likely be running it as well). So I'm going to have to do a redesign so that the program is run from the shell prompt, passing in a switch to dictate the use (i.e. -d to see the diff, -s to sync), as well as the directories.
However, before I do that, I'm going to map out the use cases on the whiteboard to make sure I'm happy with them first!
* Yes, I know that there are already multiple apps out there that can do this for me (and the vast majority will be better than mine no doubt), but I want a sandbox app and this fits the bill nicely.
** Yes, I am aware that a shell script will probably be faster, however it's Ruby that I want to play about in and not shell script. Besides, I may well want to run this on my Windows machine as well (although it's dual boot so all file ops could be done in the Linux kernel instead).