Presentation is loading. Please wait.

Presentation is loading. Please wait.

FP301 Object Oriented Programming

Similar presentations


Presentation on theme: "FP301 Object Oriented Programming"— Presentation transcript:

1 FP301 Object Oriented Programming
1.0 Introduction To OOP 2.0 Fundamentals Of Java Programming Language 3.0 Exception Handling 4.0 Classes, Inheritance And Polymorphism © 2011 | PN AZRINA BINTI TAHIR

2 1.0 INTRODUCTION TO OBJECT – ORIENTED PROGRAMMING (OOP)
Understand Java terminology and environment © 2011 | PN AZRINA BINTI TAHIR

3 Learning Outcome Subtopic 1.3
FP301 OBJECT ORIENTED PROGRAMMING Learning Outcome Subtopic 1.3 1 Describe the history of Java technology 2 Explain the Java technology 3 Determine Java minimum specifications and platforms 4 Identify the key concept of Java programming language 5 Identify Java Technology product such as Standard, Enterprise and Mobile edition 6 Describe the basic tools in Java Development Kit © 2011 | PN AZRINA BINTI TAHIR

4 FP301 OBJECT ORIENTED PROGRAMMING
Cont... 7 Use the Java Technology API documentation to indicate the packages and classes available 8 Draw diagram and label models for both a compiled and an interpretative program 9 State anatomy of the Java program 10 Apply programming style and documentation in Java 11 Write a simple Java program 12 Compile and run the Java program 13 Troubleshoot the source code to identify errors © 2011 | PN AZRINA BINTI TAHIR

5 History of Java Technology
FP301 OBJECT ORIENTED PROGRAMMING Intelligent consumer –electronic devices. Sun Microsystem funded an internal corporate research project code named Green in 1991. The project develop a new language based on C++ which it still maintain the minimum feature of C++. The creator James Gosling called the new language as Oak named after an oak tree outside his window at Sun. Later, they discovered that there already was a computer language called Oak. When the Green team visited a local coffee place, the name Java suggested and it being used after that. © 2011 | PN AZRINA BINTI TAHIR

6 Java Technology The Java technology is: A programming language
FP301 OBJECT ORIENTED PROGRAMMING The Java technology is: A programming language The syntax of Java programming language is similar to C++ syntax. Therefore, it is possible to develop all kind applications that can be create using any conventional programming language. A development environment Java technology provide a large suit of tools: A compiler An interpreter A documentation generator A class file packaging tool and so on. © 2011 | PN AZRINA BINTI TAHIR

7 Cont….. An application environment
FP301 OBJECT ORIENTED PROGRAMMING An application environment Java technology applications are standalone programs that do not require a web browser to execute. A deployment environment There are two main deployment environments. First, the JRE supplied by the Java 2 Software Development Kit (Java 2 SDK) contains the complete set of class files for all of the Java technology packages which includes basic language classes, GUI component classes, an advanced Collections API and so on. Second, is on your web browser. Most commercial browsers supply a Java technology interpreter and runtime environment. © 2011 | PN AZRINA BINTI TAHIR

8 Java minimum specifications and platforms
FP301 OBJECT ORIENTED PROGRAMMING Hardware requirements Processor – recommended Pentium and above if you're running Windows, and a PowerMac for running the Mac OS. Older machines, such as a 486 or a Mac Quadra, will work, but they will be slow. Anything slower than that could be a source of long waits and lots of frustration. minimum of 16 megabytes of RAM. Platforms & Operating Systems The World Wide Web, and the Java language, run on a variety of platforms, including Windows, the Macintosh, and many Unix systems Windows95 Unix and Windows are the platforms on which the Java effort has been the most focused. Consequently, Java seems to run more smoothly here. If you're using Windows95, we recommend using Netscape's Navigator 4.5 as your browser. © 2011 | PN AZRINA BINTI TAHIR

