Top Banner
1 | Page Contents Introduction................................................. 2 UML Diagram.................................................. 3 Use case diagram............................................. 3 Class diagram............................................... 11 Activity diagram............................................ 12 Explanation of coding.......................................13 Inheritance................................................13 Encapsulation..............................................13 Exception Handling.........................................13 Object-Oriented Programming (Research)......................15 What is Object-oriented programming?.......................15 Difference between Object-Oriented Programming and Procedural Programming................................................15 Advantages of OOP..........................................16 Concept of the Object Oriented Programming.................17 Object.....................................................17 Classes....................................................17 Data Abstraction and Encapsulation.........................18 Inheritance................................................18 Example of Inheritance.....................................19 Polymorphisms..............................................19 References.................................................. 21 OODJ TAN KWONG HWEE
27
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: saleh_oodj

1 | P a g e

ContentsIntroduction..............................................................................................................................2

UML Diagram............................................................................................................................3

Use case diagram......................................................................................................................3

Class diagram..........................................................................................................................11

Activity diagram......................................................................................................................12

Explanation of coding.............................................................................................................13

Inheritance..........................................................................................................................13

Encapsulation......................................................................................................................13

Exception Handling.............................................................................................................13

Object-Oriented Programming (Research).............................................................................15

What is Object-oriented programming?.............................................................................15

Difference between Object-Oriented Programming and Procedural Programming...........15

Advantages of OOP.............................................................................................................16

Concept of the Object Oriented Programming...................................................................17

Object.................................................................................................................................17

Classes................................................................................................................................17

Data Abstraction and Encapsulation...................................................................................18

Inheritance..........................................................................................................................18

Example of Inheritance.......................................................................................................19

Polymorphisms...................................................................................................................19

References..............................................................................................................................21

OODJ TAN KWONG HWEE

Page 2: saleh_oodj

2 | P a g e

IntroductionIn 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 object-oriented 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

Page 3: saleh_oodj

3 | P a g e

UML Diagram

Use case diagram

OODJ TAN KWONG HWEE

Page 4: saleh_oodj

4 | P a g e

OODJ TAN KWONG HWEE

Page 5: saleh_oodj

5 | P a g e

Use Case Description

Use Case Add StudentActor AdministratorPrecondition Administrator need to login successful

before add the student informationPost condition Add Student InformationMain Path 1. Select student tab

2. Insert all the student information3. Select the module that student want

take4. Insert username and password to

create account for login5. Click register6. Student information save to

databaseAlternative path

Use Case Edit StudentActor AdministratorPrecondition Administrator need to login successful

before edit the student informationPost condition Edit Student InformationMain Path 1. Select ‘search’ tab

2. Insert search criteria3. Select search key4. Press search5. Edit information6. Click next7. The information will update at

databaseAlternative path 4a. Click next button if you want to search

other student

OODJ TAN KWONG HWEE

Page 6: saleh_oodj

6 | P a g e

Use Case Delete StudentActor AdministratorPrecondition Administrator need to login successful

before delete the student informationPost condition Delete Student InformationMain Path 1. Select ‘search’ tab

2. Insert search criteria3. Select search key4. Press search button5. Press delete button6. The student information is deleted

from databaseAlternative path 4a. Click next button if you want to search

other student

Use Case Search and view StudentActor Administrator, Administrator StuffPrecondition Administrator and Administrator Stuff need

to login successful before search and view the student information

Post condition Search and view Student DetailMain Path 1. Select ‘search’ tab

2. Insert search criteria3. Select search key4. Press search button5. The system will search from

database and display the information to system

Alternative path 4a. Click next button if you want to search other student

Use Case View studentActor StudentPrecondition Student need to login successful before view

the student informationPost condition Display student informationMain Path The student information will display after the

student login successfullyAlternative path

OODJ TAN KWONG HWEE

Page 7: saleh_oodj

7 | P a g e

Use Case Delete StudentActor AdministratorPrecondition Administrator need to login successful

before delete the student informationPost condition Delete Student InformationMain Path 1. Select ‘search’ tab

2. Insert search criteria3. Select search key4. Press search5. Press delete button6. The student information is deleted

from databaseAlternative path 4a. Click next button if you want to search

other student

Use Case Add moduleActor AdministratorPrecondition Administrator need to login successful

before delete the student informationPost condition Add moduleMain Path 1. Click module tab

2. Insert module name3. Press register button4. The module will save to database

Alternative path 3a. The module will not register if the module is repeated

Use Case Edit moduleActor AdministratorPrecondition Administrator need to login successful

before delete the student informationPost condition Change moduleMain PathAlternative path

Use Case Delete moduleActor AdministratorPrecondition Administrator need to login successful

before delete the student informationPost condition Delete moduleMain PathAlternative path

OODJ TAN KWONG HWEE

Page 8: saleh_oodj

8 | P a g e

Use Case Search and view moduleActor Administrator, Administrator stuffPrecondition Administrator and Administrator Stuff need

to login successful before search and view module

Post condition Search and display moduleMain PathAlternative path

Use Case View moduleActor StudentPrecondition Student need to login successful before

delete the student informationPost condition Display moduleMain Path The module will display after the student

login successfullyAlternative path

Use Case Add lecturerActor AdministratorPrecondition Administrator need to login successful

