Você está na página 1de 23

1|Page

Contents
Introduction ............................................................................................................................... 2 UML Diagram ............................................................................................................................. 3 Use case diagram....................................................................................................................... 3 Class diagram ........................................................................................................................... 11 Activity diagram ....................................................................................................................... 13 Explanation of coding .............................................................................................................. 14 Inheritance .......................................................................................................................... 14 Encapsulation ...................................................................................................................... 14 Exception Handling .............................................................................................................. 14 Object-Oriented Programming (Research).............................................................................. 16 What is Object-oriented programming? ............................................................................. 16 Difference between Object-Oriented Programming and Procedural Programming .......... 16 Advantages of OOP.............................................................................................................. 17 Concept of the Object Oriented Programming ................................................................... 18 Object .................................................................................................................................. 18 Classes ................................................................................................................................. 18 Data Abstraction and Encapsulation ................................................................................... 19 Inheritance .......................................................................................................................... 19 Example of Inheritance........................................................................................................ 20 Polymorphisms .................................................................................................................... 20 References ............................................................................................................................... 22

OODJ

TAN KWONG HWEE

2|Page

Introduction
In this assignment, I need to develop an application to maintain student exam details for a university. The application is called as Student Grade Management System. In order to do the project efficiently and to fulfill the requirements I need to work with object oriented java. We will use different OO techniques to achieve our goals i.e. polymorphism, abstraction, encapsulation etc. In addition, I would also do the research and explain more detail about objectoriented concept which is implementing on Java programming language. Based on the explanation, I will also give some example for the Java coding to understand easy for the object-oriented concept.

OODJ

TAN KWONG HWEE

3|Page

UML Diagram
Use case diagram

OODJ

TAN KWONG HWEE

4|Page

add student detail *

<<extends>> Account Registration

edit student detail * delete student detail * search student detail * include

<<extends>>

view student detail * * ** * add lecturer ** ** * * * ** * edit lecturer * * * * Administrative Stuff enter student marks Administrator * search lecturer * include view lecturer delete student marks * delete lecturer * edit student marks * *

* add module * edit module * delete module * search module * view module * search module result * * * view module result include Student * * *

* * * * * *

view student module

search student module Lecturer *

* *

view student marks

include

View student detail *

* view module

OODJ

TAN KWONG HWEE

5|Page Use Case Description Use Case Actor Precondition Post condition Main Path Add Student Administrator Administrator need to login successful before add the student information Add Student Information 1. Select student tab 2. Insert all the student information 3. Select the module that student want take 4. Insert username and password to create account for login 5. Click register 6. Student information save to database

Alternative path

Use Case Actor Precondition Post condition Main Path

Alternative path

Edit Student Administrator Administrator need to login successful before edit the student information Edit Student Information 1. Select search tab 2. Insert search criteria 3. Select search key 4. Press search 5. Edit information 6. Click next 7. The information will update at database 4a. Click next button if you want to search other student

OODJ

TAN KWONG HWEE

6|Page Use Case Actor Precondition Post condition Main Path Delete Student Administrator Administrator need to login successful before delete the student information Delete Student Information 1. Select search tab 2. Insert search criteria 3. Select search key 4. Press search button 5. Press delete button 6. The student information is deleted from database 4a. Click next button if you want to search other student

Alternative path

Use Case Actor Precondition

Post condition Main Path

Alternative path

Search and view Student Administrator, Administrator Stuff Administrator and Administrator Stuff need to login successful before search and view the student information Search and view Student Detail 1. Select search tab 2. Insert search criteria 3. Select search key 4. Press search button 5. The system will search from database and display the information to system 4a. Click next button if you want to search other student

Use Case Actor Precondition Post condition Main Path Alternative path

View student Student Student need to login successful before view the student information Display student information The student information will display after the student login successfully

OODJ

TAN KWONG HWEE

7|Page

Use Case Actor Precondition Post condition Main Path

Alternative path

Delete Student Administrator Administrator need to login successful before delete the student information Delete Student Information 1. Select search tab 2. Insert search criteria 3. Select search key 4. Press search 5. Press delete button 6. The student information is deleted from database 4a. Click next button if you want to search other student

Use Case Actor Precondition Post condition Main Path

Alternative path

Add module Administrator Administrator need to login successful before delete the student information Add module 1. Click module tab 2. Insert module name 3. Press register button 4. The module will save to database 3a. The module will not register if the module is repeated

