1 Types of Data Fundamental data type (atoms, primitive) –integers, characters Data structures- fundamental data types grouped in a particular way –Employee.

Slides:



Advertisements
Similar presentations
Business Planning using Spreasheets-2 1 BP-2: Good Spreadsheet Practice  There is always the temptation to rush in and start entering data.  However.
Advertisements

Topics Introduction Types of Errors Exceptions Exception Handling
Overview of Data Structures and Algorithms
Chapter 3: Modularization
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
1 / 89 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 11 Programming Fundamentals using Java 1.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Process Specifications and Structured Decisions Systems Analysis and Design, 8e Kendall.
Road Map Introduction to object oriented programming. Classes
VBA Modules, Functions, Variables, and Constants
Chapter 9 Describing Process Specifications and Structured Decisions
High-Level Programming Languages
Terms and Rules Professor Evan Korth New York University (All rights reserved)
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
An Overview of Programming Logic and Design
Introduction to a Programming Environment
Modules, Hierarchy Charts, and Documentation
Chapter 1 Program Design
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
C++ fundamentals.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
Object Oriented Software Development
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 Using Classes Object-Oriented Programming Using C++ Second Edition 5.
Array.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Technology in Action Chapter 10 Behind the Scenes: Software Programming Copyright © 2014 Pearson Education, Inc. Publishing as Prentice Hall.
Programming Translators.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Chapter 06 (Part I) Functions and an Introduction to Recursion.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
CSE 219 Computer Science III Program Design Principles.
What does a computer program look like: a general overview.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Lecture 4 Programming Technique Programming Appreciation.
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
Applications Development
Handling Exceptions. 2 home back first prev next last What Will I Learn? Describe several advantages of including exception handling code in PL/SQL Describe.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Chapter 3: Developing Class Methods Object-Oriented Program Development Using Java: A Class-Centered Approach.
Introduction to Object-Oriented Programming Lesson 2.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
1 Exceptions. 2 Syntax Errors, Runtime Errors, and Logic Errors syntax errors, runtime errors, and logic errors You learned that there are three categories.
Controlling Program Flow with Decision Structures.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Copyright © 2011 Pearson Education Process Specifications and Structured Decisions Systems Analysis and Design, 8e Kendall & Kendall Global Edition 9.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
Exceptions in OO Programming Introduction Errors Exceptions in Java Handling exceptions The Try-Catch-Finally mechanism Example code Exception propagation.
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Introduction to Algorithms
Functions + Overloading + Scope
Object-Orientated Programming
Classes and OOP.
Java Primer 1: Types, Classes and Operators
About the Presentations
Introduction to Algorithms
Topics Introduction to Functions Defining and Calling a Function
CMSC 202 Exceptions.
Chapter 4: Writing and Designing a Complete Program
Presentation transcript:

1 Types of Data Fundamental data type (atoms, primitive) –integers, characters Data structures- fundamental data types grouped in a particular way –Employee record name salary address

2 Methodologies A methodology deals with the arrangement of the data and the algorithm Monolithic (block) Structured (procedural) Object Oriented (encapsulated)

3 Why have different methodologies evolved? Not for reasons of functionality Reduce code cost –To support development in teams –To reduce the possibility of errors –To reduce the cost of maintenance by making the program easier to understand –To support reuse of code (if code is written correctly) –To protect the integrity of data

4 Monolithic-Company example, sole trader Functions: One person does everything, there is no need for formally defined heirarchy/ rules/ procedures,etc. So may not have any distinct methods (blocks) Data: One data store (filing cabinet) is used for everything

5 Structured- Company example, small business Functions: Employees have job descriptions/ titles therefore they can be replaced/ retrained with little problem. So there are distinct functions/ methods (workOutVat, sendInvoice, makeSale) Data: Data is still stored in a filing cabinet which everyone can access (this allows unchecked access to data)

