Sunday, January 15, 2012

an idea for a programming exercise


An idea came to my mind that could be a programming exercise for a newbie. I'll give the simplest example to get the idea. Suppose you have implemented a view controller that has a view which loads an image from a remote URL and shows a loading indicator until the loading is done. And then when the loading is done your view controller does some action.


For some reasons, you have implemented this functionality inside your view controller code. And luckily you have a newbie little sister who wants to be a software developer.  Instead of telling her to go get some bread from the market, you can as well tell her to go get your view's functionality extracted.


Her exercise would be to extract that view's functionality from your view controller completely. This way she'll get a stand alone view that goes and loads the image from the specified URL and tell a delegate that it's job is done. So, you'll get a reusable image loader component and a less crowded view controller and a trained little sister who has learned something about encapsulation, reusability and delegation :P
.widget { margin-top: 30px; margin-bottom: 30px; }