In our latest session my goal was to begin to transition from procedural programming to introducing object-orientation. Somewhere between his blank stares and my ramblings I got an idea to focus on what he knows and challenge him to write an app that’s simple yet interesting to him.
Do we make the GUI first? Can we make it later? Do we make it last?
I generally answer these questions by saying that a good application architecture allows you defer any infrastructure decision for as long as is necessary. We build software to solve problems and we should build our apps to focus on the problem it’s solving not on the devices it’s run on. By building our application logic separately and making all of our presentation specific technology plug-in to our application (or invert the dependency) we gain a huge advantage later on if and whenever we want to expand our app to different platforms or different presentation frameworks/technologies. This immediately increases our code’s longevity and reuse ten-fold. An added bonus is that the practice of inverting our dependencies inward towards our applications logic seems to always produce obvious component boundaries.