This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've recently decided to gain some experience in programming design. I read "Refactoring: Improving the Design of Existing Code" by Martin Fauler, "Design Patterns: Elements of Reusable Object-Oriented Software" by the Gang of Four. Finally, I obtained some skilles in usage of the patterns from the aforementioned books.
Both of these books possess UML diagrams (primarily class and sequence diagrams). So my second step was to create UML diagrams by myself. And I decided to take a Java web-application. I have little experience in UML so could someone help to build a proper class diagram for the following source code:
This peace of code uses external ZK framework. To tell the truth I have no idea how I can depict the relations between container (Tomcat), external framework (ZK, Spring, etc.) and my own web-application and wether I am to do so.
I think I'd go with the following diagram. A couple of remarks:
The GoF design patterns book uses OMT notation, not UML;
Don't worry too much about making your class diagram as detailed as possible. What I've learned over the years is that its real value is in communicating design decisions. Add to your diagram the things you judge necessary to communicate your choices.
If I make no mistake, your MainFrame class represents a window, right? I would avoid adding a getMenubar public method to such a class, because someone with a reference to an instance of a MainFrame class could call MainFrame.getMenubar and start doing things that MainFrame wouldn't know. In other words, the menu bar wouldn't be well encapsulated. Add methods to your MainFrame class that deal with your menu bar.