CST06105 - Fundamentals of OOP Software Programming Languages
This document provides an overview of object-oriented programming and compares it to procedural programming. It discusses key concepts in OOP like classes, objects, inheritance and libraries. It also contrasts OOP with event-driven programming and machine-oriented languages. The document is from a lecture on fundamentals of OOP that discusses its advantages over conventional programming approaches.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
15 views26 pages
CST06105 - Fundamentals of OOP Software Programming Languages
This document provides an overview of object-oriented programming and compares it to procedural programming. It discusses key concepts in OOP like classes, objects, inheritance and libraries. It also contrasts OOP with event-driven programming and machine-oriented languages. The document is from a lecture on fundamentals of OOP that discusses its advantages over conventional programming approaches.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26
CST06105 – Fundamentals of OOP
Lecture 2 Software Programming Languages
Dr. Msury Mahunnah
e-mail: [email protected] course website: https://mahunnah.wordpress.com/ Background • The fist object oriented language was called Simula 67 • It was developed in the 1960’s by the Norwegian Computing Centre • Simula 67 contained most of the important concepts and techniques used in present day object-oriented languages • Research then progressed and led to languages like C++, Visual Basic and many others • The popularity of such languages was enhanced by the increasing use of GUI’s and windows applications Conventional Programming • Conventional methods of programming used imperative languages, where programs were written in terms of procedures • Programs were sequential, running to completion branching and loping according to the programs instructions • A flaw in this type of program was that large programs became complex and unmanageable • Also global variables could be accessed and changed during execution so results might no be valid Modern Programming • Today programming is done in and for a windows environment • Windows is an event driven environment and user interaction is required to represent the programming • Procedural languages do not possess the necessary constructs to deal with this style of programming and are unsuitable for windows applications • Object-oriented programming techniques overcome these difficulties and make it easier for the programmer to implement good programming practices Object-Oriented Programming • This is a programming methodology • It compels the programmer to think in a different way about software and its development • OO programming enables the creation of software that can be more readily understood and shared • OO programming directly models the program and is centred around objects and data associated with them Objects • An object is a logical unit that contains both data and the code that manipulates it • The 2 are regarded as a single unit • Objects steams from techniques with attempting to solve real-life events employing everyday objects • Objects share 2 characteristics, they have: – A state (data) – A behaviour (operations)
Object State Behaviour
Dog Size, name, colour, breed Barking, playing, sniffing,
hunting
Car Make, model, colour, Accelerating, braking,
engine size reversing, gear changing Desk Characteristics • A desk – You know where it is, it has a certain size and colour – If we move the desk we change the location property, if we paint it we change the colour property – When we change the attributes of a desk we don’t change the fact that it is still a desk Object Characteristics • Windows objects contain 2 parts: – Attributes (data) – Operations (methods) • Here is a schematic view of an object
Objects communicate with one another using messages
Classes • Objects of the same kind share many characteristics – A car is just one of many cars • A Blueprint can be produced to accommodate objects, such a blueprint is called a Class • Using OO terminology a car object is an Instance of the class of objects known as cars • A main class or Super-class can have Sub-classes where all sub-classes have common features based on the super-class • The art of OO programming is determining the best way to divide a program into classes speeding up the development time and producing fewer lines of code meaning less errors and lower maintenance costs Car Example • Suppose there exits a class called Car that contains instances of types of cars, such as four-wheel drive, saloon • The class car would become a super-class and the various types of car become sub-class Libraries • OO Languages depend greatly on the concept of Class Libraries • These are sets of classes that can be used by developers as common building blocks for complex applications • This is like the idea of module libraries used in procedural programming Procedural Languages • In the procedural language the program is considered as a series of blocks of code that process collections of data • Programs carryout processing according to a defined sequence of events until the program terminates
Similarities of Object-Oriented and Procedural:
OO languages have all the high level control structures for iteration and selection available to procedural languages OO languages operate by changing values of variables by using assign statements Both languages are problem specific Differences • Differences of Object-Oriented and Procedural: – Object-Oriented concepts are harder to learn – In procedural language a program module is a free standing unit that can be compiled and executed. In OO language a module is always part of a hierarchy – In OO programming data and code are not regarded as separate, both are encapsulated into an object that consists of data and operations – Assignment statements may look the same but their interpretation is different – If a program written in a procedural language encounters a problem and crashes that is the end of the program. In OO language if an error occurs in the code for a specific object then only that object will be affected, the program will continue to operate Event Driven Languages • With the increasing use of GUI’s new event driven languages, like Visual Basic, have emerged to accommodate the new style of programming • Since GUI’s are object based then object-oriented techniques feature in this environment • In event driven environments the user executes an event procedure, such as clicking a mouse, to run part of the code • Event driven programs are also referred to Asynchronous Programming as the computer waits for an event to occur and responds to them as they happen Event Dispatcher • An event driven program consists of smaller procedures that respond to events triggered by the user • These procedures are called event handlers and are executed by a program called a Dispatcher • The event dispatcher is called whenever an event is triggered • The dispatcher can be regarded as a large programming loop that waits for an event to occur then responds accordingly • If an event is triggered while others are being processed then it is put into an Event Queue and all events in the queue are processed in order Event Driven Programming • Event-driven programs do not have a set sequence of instructions to execute • Event programming an object-oriented programming are linked in GUI systems • Languages like Visual Basic provide support for event-driven programming through the use of objects, classes and methods • Inputs to event-driven programs come from event sources that require individual event handlers to process them • Object-oriented programming techniques are evident in GUI programming and work in harmony with event-driven procedures • It is difficult to distinguish between object-oriented and event-driven programs Machine Oriented Languages • At low level the focus is on the computer rather than the problem • There is only 1 programming language that any computer can understand and execute, that is binary machine code • This is the lowest possible level of language • An enhancement to binary was assembly code, it used simple mnemonics to represent actions • These mnemonics varied from computer to computer as each had a different Instruction Set relating to the processor • Machine code and assembly code are machine dependant and are referred to as Machine-Oriented Languages • Low level languages run very fast and make efficient use of the computers resources, however they have no high level features available to them Low Level Languages • Low level languages are: – Machine dependant – Difficult to program and debug – Not complied or interpreted – Demand a large expense of time on the part of the programmer – Contain no high level constructs – Execute extremely fast – Produce lines of code that have a 1:1 relationship with machine instructions Machine Code • This was the first code used to program a computer • Machine instructions were in binary form consisting of opcodes (operational codes and addresses) • A 16-bit instruction may have had the following structure 0001 000100110001 Op Code Address
The main problems associated with machine code were:
• Programs would only run on specific machines • Low level programs were not easy to read , maintain or adapt • Programmers found it difficult to remember opcodes Assembly Code • Assembly language programming addressed the problem of remembering all the opcodes • A mnemonic responded to the type of operation, this made writing and debugging programs easier • Mnemonics have to be translated into machine code before the processor can carry out instructions, this was achieved using an Assembler – An assembler is a program designed to produce machine code • Assembly language programs have fast execution and make efficient use of computer resource • An assembly code statement has a 1:1 relationship with a machine language statement High Level Languages • It became apparent that language development should now include operations more suited to the application program instead of hardware • That lack of portability between different computers was a deciding factor in the development of HLL’s • High level, imperative languages were designed as block-structured (procedures) and the lines of code resembled English sentences and mathematical expressions, that were much easier to read and debug • Each line of high level code translated into 10-20 lines of low level code allowing programmers more flexibility • HLL had slow execution times since they had to be translated HLL Advantages • The use of HLL started the programming revolution and offered many advantages: – The use of statements and keywords using English words – Access to high level control structures, such as selection & iteration – The use of high level data structures such as arrays, records and files – The capability of defining types and dynamic data structures, such as stacks and queues The Computing Explosion • Progression through the 1960’s and 70’s seen a dramatic increase in: – the number of programming languages – the need to write easier and faster error-free programs • Other notable factors in this increase were: – Compiler techniques were becoming more refined – Escalation of new hardware technologies – Expansion of specialised software applications • Programs ran with reduced efficiency but with decreasing costs and increasing hardware speeds 4th Generation Languages • 4GL’s were developed to meet the special needs of data processing, with such applications as DB, SS and GR • They were non-procedural and designed in a way that users could specify the nature of the problem in a simple manner without having to understand the computer processing • Most 4GL’s were written for specific purposes: – Database application tools – End-user tools like query languages – Report generators – Application generators, sometimes known as RAD (Rapid Application Development) • 4GL’s have evolved and are now responsible for many of the built-in features that can be access from a menu or icon in GUI systems Beyond 4GL • The terms 4GL and now 5GL are used to define stages in computer language development • There are various 5GL’s that exist: – Natural language systems involved in Artificial Intelligence – They encompass event-driven, object-oriented and GUI’s – 5GL is programming that uses a visual or graphical interface to create source code • With the rapid use of the Internet web-based languages were developed, they include scripting and mark-up languages Language Criteria • The criteria that might be used to decide if a language is popular is: – It should be available to run on a variety of hardware – It should be easy to learn – It should be simple to implement – It should require modest computer resources – Its code should be efficient at running