* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Introduction - Portal UniMAP
Name mangling wikipedia , lookup
Logic programming wikipedia , lookup
Stream processing wikipedia , lookup
Library (computing) wikipedia , lookup
C Sharp syntax wikipedia , lookup
Java performance wikipedia , lookup
Flow-based programming wikipedia , lookup
Programming language wikipedia , lookup
Software bug wikipedia , lookup
Application Interface Specification wikipedia , lookup
Functional programming wikipedia , lookup
Class (computer programming) wikipedia , lookup
Software quality wikipedia , lookup
Reactive programming wikipedia , lookup
Design Patterns wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
Structured programming wikipedia , lookup
Object-relational impedance mismatch wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Introduction DKT216 Lecturer • Dr Amiza Amir • [email protected] • 0134288966 (8.00 am to 6.00 pm) Course Outcome • CO1: Ability to explain object-oriented programming concept. • CO2: Ability to apply object-oriented programming concept in software development. • CO3: Ability to initiate application development using OOP-based Graphical User Interface (GUI) library Word of Wisdom I hear and I forget. I see and I remember. I do and I understand -Confucius Recommended References • Programming -- Principles and Practice Using C++ by Bjarne Stroustrup Addison-Wesley ISBN 978-0321-992789. May 2014. C++ Inventor Bjarne Stroustrup Recommended References • Design Patterns : Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (Gang of Four) Recommended References Head First Design Patterns by Eric Freeman, Bert Bates, Kathy Sierra and Elisabeth Robson Procedural Programming • Traditional procedural-oriented programming languages (such as C, Fortran, Cobol and Pascal) suffer some notable drawbacks in creating reusable software components: • The procedural-oriented programs are made up of functions. Functions are less reusable. It is very difficult to copy a function from one program and reuse in another program because the function is likely to reference the global variables and other functions. In other words, functions are not wellencapsulated as a self-contained reusable unit. • The procedural languages are not suitable of high-level abstraction for solving real life problems. For example, C programs uses constructs such as if-else, for-loop, array, method, pointer, which are low-level and hard to abstract real problems. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html Procedural Programming : Top Down Design • Start with a problem (procedure). • Systematically break the problem down into sub problems (sub procedures)---called functional decomposition. This process continues until a subproblem is straightforward enough to be solved by the corresponding sub-procedure. • The difficulties with this type of programming, is that software maintenance can be difficult and time consuming ---when changes are made to the main procedure (top), those changes can cascade to the sub procedures of main, and the sub-sub procedures and so on. The Birth of Object-oriented Programming (OOP) • In the early 1970s, the US Department of Defense (DoD) commissioned a task force to investigate why its IT budget always went out of control; but without much to show for. The findings are: 80% of the budget went to the software (with the remaining 20% to the hardware). More than 80% of the software budget went to maintenance (only the remaining 20% for new software development). Hardware components could be applied to various products, and their integrity normally did not affect other products. (Hardware can share and reuse! Hardware faults are isolated!) Software procedures were often non-sharable and not reusable. Software faults could affect other programs running in computers. • The task force proposed to make software behave like hardware OBJECT. Subsequently, DoD replaces over 450 computer languages, which were then used to build DoD systems, with an object-oriented language called Ada. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html Object-oriented Programming (OOP) • Solve the difficulties with procedural programming. • In object-oriented programming (OOP), the main modules in a program are classes, rather than procedures. • Classes and objects in OOP model real world objects. OOP Concepts • The basic unit of OOP is a class, which encapsulates both the static properties and dynamic operations within a "box", and specifies the public interface for using these boxes. Since classes are wellencapsulated, it is easier to reuse these classes. In other words, OOP combines the data structures and algorithms of a software entity inside the same box. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html OOP Concepts • OOP languages permit higher level of abstraction for solving real-life problems. The traditional procedural language (such as C and Pascal) forces you to think in terms of the structure of the computer (e.g. memory bits and bytes, array, decision, loop) rather than thinking in terms of the problem you are trying to solve. • The OOP languages (such as Java, C++ and C#) let you think in the problem space, and use software objects to represent and abstract entities of the problem space to solve the problem. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html OOP Concepts • In object-oriented programming, a class is a template for creating objects. The template is a particular set of attributes and behaviors. • An object is an instance of a class. Objects implement class attributes as data and class behaviors as functions. • In other words, a class is a collection of objects that have common attributes and behaviors. A class is a combination of attributes (data) and behavior (methods). OOP Concept: Class • Example A class Human represents all humans in the world. Humans have attributes, such as height, weight, and hair color. They also have behavior, such as walking, talking, eating. All of the attributes and behavior of a human are encapsulated (contained) within the class human. OOP Concept: Object • An object is an instance of a class. Objects are units of abstraction. • An object can communicate with other objects using messages. • Objects then perform the actions that are required to get a response from the system. OOP Concept: Object • Examples Two examples object from the class Human are : 1) Abu Height: 6’; Weight : 90 kg; Hair colour : Black 2) Kerri Height: 5’ 5”; Weight : 62 kg; Hair colour : Brown Both Abu and Kerri can walk, talk, and eat. However, the way they do these actions may be different from each other. Procedural Programming and OOP The procedural-oriented languages focus on procedures, with function as the basic unit. You need to first figure out all the functions and then think about how to represent data. The object-oriented languages focus on components that the user perceives, with objects as the basic unit. You figure out all the objects by putting all the data and operations that describe the user's interaction with the data. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html OOP Benefits • Ease in software design as you could think in the problem space rather than the machine's bits and bytes. You are dealing with high-level concepts and abstractions. Ease in design leads to more productive software development. • Ease in software maintenance: object-oriented software are easier to understand, therefore easier to test, debug, and maintain. • Reusable software: you don't need to keep re-inventing the wheels and re-write the same functions for different situations. The fastest and safest way of developing a new application is to reuse existing codes - fully tested and proven codes. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html Example : A computer soccer games Using OOP languages, you can easily model the program accordingly to the "real things" appear in the soccer games. Player: attributes include name, number, location in the field, and etc; operations include run, jump, kick-the-ball, and etc. Ball: Reference: Field: Audience: Weather: Some of these classes (such as Ball and Audience) can be reused in another application, e.g., computer basketball game, with little or no modification. http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html Example : A computer soccer game http://www.ntu.edu.sg/home/ehchua/programming/java/J3a_OOPBasics.html