Use Case Actor Precondition Post condition Main Path Alternative path

Edit module Administrator Administrator need to login successful before delete the student information Change module

Use Case Actor Precondition Post condition Main Path Alternative path

Delete module Administrator Administrator need to login successful before delete the student information Delete module

OODJ

TAN KWONG HWEE

8|Page

Use Case Actor Precondition

Post condition Main Path Alternative path

Search and view module Administrator, Administrator stuff Administrator and Administrator Stuff need to login successful before search and view module Search and display module

Use Case Actor Precondition Post condition Main Path Alternative path

View module Student Student need to login successful before delete the student information Display module The module will display after the student login successfully

Use Case Actor Precondition Post condition Main Path

Alternative path

Add lecturer Administrator Administrator need to login successful before add the lecturer Register lecturer 1. Go to module tab 2. Insert the lecturer name, username and password 3. Click register button 4. The lecturer information is saved to the database 4a. The system will not save the data and go back to step 2 if the username is duplicated

Use Case Actor Precondition Post condition Main Path Alternative path

Edit lecturer Administrator Administrator need to login successful before edit the lecturer information Edit lecturer detail

OODJ

TAN KWONG HWEE

9|Page

Use Case Actor Precondition Post condition Main Path Alternative path

Delete lecturer Administrator Administrator need to login successful before delete the lecturer Delete lecturer information

Use Case Actor Precondition Post condition Main Path Alternative path

Search lecturer Administrator Administrator need to login successful before search the lecturer Search lecturer

Use Case Actor Precondition Post condition Main Path

Alternative path

Enter marks Lecturer, Administrator Lecturer and Administrator need to login successful before go to result entry Insert marks for student 1. Select module 2. Click search 3. The student name will display 4. Insert marks 5. Click save 6. The marks will save to database 2a. Click the next button to search other student

Use Case Actor Precondition Post condition Main Path

Alternative path

Enter marks Lecturer, Administrator Lecturer and Administrator need to login successful before go to result entry Insert marks for student 1. Select module 2. Click search 3. The student name will display 4. Insert marks 5. Click save 6. The marks will save to database 2a. Click the next button to search other student

OODJ

TAN KWONG HWEE

10 | P a g e

Use Case Actor Precondition Post condition Main Path

Alternative path

Edit marks Lecturer, Administrator Lecturer and Administrator need to login successful before go to result entry Insert marks for student 1. Select module 2. Click search 3. The student name will display 4. Edit marks 5. Click save 6. The marks will update to database 2a. Click the next button to search other student

Use Case Actor Precondition Post condition Main Path

Alternative path

Delete marks Lecturer, Administrator Lecturer and Administrator need to login successful before go to result entry Insert marks for student 1. Select module 2. Click search 3. The student name will display 4. Delete marks 5. Click save 6. The marks will save to database 2a. Click the next button to search other student

Use Case Actor Precondition

Postcondition Main Path

Alternative path

Search and view module result Lecturer, Administrator, Administrator Stuff Lecturer, Administrator and administrator stuff need to login successful before go to result entry Search and display module result for student 1. Select module 2. Click search 3. The student name will display 2a. Click the next button to search other student

OODJ

TAN KWONG HWEE

11 | P a g e

Class diagram
Person #name:string #address:string #Gender:string +Person(name:string, address string, Gender:string) +setAddress(address:string):void +setGender(Gender:string):void +setName(name:string):void +getAddress():string +getGender():string +getName():string

Student -nic:string -Dob:string -Nationality:string -StudentNumber:string -email:string -module1:string -module2:string -moduel3:string +Student(name:string, address:string, nic:string, gender:string, dob:string, nationality:string, tp:string, email:string, module1:string, module2:string, module3:string) +Register():void +studentUpdate():void +accountRegister(username:string, password:string) +student()

Admin -con:Connection -st:Statement -rst:ResultSet +Admin() +registerLecturer(name:String, username:string, password:string)

Lecturer #contact:cont #lecturer_code:string +SaveMarks() +UpdateMarks() +SearchModul()

LoginUser +username:string +password:string +LoginUser() LoginUser(username:string, password:string) +setUsername(username:string) +setPassword(password:string)

OODJ

TAN KWONG HWEE

12 | P a g e +getUsername() +getPassword()

db #con:connection +db() +connect()