before add the lecturerPost condition Register lecturerMain Path 1. Go to module tab

2. Insert the lecturer name, username and password

3. Click register button4. The lecturer information is saved to

the databaseAlternative path 4a. The system will not save the data and go

back to step 2 if the username is duplicated

Use Case Edit lecturerActor AdministratorPrecondition Administrator need to login successful

before edit the lecturer informationPost condition Edit lecturer detailMain PathAlternative path

OODJ TAN KWONG HWEE

Page 9: saleh_oodj

9 | P a g e

Use Case Delete lecturerActor AdministratorPrecondition Administrator need to login successful

before delete the lecturerPost condition Delete lecturer informationMain PathAlternative path

Use Case Search lecturerActor AdministratorPrecondition Administrator need to login successful

before search the lecturerPost condition Search lecturerMain PathAlternative path

Use Case Enter marksActor Lecturer, AdministratorPrecondition Lecturer and Administrator need to login

successful before go to result entryPost condition Insert marks for studentMain Path 1. Select module

2. Click search3. The student name will display4. Insert marks5. Click save6. The marks will save to database

Alternative path 2a. Click the next button to search other student

Use Case Enter marksActor Lecturer, AdministratorPrecondition Lecturer and Administrator need to login

successful before go to result entryPost condition Insert marks for studentMain Path 1. Select module

2. Click search3. The student name will display4. Insert marks5. Click save6. The marks will save to database

Alternative path 2a. Click the next button to search other student

OODJ TAN KWONG HWEE

Page 10: saleh_oodj

10 | P a g e

Use Case Edit marksActor Lecturer, AdministratorPrecondition Lecturer and Administrator need to login

successful before go to result entryPost condition Insert marks for studentMain Path 1. Select module

2. Click search3. The student name will display4. Edit marks5. Click save6. The marks will update to database

Alternative path 2a. Click the next button to search other student

Use Case Delete marksActor Lecturer, AdministratorPrecondition Lecturer and Administrator need to login

successful before go to result entryPost condition Insert marks for studentMain Path 1. Select module

2. Click search3. The student name will display4. Delete marks5. Click save6. The marks will save to database

Alternative path 2a. Click the next button to search other student

Use Case Search and view module resultActor Lecturer, Administrator, Administrator StuffPrecondition Lecturer, Administrator and administrator

stuff need to login successful before go to result entry

Postcondition Search and display module result for studentMain Path 1. Select module

2. Click search3. The student name will display

Alternative path 2a. Click the next button to search other student

OODJ TAN KWONG HWEE

Page 11: saleh_oodj

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

db#con:connection

OODJ TAN KWONG HWEE

Admin-con:Connection-st:Statement-rst:ResultSet+Admin()+registerLecturer(name:String, username:string, password: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()

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)+getUsername()+getPassword()

Page 12: saleh_oodj

12 | P a g e

+db()+connect()

Activity diagram

OODJ TAN KWONG HWEE

Page 13: saleh_oodj

13 | 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 don’t 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 object’s 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.

OODJ TAN KWONG HWEE

Page 14: saleh_oodj

14 | P a g e

Exception Handling

Figure 3: Exception Handling

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

Page 15: saleh_oodj

15 | P a g e

Object-Oriented Programming (Research)

What is Object-oriented programming?Object–oriented 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 ProgrammingCompare 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

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 it’s simply a passing value to the Arguments to the Functions and / or procedures.

Main concept are method, function and subroutine

Contain procedures to operate

OODJ TAN KWONG HWEE

Page 16: saleh_oodj

16 | P a g e

own data List of OOP : Java, VB.NET,

C#.NET

through the data structure

List of PP: C, VB, Perl, Basic, FORTRAN

(Roshan Ragel, 2011)

Advantages of OOPThere 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

OODJ TAN KWONG HWEE

Page 17: saleh_oodj

17 | P a g e

comprehensive investments in training and infrastructure. Java has helped object-oriented 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)

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)

ClassesClass 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.

OODJ TAN KWONG HWEE

Page 18: saleh_oodj

18 | P a g e

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.

Data Abstraction and EncapsulationIt 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)

InheritanceThe 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.

OODJ TAN KWONG HWEE

Page 19: saleh_oodj

19 | P a g e

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. 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)

OODJ TAN KWONG HWEE

Page 20: saleh_oodj

20 | P a g e

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))

PolymorphismsPolymorphism 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)

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.

OODJ TAN KWONG HWEE

Page 21: saleh_oodj

21 | P a g e

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)

References

Anban Pillay (2007) Object-Oriented Programming [Online] Available from http://math.hws.edu/eck/cs124/downloads/OOP2_from_Univ_KwaZulu-Natal.pdf [Accessed: 15 April 2012]

Gary B. Shelly Misty E. Vermaat, 2011, Discovering Computer 2011 Living Digital World (Complete). [Accessed: 15 April 2012]

OODJ TAN KWONG HWEE

Page 22: saleh_oodj

22 | P a g e

Roshan Ragel, Difference Between Object Oriented Programming and Procedural Programming, [Online] Available from http://www.differencebetween.com/difference-between-object-oriented-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/BasicJava2/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-Object-Oriented-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-in-java-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. 

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_OOPBasics.html [Accessed: 20 April 2012]

OODJ TAN KWONG HWEE