Presentation on theme: "OBJECT ORIENTED DESIGN Mohammad Amin Kuhail M.Sc. (York, UK) Introduction to Object Oriented Design & Analysis University of Palestine Faculty of."— Presentation transcript:
OBJECT ORIENTED DESIGN Mohammad Amin Kuhail M.Sc. (York, UK) Introduction to Object Oriented Design & Analysis University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Lecture #: 1 Week: 2 Date: SAT, 19.01.08 Location: KB112
Introduction to Object Oriented Analysis and Design Outline History of Object Oriented Programming. Object Oriented Programming. Procedural Vs. Object Oriented Programming. Advantages
History of Object Oriented Programming Simula Objects as programming entities were introduced in the 1960s in Simula 67, a programming language designed for making simulations, created by Ole-Johan Dahl and Kristen Nygaard of the Norwegian Computing Center in Oslo. Such an approach was a simple extrapolation of concepts earlier used in analog programming. On analog computers, such direct mapping from real-world phenomena/objects to analog phenomena/objects (and conversely), was (and is) called 'simulation'. Simula not only introduced the notion of classes, but also of instances of classes, which is probably the first explicit use of those notions.
History of Object Oriented Programming Smalltalk The Smalltalk language, which was developed at Xerox PARC in the 1970s, introduced the term Object-oriented programming to represent the pervasive use of objects and messages as the basis for computation. Smalltalk creators were influenced by the ideas introduced in Simula 67, but Smalltalk was designed to be a fully dynamic system in which classes could be created and modified dynamically rather than simply using static ones as in Simula 67.
History of Object Oriented Programming C++ Object-oriented programming developed as the dominant programming methodology during the mid-1990s, largely due to the influence of C++. Its dominance was further cemented by the rising popularity of graphical user interfaces, for which object-oriented programming is well-suited. An example of a closely related dynamic GUI library and OOP language can be found in the Cocoa frameworks on Mac OS X, written in Objective C, an object- oriented, dynamic messaging extension to C based on Smalltalk
History of Object Oriented Programming Java,.NET, UML Object-oriented features have been added to many existing languages during that time, including Ada, BASIC, Lisp, Fortran, Pascal, and others. Adding these features to languages that were not initially designed for them often led to problems with compatibility and maintainability of code. More recently, a number of languages have emerged that are primarily object- oriented yet compatible with procedural methodology, such as Python and Ruby. Besides Java, probably the most commercially important recent object-oriented languages are Visual Basic.NET and C# designed for Microsoft's.NET platform. Just as procedural programming led to refinements of techniques such as structured programming, modern object-oriented software design methods include refinements such as the use of design patterns, design by contract, and modeling languages (such as UML).
Object Oriented Programming Definition The idea behind the approach was to build software systems by modeling them based on the real-world objects that they were trying to represent. For example, banking systems would likely contain customer objects, account objects, etc. Today, object-oriented design has been widely adopted by businesses around the world. When done properly, the approach leads to simpler, concrete, robust, flexible and modular software. When done badly, the results can be disastrous.
Object Oriented Programming Definition Object-oriented analysis is concerned with developing an object-oriented model of the application domain. The identified objects reflect entities and operations that are associated with the problem to be solved. Object-oriented design is concerned with developing an object-oriented model of a software system to implement the identified requirements. The objects in an object-oriented design are related to the solution to the problem that is being solved. There may be close relationships between some problem objects and some solution objects but the designer inevitably has to add new objects and to transform problem objects to implement the solution. Object-oriented programming is concerned with realizing a software design using an object-oriented programming language. An object-oriented programming language, such as Java, supports the direct implementation of objects and provides facilities to define object classes.
Break… Software Engineering Jokes!! For a software engineer, what is the difference between work and prison? IN PRISON... you spend the majority of your time in an 8x10 cell. AT WORK... you spend the majority of your time in a 6x8 cubicle. IN PRISON... you get three meals a day. AT WORK... you only get a break for one meal and you pay for it. IN PRISON... you get time off for good behaviour. AT WORK... you get more work for good behaviour. IN PRISON... the guard locks and unlocks all the doors for you. AT WORK... you must carry around a security card and open all the doors for yourself.k…
Procedural Vs. Object Oriented Procedural Programming Most people think in top-down structured design (Procedural Programming ) approach decomposition simple matter of algorithmic decomposition each module in system denotes a major step (action) in some overall process
Procedural Vs. Object Oriented Procedural Programming Is a programming paradigm that is based on procedure call. Procedures, also known as routines, subroutines, methods, or functions simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. The focus of procedural programming is to break down a programming task into a collection of data structures and subroutines.
Procedural Vs. Object Oriented Procedural Programming Especially in large, complicated programs, modularity is generally desirable. Inputs are usually specified syntactically in the form of arguments and the outputs delivered as return values. Scoping is another technique that helps keep procedures strongly modular. It prevents the procedure from accessing the variables of other procedures (and vice- versa), including previous instances of itself, without explicit authorization.
Procedural Vs. Object Oriented Procedural Programming A module interface expresses the elements that are provided and required by the module. The elements defined in the interface are visible to other modules. The implementation contains the working code that corresponds to the elements declared in the interface. The differences between classes and modules are: Classes can be instantiated to create objects, Classes can inherit behavior and data from another class, Polymorphism allows relationships between class instances to change at run-time, while relations between modules are static. The similarities between classes and modules are: Both can be used to hide implementation details from public view Both can form a hierarchy of modules/classes.
Procedural Vs. Object Oriented OO Programming With OO decompose, key abstractions in problem domain are considered move knight (bridge game) shoot i.e. bet (playing craps) Roll identify objects such as knight, pawn, rook,... Dice weapon
Procedural Vs. Object Oriented Procedural Programming In OO decomposition, the world is viewed as set of autonomous agents objects collaborate to perform some higher level behavior role doesn’t exist as an independent algorithm it is an operation associated with the object: i.e. dice
Procedural Vs. Object Oriented OO Programming The class concept combines data and operation (e.g. card, dice, bishop, monster, …) Better possibilities of abstraction. OO methods shift the focus of modeling from the solution area towards the problem area. Methodology uniformity. All phases of software development operate with the same concepts (classes, objects, relationships,...)
Procedural Vs. Object Oriented OO Programming An object is simply a real entity, which exhibits some well-defined behavior. objects do things we ask objects to perform actions by sending a messages Decomposition based upon objects (not algorithms), thus we call this an object-oriented decomposition.
Advantages Encapsulation, Inheritance Encapsulation: Achieved through: Data hiding: Every object encapsulates its attributes, and methods. Other objects don’t need to worry how each method is implemented. objects interact with each other through messages. Inheritance: Achieved through: The derived class can inherit the properties of its base class and also adds its own data and routines. Overloading, in OOP, means the ability to assign multiple meanings to the names of operators and functions.
Advantages simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear. modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system. modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods. extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones; maintainability: objects can be maintained separately, making locating and fixing problems easier; re-usability: objects can be reused in different programs.