OODJ

TAN KWONG HWEE

13 | P a g e

Activity diagram
User Student Grade Management System
Receive Username and Password

Database
Incorrect
Check Username and Password

Log In

Correct
Notification (Unable to find)

Not found User and Module Detail

Administrator

Search User or Module Details

Run Process

Retrieve User or Module Details

Display User or Module Details

Found User or Module Detail

No
Duplication Notification

Add, Delete, or Edit Users

Execute Process

Verify duplication

No
Confirm Executed Process

View Student and Module Details

Execute Process

Retrieve Student and Module Details

Student
Show Student and Module Details

Notification (No result found)

Not found User and Module Detail

Search Student and Module Details

Execute Process

Retrieve Student and Module Details

Administrative Staff
Show Student and Module Details

Found Student and Module Detail

Not found Student and Module Detail


Notification (No result found)

Search Student and Module Details

Execute Process

Retrieve Student and Module Details

Lecturer Found Student or Module Detail


Display Student and Module Detail

Add, Delete or Edit Module Result

Execute Process

Execute Process

Confirm Executed Process

OODJ

TAN KWONG HWEE

14 | P a g e

Explanation of coding
Inheritance

Figure 1: Inheritance

Figure 1 shows that the class Admin has been inherited from class Person. Inheritance give programmers much relief because it allows programmers to use parent class attributes and methods in child class so generally we as being a programmer dont need to make those things again because we can access already created things from parent class. Inheritance provides flexibility, integrity and reusability.

Encapsulation

Figure 2: Encapsulation

Encapsulation is to obscure the variables or something inside a class, stopping unauthorized parties to use. So the area methods like getter and setter admission it and the supplementary classes call these methods for accessing. Figure 2 are the example of encapsulation from my system. It is use to limiting access certain of the objects component and also creates the bundling of data with the techniques that work on that data. There are two type of encapsulation i.e. protected and private when we use protected its mean that all the child classes can use these properties while when it comes to private no one can access these properties except class itself.

Exception Handling

Figure 3: Exception Handling

OODJ

TAN KWONG HWEE

15 | P a g e

Exception Handling is the procedure of responding to the occurrence, across computation of exceptions that frequently changing the normal flow of plan execution. It is very important for the performance of any system because it helps any system to avoid crashing any program for any exceptional circumstances that are not handled by your software.

OODJ

TAN KWONG HWEE

16 | P a g e

Object-Oriented Programming (Research)


What is Object-oriented programming?
Objectoriented programming (OOP) is a set of method that able to let programmer to build better documentation, user friendly, sustainable, consistent and flexible system to achieve the requirement of users. It is helps many software developer to solve variety problem on creating system project. (Anban Pillay, 2007) It contains both data (person, place, event or transection) and the techniques that can read and execute the data.

Difference between Object-Oriented Programming and Procedural Programming


Compare with the traditional procedural programming (PP) language, both of them are totally different of programming paradigms. Programming paradigm is an essential ways for computer programming language. It can be divided into different parts of program that represented and defined the procedure for solving problem. Below are the different between OOP and PP languages Object-Oriented Programming (OOP) Procedural Programming (PP)

It is a method of programming by dividing the problems into smaller discrete pieces called Object. Focus on develop an application based on real time The OOP communicate with each other via Functions

Main concept are Polymorphism, Modularity, Messaging, Inheritance, Encapsulation and Data Abstraction Only pack all the methods and data together and operate on its own data List of OOP : Java, VB.NET, C#.NET

It is a method of programming by determining the steps and follow the set of steps in order to achieve the outcome or specific program state More focus with the flow of procedures and functions There is no any communication in PP rather its simply a passing value to the Arguments to the Functions and / or procedures. Main concept are method, function and subroutine Contain procedures to operate through the data structure List of PP: C, VB, Perl, Basic, FORTRAN

(Roshan Ragel, 2011)

OODJ

TAN KWONG HWEE

17 | P a g e

Advantages of OOP
There are several advantages when the programmers develop the program using Object Oriented approach. The main benefic of OOP is the current object can be reuse and modify. For example, programmer creates an object called Student. The object can be reused on any other existing program in many systems. Therefore, the programmer can be use many times on the existing object. It will become stable and faster when the programmer built the system with existing object. In addition, the OOP perform well in a RAD environment. RAD is abbreviation of Rapid Application Development. It is a tool of developing software. It is useful for programmer to create and run at the certain part program instead of create the whole entire complete program. It is an essential concept in RAD during pre-build components. For instance, programmers no need to write any coding for text boxes and buttons on Windows Form. This is because they have exists method that provided with the language.
(Gary B. Shelly, 2011)

