OBJECT ORIENTED PROGRAMMING | My Assignment Tutor

OBJECT ORIENTEDPROGRAMMINGCONCEPTSWEEK 1 – OBJECTUNDERSTAND THE PRINCIPLES OFOBJECT ORIENTED PROGRAMMINGCharacteristics of objects: types eg constructors, destructors;classification; features eg inheritance, polymorphism, encapsulation,public classes, private classes, public methods, private methods,message passing; interpreted, open source, common librariesVariables: public instance variables; private instance variables;static referencesSoftware engineering: features eg modularity, encapsulation, reuse,method overloading, instance variables, classes, abstract classes,interfacesClasses: characteristics eg identification attributes, control of scopeof attributes and methods, inheritance, aggregation, association,polymorphismPREREQUISITE & HOW TO SURVIVEBasic knowledge of Programming requiredRead books and remember Read the books, remember the languageThink Think in objects, think in classesPractice Do as many coding as possible and make them runningAsk in classesPROGRAMMINGTECHNIQUESThe evolution of programming techniques to make programming languages more expressive to develop complex systems more easilyProgramming Techniques Unstructured Programming Procedural Programming Modular & Structural Programming Abstract Data Type Object-Oriented ProgrammingUNSTRUCTUREDPROGRAMMINGUsually, people start learning programming by writing small andsimple programs consisting only of one main program. Here“main program” stands for a sequence of commands orstatements which modify data which is global throughout thewhole program.Main ProgramDataDRAWBACKSThis programming technique can only be used in a very small program.For example, if the same statement sequence is needed at different locationswithin the program, the sequence must be copied. If an error needed to bemodified, every copy needs to be modified.This has lead to the idea to extract these sequences(procedure), name themand offering a technique to call and return from these procedures.PROCEDURALPROGRAMMINGWith procedural programming, you are ableto combine sequences of calling statementsinto one single place.A procedure call is used to invoke theprocedure. After the sequence is processed,flow of control proceeds right after theposition where the call was made .MainProgram ProcedurePROCEDURESWith parameters and sub-procedures (procedures of procedures) ,programs can now be written more structured and error free.For example, if a procedure is correct, every time it is used it producescorrect results.Consequently, in cases of errors you can narrow your search to thoseplaces which are not proven to be correct.PROCEDURE PROGRAM VIEWNow a program can be viewed as a sequence of procedure calls.The main program is responsible to pass data to the individual calls,the data is processed by the procedures and the resulting data ispresented.Thus, the flow of data can be illustrated as a hierarchical graph, atree.PROCEDURE PROGRAM VIEWMain ProgramDataProcedure1Procedure2 Procedure3MODULAR PROGRAMMINGModular programming is subdividing your program into separatesubprograms such as functions and subroutines.With modular programming, procedures of a common functionalityare grouped together into separate modules.A program therefore no longer consists of only one single part. It isnow divided into several smaller parts which interact throughprocedure calls and which form the whole program.Main Program(Also a module)DataData Data1Module2+Data Data2Module1+Data1Procedure1 Procedure2The main program coordinates calls to procedures in separatemodules and hands over appropriate data as parameters.Procedure3Modular ProgrammingMODULAR PROGRAMMINGEach module can have its own data. This allows each module to manage aninternal state which is modified by calls to procedures of this module.Each module has its own special functionalities that supports theimplementation of the whole program.STRUCTURED PROGRAMMINGAlso structured programmingA subset of procedural programming that enforces a logicalstructure on the program being written to make it more efficientand easier to understand and modify.Certain languages such as Ada, Pascal, and dBASE are designedwith features that encourage or enforce a logical programSTRUCTURED PROGRAMMINGThree Types of Structures in a structured programStatement sequence(s1,s2,…,sn)Branch(if-then-else)Loop(for,do, and while loops)Goto (not often used)How many basic structures for programming?OBJECT ORIENTED PROGRAMMINGThe traditional view of programming is that there is some input datawhich must be logically manipulated to produce some output data. Thelogical manipulation should consist of a step by step linear series ofoperations ultimately giving the required answer. Our program willsimply consist of a long list of (hopefully logical) instructions to beperformed.What if we had to do the some portion of the sequence of instructionstwice? Well, we would have to copy the required sequence of commandsto another place in our program. This could lead to large and unwieldyprograms.Additionally if an error is detected in the code then we have to searchthrough and find all occurrences of the erroneous sequence in order tofix the error.OBJECT ORIENTED PROGRAMMINGThis lead on to the idea of extracting useful sequences of commands into a single place(called a function or a procedure). Then in our main section of code we simply call theprocedure, pass in any required data, and the commands of the procedure areprocessed before returning back to the main program with an answer.This simpli.es programming greatly: our code is reduced in size, more organised anderrors corrected in a procedure are automatically .xed for every procedure call. Themain program is responsible for the creation of data and making sure it is the correcttype and format of data for the procedures.Sometimes it makes good sense to group related procedures into a single entity called amodule.The above approach can be problematic (although with diligence and patience, you cansolve any problem using this approach). Something else (i.e. external to the procedure) isresponsible for the creation and destruction of data as well as sending in valid correctlyformatted data. The procedures and the data are decoupled, this tends to lead to afocus on the mechanics of the procedures rather than on the data structures.OBJECT ORIENTED PROGRAMMINGIn OOP data and operations on data (data manipulation) are brought together into a singleentity called an object.Our programs then consist of one or more objects interacting with each other to bring about adesired result.The object is responsible for its data and its data can only manipulated by a predefined list ofacceptable operations.Object orientation aims to emulate the way humans interact with the world around them. Inother words there is presumption that the object oriented approach to problem solving issomewhat akin to the natural approach.Consider a typical day, get out of bed, have a cup of coffee, catch a bus to work, go to arestaurant for lunch, go to your flat, eat your dinner with a knife and fork, watch television etc.It is possible to look on life as a series of interactions with things. These things we call objects.We can view all of these objects as consisting of data (called properties) and operations thatcan be performed on them (called methods). This is thought to closely resemble the way humansperceive the world, thus it is thought that object oriented system models are easier tounderstand.SO WHAT IS AN OBJECT?Tangible Things as a car, printer, …Roles as employee, boss, …Incidents as flight, overflow, …Interactions as contract, sale, …Specifications as colour, shape, …20SO, WHAT ARE OBJECTS?An object represents an individual, identifiable item, unit,or entity, either real or abstract, with a well-defined rolein the problem domain.OrAn “object” is anything to which a concept applies.Etc.21WHY DO WE CARE ABOUT OBJECTS?Modularity – large software projects can be split upin smaller pieces.Re-useability – Programs can be assembled from prewritten software components.Extensibility – New software components can bewritten or developed from existing ones.22THE TWO PARTS OF AN OBJECTObject = Data + Methodsor to say the same differently:An object has the responsibility to know and the responsibility to do.23= +WHAT IS A CLASS?A class is a blueprint that describes an object and defines attributes andoperations for the objectClasses use abstraction to make available only the elements essential todefining the objectClasses use encapsulation to enforce an abstractionWhat the user sees:What is encapsulated://verify language//authenticate PIN//validate account bal//adjust account balWHAT IS AN OBJECT?An object is an instance of a classObjects have the following qualities: Identity: Objects are distinguishable from one another Behavior: Objects can perform tasks State: Objects store information that can vary over time12324512245Object ObjectClassOOP TERMINOLOGYObjects — packet containing data and procedures methods — deliver service message — request to execute a methodClass — template for creating objectsInstance — an object that belongs to a classAbstraction – emphasis on what rather than howEncapsulation — information hiding by objectsInheritance — allowing the reuse of class spec.s class Hierarchy — tree structure inheritance relationsPolymorphism — to hide different implementations

QUALITY: 100% ORIGINAL PAPER – NO PLAGIARISM – CUSTOM PAPER

Leave a Reply

Your email address will not be published. Required fields are marked *