Tuesday, September 16, 2008

How to not make Tetris...

So, maybe I am alone in this; but, I feel that TDD is a burden just as often as it helps. For example, you would be daft to test the positioning of a JButton on a Swing app; however, you should test everything that the button does... right? Well, I do not know. So, taking the role of the good scientist, I have engineered a test of testing. This test kills two crocodiles with one boulder, as I have always said that I would make Tetris for some reason.

Anyway, I sat down from start to finish, and created an implementation of Tetris, in the rough i.e. no pretty graphics or animations, without any tests. I started out by trying to conform to a nice MVC design... as you could guess that means I have *shocking gasp* 3 classes named XModel, XView, and XController; in this case, TetrisModel, TetrisView, and TetrisController.

To be concise, I ended with an 'M-C, v' (Model-Controller, Little-View) design and the realization that most of the design occurs when you are writing the tests. My Tetris mixed model and controller together in a HUGE violation of SoC. One might as why I would do such a thing, when accepting user input and stuff is TOTALLY not the controller's role; well, I got lazy.

At a certain point, not having tests seemed to deter my willingness to write good code. I became fed up with the constant 'single change, then launch and play Tetris for 5 minutes' routine; and, my code suffered for it.

I'll try this code again in a test driven environment to see if it comes out better; but, until then I will be playing Tetris on my PS3... Thanks to the BD-J Libraries.

As soon as I find a suitable way to host some large volumes of (this is java we are talking about) code I will let the world gaze upon it.

Monday, September 15, 2008

Hmm...

Hmm... I am realizing very quickly, as my unpublished post count rises, that there is no really good way to show off a large amount of source code using this blog 'thingy'. I'm thinking about creating a pastebin... Any suggestions?