SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Java Warmup

Java Warmup (English)

Ask for more details, if you need them! :-)

Part 0: Get it running

Attached to this page you find a zip-file with sources. Install them and run the application. If you run into problems, don't hesitate to ask questions on the mailing list. Configurations problems are frequent and we are unable to forsee them all.

Part 1: Correct the JUnit tests

  • Run exercise.basic.VerticeTest as JUnit test. It should succeed.
  • Run exercise.basic.PolyLineTest. There are two problems in it. The comments in the code tell you how you should solve them.

Part 2: Introduce the state pattern

(In prepartion of this part get familar with the design pattern “state”. Google may help you. The first two matches are quite ok.)
The class hierarchy below exercise.model.Shape doesn't make much sense. You can simplify it by introducing the state pattern. Remember: You are doing a refactoring. This means the programm should behave exactly the same after you changed it. (There “are” only the three keys “1”, “2” and SPACE. The cup is rotatable and the smoke resizable but not the other way round.)

You may have a look at:
Martin Fowler: Refactoring - Improving the design of existing code, pp. 362-367, “Tease Apart Inheritance”.

Part 3: Introduce the observer pattern

(Google on observer. The first match is good.) The classes in the package exercise.model know explicitly by which part of the GUI they are displayed. This makes it tough to add other views. Introduce the design pattern “Observer”. After this change it would be easy to add e.g. a view which shows the actual effect of the keys.

Last but not least: Send us your results

The best way to do this is probably to create a new zip-file containing all your java-files. Send it to dsp@iai.uni-bonn.de, rho@iai.uni-bonn.de or muegge@iai.uni-bonn.de. It is OK, if you improved the code in other ways than we suggested. In this case it is important that you write some comments in your code explaining why you did the changes in this way.

Good luck, have fun!

Java Aufwärmübung (Deutsch)

Fragen Sie, wenn Sie weitere Hinweise benötigen! :-)

Teil 0: Bringen Sie es ans Laufen

An dieser Seite hängt eine Zip-Datei mit Quellcode. Installieren Sie diese und führen Sie die Anwendung aus. Wenn Sie auf Probleme stossen zögern Sie nicht, auf der Mailing-Liste zu fragen. Es gibt oft Konfigurationsprobleme und wir sind nicht in der Lage, alle vorherzusehen.

Teil 1: Korrigieren Sie die JUnit Tests

  • Führen Sie exercise.basic.VerticeTest als JUnit-Test aus. Er sollte erfolgreich sein.
  • Führen Sie exercise.basic.PolyLineTest aus. Hierin gibt es zwei Probleme. Die Kommentare im Code sagen Ihnen, wie Sie sie lösen sollten.

Teil 2: Führen Sie das Design Pattern "State" / Entwurfsmuster "Zustand" ein

(In Vorbereitung auf diesen Teil sollten Sie sich mit dem Design Pattern “State” vertraut machen. Google kann Ihnen hier schon weiterhelfen. Die ersten beiden Treffer sind ganz gut.)
Die Klassenhierarchy unterhalb von exercise.model.Shape macht nicht viel Sinn. Vereinfachen Sie diese durch Einführung des “State” Pattern. Beachten Sie dabei: Sie führen ein “Refactoring” durch. Das bedeutet, das Programm soll sich hinterher genauso verhalten wie vorher. (Es “gibt” nur die drei Tasten “1”, “2” und SPACE. Die Tasse ist drehbar und der Rauch vergrößer/verkleinerbar, aber nicht umgekehrt.)

Vielleicht ist folgendes für Sie hilfreich:
Martin Fowler: Refactoring - Improving the design of existing code, pp. 362-367, “Tease Apart Inheritance”.

Teil 3: Führen Sie das Design Pattern "Observer" / Entwurfsmuster "Beobachter" ein

(Google zu “Observer”. Der erste Treffer ist gut.)
Die Klassen im Paket exercise.model wissen genau, durch welche Teile der GUI sie dargestellt werden. Das macht es schwierig , weitere Anzeigen/“Views” hinzuzufügen. Führen Sie das Design Pattern “Observer” ein. Nach dieser Änderung wäre es einfach, einen weiteren View hinzuzufügen. Z. B. eine Anzeige, die sagt, welche Wirkung die Tasten im Augenblick haben.

Zum Schluß: Schicken Sie uns Ihr Ergebnis

Am besten packen Sie all Ihre Java-Dateien wieder in eine Zip-Datei und schicken Sie sie an dsp@iai.uni-bonn.de, rho@iai.uni-bonn.de oder muegge@iai.uni-bonn.de. Wenn Sie den Code in einer anderen Weise als von uns vorgeschlagen verbessern wollen, ist das auch in Ordnung. Dann ist es aber wichtig, dass Sie im Code durch Kommentare ihre Entscheidungen begründen.

Viel Glück und viel Spaß!

Attachments

teaching/labs/xp/2005a/javawarmup.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2025