Furthermore, OOP can be maintain and upgrade easily. It contains good framework for code libraries which help the programmer to apply the software components on developing graphical user interface (GUI). It can easily to maintain and modified inside the system which do not affect any part of program.
(Lakshmi Anand K, 2008)

Moreover, OOP in Java is simple language. Nowadays, there is no any language is easy but Java is one which is much simpler to use in OOP language compare with other. For example, between C++ and Java, Java has used the interface which substituted the complexity of multiple inheritances in C++ programming language. Besides, Java has automatic memory allocation and trash collection but for C++, the programmers need to allocate memory and collect trash manually. The Java also consist small number of language constructs with a powerful language. All these are the proof that Java program is easy to create and read. Other than that, OOP in Java designs with larger flexibility, modularity and reusability. For years, object-oriented knowledge has been observed as elitist, needing comprehensive investments in training and infrastructure. Java has helped objectoriented knowledge go in the mainstream of computing, alongside its easy and clean construction that permits the programmer to comprise facile to elucidate and comprise programs.
(Pradnya Choudhari)

OODJ

TAN KWONG HWEE

18 | P a g e

Concept of the Object Oriented Programming

Figure 1: Concept of the OOP

Object
An Object is a software bundle of variables and related methods. Basically, programmer creates software objects of real world objects in OOP. Software object can be modeled after the real world object is available on state and behavior. It can be keep it on its state in one or more variables. Variable is an item of data which is called identifier. The software object executes the behavior with methods. Method can assistant with the object. (Anban Pillay, 2007)

Classes
Class defines as the objects of the same kind. It is used to create the template, blueprint, or prototype which can describes as dynamic behavior and static attributes of the same kind to all objects. A class can be divided into 3 compartment box.

Figure 2: Example of classed with 3 compartment box (source from http://www3.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html)

From the figure above, the Student and Circle are the Identifier (Name). The Identifier is used to identify the class. The id, name, radius and color are the Variables. It consists the static attributes of the class. The getName(), printGrade(), getRadius() and getArea() are method which contain the dynamic behaviors of the class. It is use to declare the method of the variables.

OODJ

TAN KWONG HWEE

19 | P a g e

Data Abstraction and Encapsulation


It relates to the act of representing important features which is not including the background information or explanation. Abstract attributes are classes that use the concept of abstraction. Encapsulation is all the data and functions storing together in a single unit called class. Data are restricted to access from outside world. Only the function in the class can able to access it.
(Larry Smith, 2011)

Inheritance
The term inheritance is a concept of OOP which helps to work together on the objects. In order to implement methods, all the classes must refer to java.lang.Object in Java Programming Language.

Figure 3: Descends from java.lang.Object

The diagram above shows the class hierarchy of descends from java.lang.Object. From the diagram, all the subclasses inherit and implement at the java.lang.Object method. Each of class are stored in the Java API libraries. java.lang.Object is the main set of behavior which all the classes have in common. At the down of the hierarchy, every class has its own group of class specific field and methods to inherit one superclass or other superclass. For example, the java.awt.swing.JFrame class inherits field and methods from java.awt.Frame. The java.awt.Frame is inherited field and method by the java.awt.Container.

OODJ

TAN KWONG HWEE

20 | P a g e

After that, the java.awt.Container inherits field and methods from java.awt.Component which is inherited field and method by the java.lang.Object. (Oracle, 2010) In OOP, programmers usually create classes in hierarchy. It is used to prevent repetition and reduce redundancy. All the variables and methods in the lower hierarchy are inherited from the higher hierarchy. Subclass is lower hierarchy as well as the superclass is the higher hierarchy. Redundancy can be reducing when the variables and methods are not repeated in the subclasses.
(Larry Smith, 2011)

Example of Inheritance

Figure 4: Example of Inheritance

The example above shows the relationship between the class Cylinder and the class Circle. From example, the class Circle is the Superclass and the class Cylinder is a subclass. The class Cylinder inherited all the variable (radius and color) and methods (getRadius(), getArea()) from the class Circle which includes its immediate parent along with the ancestors. (Larry Smith, 2011))

