Lecture 2: UML Diagrams and Writing Java Applications
Objectives:
At the end of this lecture, students will be able to:
• use Unified Modeling Language to design a class
• write a Java class
• write a Java application
• use Camel Casing when writing Class name, variable identifiers and methods
• use appropriate conventions such as correct indentations in code blocks
• understand the need to use conventions in coding
• how to save a Java file
Notes:
Class Programmers design classes using Unified Modeling Language diagrams and after that they
write the source code of the class using the knowledge they have about Java classes as seen in lecture 1.
Suppose the class programmers needed to design a Student class, they would proceed and use a class
diagram which is a UML diagram. UML diagrams are used so that programmers can quickly see the
idea of the classes they will write before they write them out. These diagrams are also used as a
communicating tool between programmers and other stackholders such as sponsors of projects, the
clients who wish buy a software and other programmers like the client programmers who will create
objects from the class they write. There are a total of seven basic UML diagrams. These are:
• Class diagram
• Object diagram
• Component diagram
• Use case diagram
• Interaction diagram
• Statechart diagram
• Activitiy diagram
Class Diagram
Class diagrams basically represent the Object Oriented view of the system which is static in nature. It is
generally used for development purposes.
Use case diagram
A use case diagram are a set of use cases, actors and their relationship. They represent the use case
view of the system.
Page 1 of 5
, CSI21M1 Java Programming Notes, prepared by Mr. S. Nyika, Semester I, 2019
The Student class example
The UML class diagram
This diagram was written using a program called Dia Diagrams under Linux Operating System.The –
sign here shows that the fields are private and the + sign shows that the methods are public. Private and
public are called access specifiers. After the class diagram has been drawn, the class programmers now
write the source code of the class in an IDE of choice such as NetBeans as shown below:
The Student Class Source Code:
Page 2 of 5