Friday, November 13, 2009

Grades for week 9

Everybody completed the minimal task for this week. I hope you read more on classes in this blog since it is the most fundamental topic in Java. Although we do not have much time to dedicate to it because the course caters more to the Web development line of use of your knowledge, reread the topic and go as deep into it as you can. Good ways of using classes (in addition to separating some parts of graphics will add to your project value.

Although the minimal requirements were satisfied by all, as I said in the beginning of the course, the contenders for A-level grade should try to maximize the effect of every task (not just formally satisfy it). This week we saw how some students took the idea of size and color control to a higher level allowing to do it dynamically. This supports the dominant program development pattern: MVC (model-view-controller) where the way the user tries to control the systems behavior and the way the backbone model works (image in this case) are separated into different classes, allowing to change the model (images) without changing the way users interface with the system or change interface behavior on the same internal models.

Tuesday, November 3, 2009

Classes

Classes are a form of structuring software projects in modern programming languages. Read more on object-oriented design (if interested).

The T9.3 task will not be checked (there are no points for it) but just to remind you that the described feature should be in your project. T9.2 is a simpler task dealing only with modification of the example. Of course, you could do it by changing your project (like having some graphics moved to another class), which is more than the T9.2 calls for. If you understand classes well then I would suggest to do T9.2 as it is required (will be a small piece of work for those who understands classes) and then without hurry redesign your project into may be several classes (the better use of technology - the higher the grade for the project will be). One class might handle the interface, another handles logic of the control panel, and the third one deals with the game engine (as game state generation, getting user input, and win/loose calculation with no connection to the GUI interface). But if you want to start with one class for now (like some graphics in your project) you can do it. The class design that I just described corresponds to the modern MVC pattern (read about Model View Controller pattern on the Web). The View here will be not just the picture but the whole layout (although art could be a small subclass). The picture will probably change in its implementation when we get to the threads (as another form of concern separation) anyway. The general rule is to keep something in a separate class (object-oriented design), which will have a life (changes) of its own. So if you plan to play with picture by changing it as a result of the event processing - then it should be another class serving the proper image based on the user choices and resulting system’s reaction.

A simple description of the typical class structure and a simple example are on pp.237-239.

If you want to know more about classes – read: http://java.sun.com/docs/books/tutorial/java/javaOO/classes.html . Somewhat more advanced tutorial is here: http://home.cogeco.ca/~ve3ll/jatutor4.htm . For deeper understanding of classes: http://leepoint.net/JavaBasics/oop/oop-10-intro.html see all pages and also the whole chapter 3 in http://docstore.mik.ua/orelly/java/javanut/ch03_01.htm .