9 Cont….. FP301 OBJECT ORIENTED PROGRAMMING MacOS With the release of Apple's MRJ ("Mac Runtime Java") v. 2.1, the Mac has caught up with and even passed the PC as the hot Java platform. Microsoft's Internet Explorer 4.0 will run with the MRJ 2.1. UNIX Of course, Java is available in UNIX using either the Netscape Navigator or the Internet Explorer. However, there are many flavors of UNIX and many versions to be aware of. We suggest that you visit either Netscape or Microsoft to learn more about exactly how to get the browser that's right for you. © 2011 | PN AZRINA BINTI TAHIR

10 Key Concepts of Java Programming
Language FP301 OBJECT ORIENTED PROGRAMMING The Java programming language was designed to be: Object-oriented Distributed Simple Multithreaded Secure Platform-independent © 2011 | PN AZRINA BINTI TAHIR

11 1) Object-oriented FP301 OBJECT ORIENTED PROGRAMMING Java is an object-oriented programming language because one of the main goals of the Java technology programmer is to create objects, pieces of autonomous code, that can interact with other objects to solve a problem. OOP differs from procedural programming because procedural programming stresses the sequence of coding steps required to solve a problem, while OOP stresses the creation and interaction of objects. Procedural programming focuses on sequence Object-oriented programming focuses on objects and object interactions © 2011 | PN AZRINA BINTI TAHIR

12 2) Distributed FP301 OBJECT ORIENTED PROGRAMMING Java is a distributed language because the language provides support for distributed network technologies. Example: Remote Method Invocation (RMI), Common Object Request Broker Architecture (CORBA) and Universal Resource Locator (URL) © 2011 | PN AZRINA BINTI TAHIR

13 3) Simple FP301 OBJECT ORIENTED PROGRAMMING Java programming language is simple the designers removed some of the complex or obscure programming constructs found in other programming languages. Example: Java used object referenced to manipulate objects, but C and C++ used pointers to memory locations, a complex and often misused feature. In Java, boolean data type can have a value of either true or false. Memory management is automatic with the existence of garbage collector to monitor or remove objects that are no longer referred to. © 2011 | PN AZRINA BINTI TAHIR

14 4) Multithreaded FP301 OBJECT ORIENTED PROGRAMMING Java supports multithreading, that is performing several task at a time. It allows a Java technology program to be efficient in its use of system resources. © 2011 | PN AZRINA BINTI TAHIR

15 5) Secure FP301 OBJECT ORIENTED PROGRAMMING The environment in which Java technology programs run, uses security measures to protect programs from attacks. These measures include: Prohibiting the manipulation of memory using pointers. Prohibiting distributed programs such as applets from reading and writing to a hard disk of a computer. Verifying that all Java technology programs contain valid code. Supporting digital signatures. Java technology code can be “signed” by a company or person in a way that another person receiving the code can verify the legitimacy of the code. © 2011 | PN AZRINA BINTI TAHIR

16 6) Platform-independent
FP301 OBJECT ORIENTED PROGRAMMING Programs written in most languages usually require numerous modifications to run on more than one type of computing platform, a combination of a CPU and operating system. C and C++ is a platform dependence which require you to write code specific to the underlying platform. It also require programmers to compile and link their programs, resulting in an executable program unique to a platform. While Java programming language is a platform independent. © 2011 | PN AZRINA BINTI TAHIR

17 a) Platform-dependent program
FP301 OBJECT ORIENTED PROGRAMMING © 2011 | PN AZRINA BINTI TAHIR

18 Cont…. FP301 OBJECT ORIENTED PROGRAMMING
© 2011 | PN AZRINA BINTI TAHIR

19 Cont…. FP301 OBJECT ORIENTED PROGRAMMING
© 2011 | PN AZRINA BINTI TAHIR

20 b) Platform-independent program
FP301 OBJECT ORIENTED PROGRAMMING © 2011 | PN AZRINA BINTI TAHIR

