Java MVC with “note”
by Patrick on April 11, 2011
In order to train my Java skills I started a little program called “note”. It was thought to be some note manager, with adding, editing, deleting, etc. notes. Since I don’t have any clue of swing or AWT it was started as a console program – and never left that stadium.
The only interesting thing, well the only thing which might be interesting, is that it’s implementing the MVC (Model View Controller) pattern. You are able to write controller classes und action methods inside these classes, just like you know it from good ol’ Zend Framework. note’s implementation of the console-MVC is much like that found in Zend_Tool. This means that you write your commands as follows:
add note "Test"
This command would call the action “add” on the controller “note”, passing a single parameter with the value “Test”. note reads this input, splits it by spaces and searches for a class called “note.Controllers.note” and instantiates it. Next thing is setting the arguments of the controller and calling the action on that newly instantiated object. This is all done via reflection.
The code is poorly to not at all commented. On the other hand it’s not that hard to understand what is going on. If you have any questions, feel free to ask. Furthermore I’m sure as hell that there is some stuff in that code which doesn’t make any sense, or could be made better. So feedback is welcomed.
The GitHub repository can be found here: https://github.com/patrickburke/note
Leave your comment