6 Object Oriented- Company example – multinational –Functions: Employees have job descriptions. Employees are grouping according to their task (e.g. all sales staff are put in the same room). Functions are grouped with the employee (Accountant – calculateTax, calculateIncome: SalesManager – makeSale, sendAdvert) –Data: Filing cabinets are the property of a staff group and access to these cabinets is controlled by members of the group (e.g. if the production manager wanted sales figures for this month they must contact a member of the sales group to unlock the file and get the data). Members of the group can therefore decide whether to permit or deny access to data.

7 Object Oriented Program Object Oriented means a program uses objects to carry out its task. It creates objects (either automatically or explicitly), stores data in them, gets objects to carry out tasks, etc. A program therefore consists of a group of objects which can communicate with each other. These objects are created from classes. An object oriented program is written using classes to describe the objects that will be created when the program executes. So an object oriented program consists of one or more classes.

8 Object Oriented Program When an Object Oriented Program is executing it consists of a main object, which is started first, and possibly other objects which are created by the main object or the runtime environment. The main object uses the other objects in the program to carry out the relevant tasks.

9 Object Oriented Program To write an Object Oriented Program 1. Need to define main class 2. Need to identify classes the main class would use (these classes in turn may need to use other classes and so on) and write them if necessary Main class Class1 Class2 Class3 Class4

10 Object Oriented Program To run an Object Oriented Program 1. Need to create an object from the main class 2. This main object then creates all the other relevant objects and uses them Main object object of Class1 object of Class2 object of Class3 object of Class4 object of Class1

11 Analogy A manager (main object) creates a team of workers (objects) who in turn may create other teams of workers (objects) Each object is separate but they have a relationship with each other.

12 Analogy E.g. manager object can order worker object to perform task but worker cannot order other worker to perform task unless that worker controls them. Each object controls access to their data E.g. work will divulge phone number (public information) but not ATM password (private information)

13 Analogy Manager worker2 managed by manager worker1 managed by manager worker3 managed by worker1 worker4 managed by worker1

14 Data access in an object To get access to data in an object you can do the following: 1.Contact a function (called a method in OO) in the object which will get the data for you 2.Obtain the data directly from the object without having to go through a method (this goes against the idea of OO but is necessary on rare occasions). You MUST minimise these scenarios. If you want to use 1 declare a piece of data as being private For 2 declare a piece of data as being public

15 Data access in an object When writing a class must make a decision for each item of data/ function. –Should item be public/private? Guideline is declare element private unless convincing reason otherwise. Should only declare data as public in exceptional circumstances

16 Encapsulation Protecting data by keeping it among only a specific predefined group of functions is called encapsulation (aka data hiding). Why is it important to protect data? Imagine a variable which holds an age. If other parts of the program are free to alter the age they may alter it incorrectly (e.g. you may have a negative age). When the pension calculator program runs into a negative age unpleasent things are going to happen. However if no one can change the age without having the change approved then mistakes can be avoided.

17 Programming Language A programming language supports a methodology, it does not enforce it (e.g. you could use an oo language to write a non-oo program) Need programmer discipline or written guidelines (pattern)

18 Entry point Every program has an entry point. Could be: –First instruction encountered –A single named section of the program (e.g. ‘main()’) –Multiple named sections of the program (e.g. start, init, paint)

19 Flow of control Which instruction is executed next? This is called the flow of control of the program Some programs work sequentially, i.e. the next instruction is the one following the current one or the one named in a jump Some programs are event based, i.e. there are several possible events defined and different instructions associated with each. An example of an event would be a button being pressed.

20 Errors Syntax errors – mistake in grammer or spelling – picked up by the compiler Algorithmic error – program will compile but will not work as anticipated due to mistake in code – picked up by the programmer/ tester Runtime error – invalid operation, not noticed by compiler (e.g. divide by zero) – picked up by runtime environment (Java is a friendlier runtime error handler than other programming languages)

21 Phases involved in developing an Object Oriented program Decide what objects there should be (if any) Write the definition for these objects Write the ‘main’ program (class) which creates and uses the relevant objects