21 Analyze a problem using OOAD
FP301 OBJECT ORIENTED PROGRAMMING To analyze a problem (case study), there will be three(3) main factor to be considered which is:- Identify problem domain Identify objects Identify object attributes and operations Example of case study: DirectClothing Inc. Sells shirts from their catalog. Business is growing 30 percent per year and they need a new order entry system. You have been contracted by DirectClothing to design the new system. DirectClothing produces a catalog of clothing every six months and mails it to subscribers. Each shirt in the catalog has an item identifier (ID), one or more colors (each with a different color code), one or more sizes, a description and a price. DirectClothing accepts cheques and credit cards. to place an order, customers can call DirectClothing to order directly from a customer service representative (CSR) or customers can mail or fax an order form to DirectClothing. © 2011 | PN AZRINA BINTI TAHIR

22 1) Identify problem domain
FP301 OBJECT ORIENTED PROGRAMMING A problem domain is the scope of the problem that need to be solve. For example, “Create a system allowing order entry people to enter and accept payment for an order”. © 2011 | PN AZRINA BINTI TAHIR

23 2) Identify objects Objects can be physical or conceptual.
FP301 OBJECT ORIENTED PROGRAMMING Objects can be physical or conceptual. Object have attributes (characteristics). Size, name, shape and so on. Object have operations (the things they can do) Setting a value, displaying a screen or increasing speed. © 2011 | PN AZRINA BINTI TAHIR

24 Cont….. FP301 OBJECT ORIENTED PROGRAMMING
© 2011 | PN AZRINA BINTI TAHIR

25 Cont….. Additional criteria for recognizing objects:
FP301 OBJECT ORIENTED PROGRAMMING Additional criteria for recognizing objects: Relevance to the problem domain Does the object exist within the boundaries of the problem domain? Is the object required for the solution to be complete? Is the object required as part of an interaction between a user and the solution? Independent existence For an item to be an object and not an attribute of another object, it must exist independently in the context of problem domain. Possible objects in the DirectClothing case study as follow: © 2011 | PN AZRINA BINTI TAHIR

26 3) Identify object attributes and operations
FP301 OBJECT ORIENTED PROGRAMMING Attributes are data: Order ID Customer ID Operations are action: Delete Item Change ID Order object © 2011 | PN AZRINA BINTI TAHIR

27 Cont….. Object with another object as an attribute
FP301 OBJECT ORIENTED PROGRAMMING Object with another object as an attribute © 2011 | PN AZRINA BINTI TAHIR

28 Cont….. FP301 OBJECT ORIENTED PROGRAMMING Possible attributes and operations for objects in the DirectClothing, Inc. case study © 2011 | PN AZRINA BINTI TAHIR

29 Case Study Solution Order Shirt Customer Form of Payment Catalog CSR
FP301 OBJECT ORIENTED PROGRAMMING Order Shirt Customer Form of Payment Catalog CSR Order ID Date *Shirt(s) Total price *Form of payment *CSR Status Shirt ID Price Description Size Color code Customer ID Name Address Phone number address *Order Cheque number Credit card number Expiration date Shirt(s) extension + Calculate order ID + Calculate the total price + Add shirt to order + Remove shirt from order + Submit the order + Calculate shirt ID + Display shirt information + Assign a customer ID + Verify credit card number + Verify cheque payment + Add a shirt + Remove a shirt © 2011 | PN AZRINA BINTI TAHIR

30 Design classes form using UML Class
Diagram FP301 OBJECT ORIENTED PROGRAMMING To design a class you need to identify: Object (class name) Attributes (variables name) Operations (methods name) Syntax: ClassName attributeVariableName [range of values] methodName() © 2011 | PN AZRINA BINTI TAHIR

31 Cont….. Shirt shirtID Example: Price Description Size
FP301 OBJECT ORIENTED PROGRAMMING Example: Shirt shirtID Price Description Size colorCode R=Red, B=Blue, G=Green calculateShirtID() displayInformation() © 2011 | PN AZRINA BINTI TAHIR


Download ppt "FP301 Object Oriented Programming"

Similar presentations


Ads by Google