Polymorphisms
Polymorphism is a generic word that way 'many shapes'. Extra precisely Polymorphisms way the skill to appeal that the alike procedures be gave by an expansive scope of disparate kinds of things. At periods, I utilized to contemplate that understanding Object Oriented Software design thoughts have made it tough as they have gathered below four main thoughts, as every single believed is closely connected alongside one another. Therefore one has to be tremendously prudent to accurately comprehend every single believed separately, as understanding the method every single connected alongside supplementary concepts. In OOP the polymorphisms is attained by employing countless disparate methods shouted method overloading, operator overloading and method overriding. (Nirosh, 2011)

OODJ

TAN KWONG HWEE

21 | P a g e

Method is overloading and method overriding uses believed of polymorphism in java whereas method term stays alike in two classes but actual method shouted by JVM (Java Virtual Machine) depends on object. Java supports both overloading and overriding of methods. In case of overloading method signature adjustments as in case of overriding method signature stays alike and attaching and prayer of method is selected on runtime established on actual object. This ability permits java programmer to comprise extremely flexibly and maintainable program employing interfaces lacking fretting concerning concrete implementation. One disadvantage of employing polymorphism in program is that as reading program you don't understand the actual kind that irritates as you are looking to find bugs or trying to debug program. But if you do java debugging in IDE you will definitely be able to discern the actual object and the method call and variable associated alongside it.
(Javarevidsited, 2011)

OODJ

TAN KWONG HWEE

22 | P a g e

References
Anban Pillay (2007) Object-Oriented Programming [Online] Available from http://math.hws.edu/eck/cs124/downloads/OOP2_from_Univ_KwaZu lu-Natal.pdf [Accessed: 15 April 2012] Gary B. Shelly Misty E. Vermaat, 2011, Discovering Computer 2011 Living Digital World (Complete). [Accessed: 15 April 2012] Roshan Ragel, Difference Between Object Oriented Programming and Procedural Programming, [Online] Available from http://www.differencebetween.com/difference-between-objectoriented-programming-and-vs-procedural-programming/ [Accessed: 15 April 2012] Oracle, 2010, Lesson 8: Object-Oriented Programming, [Online] Available from http://java.sun.com/developer/onlineTraining/Programming/BasicJava 2/oo.html#inh [Accessed: 21 April 2012] Pradnya Chounhari, Java Advantage & Disadvantages, [Online] Available from http://www.suraj.lums.edu.pk/~cs293m02/Java%20Advantages.doc [Accessed: 21 April 2012] Nirosh, Introduction to Object Oriented Programming Concepts (OOP) and More, [Online] Available from http://www.codeproject.com/Articles/22769/Introduction-to-ObjectOriented-Programming-Concep#Overloading [Accessed: 21 April 2012] Javarevisited, Method overloading and method overriding in Java, [Online] Available from http://javarevisited.blogspot.com/2011/08/what-is-polymorphism-injava-example.html [Accessed: 22 April 2012] Timothy A. Budd, An Introduction to Object-Oriented Programming (3/E), Tsinghua University Press ,2004, pp.1-23,125-146. Ronald J. Norman, Object-Oriented Systems Analysis and Design, Tsinghua University Press, Prentice Hall ,1998, pp.55-82. Walter Savitch, C + + object-oriented programming (5th edition), Tsinghua University Press, 2005, pp.194-288. Tan Hao Qiang, C + + Programming, Tsinghua University Press ,2004, pp.231-313. Zheng Li, Fu Shi Xin, Zhang Rui Feng, C + + Language Programming(3rd edition), Tsinghua University Press, 2004, pp.90-124. Li Longshu, C + + Programming (2nd edition), Tsinghua University Press, 2008, pp.71-116.

OODJ

TAN KWONG HWEE

23 | P a g e

Zhu Haibin, Zhou Mengchu, Object-Oriented Programming in C++:A Project-Based Approach, Tsinghua University Press, 2006, pp.46-98. Guo Ling Yan, Chang Shu Feng, "Object-Oriented programming ideas understanding and case analysis", Educational Technology Guide, 2007, pp.47-48. Chua Hock-Chuan, Object-Oriented Programming in Java, [Online] Available from http://www3.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBa sics.html [Accessed: 20 April 2012]

OODJ

TAN KWONG HWEE

Você também pode gostar