So I screencapped an example of where I really feel like they are giving me a power-up. I’m sure you can do this level of code generation in many other IDEs, but the ease with which you can do it with Sprouts+TextMate makes it hard to resist.
The usecase shown here is an air app that controls a whole bunch of inter-related data. All data types need to be loaded, some also need to be edited and saved/deleted.
In version 1 of this app – built a few years ago – the specifics of each loading/saving/deleting process were implemented through switches and conditionals. I came to hate this system.
In this version, each data type has a strong event type that goes with it – AccountDataEvent, UserDataEvent, GroupDataEvent etc. I have some simple base classes that capture the common processes of moving the data between the app and the server, but the differing logics are wired up using the CommandMap instead.
I know from my version 1 experience that actually these data types each require something a little special. The upside of this approach is that I’ve got a small, digestible, chunk of code in each specific class. They’re isolated from each other’s changes. I can develop and test them and know that they won’t get messed up by the next type I add. The code is written to the concrete types so I’m doing very little casting.
The downside – in many peoples eyes – is that saving and deleting alone require an extra 7 classes and 7 test cases.
And that’s where the power of Sprouts generators really comes in…