HST 952 Computing for Biomedical Scientists Lecture 2.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

When is Orientated Programming NOT? Mike Fitzpatrick.
Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Object-Oriented Programming (OOP) Lecture No. 6
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
Classes and Instances. Introduction Classes, Objects, Methods and Instance Variables Declaring a Class with a Method and Instantiating an Object of a.
Fall 2007ACS-1805 Ron McFadyen1 Programming Concepts Chapter 4 introduces more advanced OO programming techniques. Construction of a programs usually requires:
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Java CourseWinter 2009/10. Introduction Object oriented, imperative programming language. Developed: Inspired by C++ programming language.
C++ fundamentals.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
2.5 OOP Principles Part 2 academy.zariba.com 1. Lecture Content 1.Polymorphism 2.Cohesion 3.Coupling 2.
Introduction To System Analysis and design
A First Program Using C#
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
MIT AITI 2002 Abstract Classes, Interfaces. Abstract Classes What is an abstract class? An abstract class is a class in which one or more methods is declared,
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Microsoft Visual Basic 2005: Reloaded Second Edition
Introduction to Object-oriented programming and software development Lecture 1.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
An Object-Oriented Approach to Programming Logic and Design
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
CONCEPTS OF OBJECT ORIENTED PROGRAMMING. Topics To Be Discussed………………………. Objects Classes Data Abstraction and Encapsulation Inheritance Polymorphism.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
POS 406 Java Technology And Beginning Java Code
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
JAVA COURSE 1 Computer Engineering Association. Compile your first program Public class Hello{ public class Hello(){ System.out.println(“Hello”); } puclic.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Java Programming Dr. Randy Kaplan. Abstract Classes and Methods.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
IT108 Objects and Classes Part I George Mason University Revised 4/3/2012.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Object-Oriented Systems Analysis and Design Using UML Systems Analysis and Design,
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,
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
OOP Basics Classes & Methods (c) IDMS/SQL News
COMPUTER SCIENCE & TECHNOLOGY DEGREE PROGRAMME FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UVA WELLASSA ‏ Properties of Object Oriented Programming.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
 The word static is used to declare either a ________ variable or method.  Why do we use statics?  What is Polymorphism? class In general, we use a.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Object-Oriented Programming
Modern Programming Tools And Techniques-I
Advanced Object-Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Object oriented vs procedural programming
Object Oriented Analysis and Design
Object-Oriented Programming
Presentation transcript:

HST 952 Computing for Biomedical Scientists Lecture 2

Object Oriented Programming In this course, we will examine imperative, object-oriented programming (OOP) using Java Imperative OOP: objects issue commands Object: an entity (car, dog, house, person, etc.) In OOP, data and the methods for manipulating the data are grouped together in an object

Object Oriented Programming To create an OO program we need to identify –all the objects that we want to manipulate –the properties that these objects have –how these objects relate to/interact with each other This process is called data modeling Example problem: scheduling final exams for four courses that have some of the same students so that no two students have an overlapping exam

Object Oriented Programming Objects are defined using classes -- an object is an instance of a class Each class specifies attributes (properties) of an object and the object’s behavior (via methods) An object can perform actions by invoking methods defined in its class

Object Oriented Programming To perform a task, find an object and send it a message (a message is a request to perform a method) If no appropriate object is available, create one using an already defined class If no class is available that does what you want, write a new class

A simple Java class import java.io.*; /* The SimpleProgram class implements an application * that displays “Hello world!” to the standard output */ public class SimpleProgram { public static void main(String[] args) { // Display the words “Hello world!” System.out.println(“Hello world!”); } Must be saved in a file called SimpleProgram.java

Object Oriented Programming OOP follows three main design principles: 1. Encapsulation (information hiding) –Users of an object see only what is absolutely necessary for using that object –As an abstraction mechanism, encapsulation frees us from the details of a particular implementation of an object –We can focus on what an object can do (its interface) rather than how it does it

Object Oriented Programming 2. Polymorphism (e.g., method overriding) –an instruction (via a single method name) can be issued using different types of objects –different actions are performed depending on the objects used –E.g., draw method for a shape will depend on the specific shape object (square, circle, triangle)

Object Oriented Programming 3. Inheritance - means by which classes that have common or overlapping properties can have those properties specified just once –can base a new class on an existing class with more general properties: e.g., base “student” on “person” –common or base class is the superclass –new (derived) class is the subclass –subclass is usually a specialization of the superclass

Object Oriented Programming Health care professional EMT NurseMedical doctor Physiotherapist Pharmacist SurgeonRadiologist Pediatrician

Object Oriented Programming Problem: Given a list of shapes, draw them Non-OO procedural programming approach (e.g. C, Pascal): for each shape, s in the list if s is a square specify square drawing code else if s is a rectangle specify rectangle drawing code else if s is a circle specify circle drawing code

Object Oriented Programming Problem: Given a list of shapes, draw them Imperative OOP approach (e.g. Java, C++): for each shape, s s.draw() There is a base shape class with a draw method Each subclass of shape implements its own version of the draw method so it knows how to draw itself

Object Oriented Programming If we add a new shape to the list using the procedural approach, need to add another conditional statement and code for drawing it If we add a new shape in the OOP approach, we need to implement its draw method

OO Modeling Problem A bakery shop sells 5 different types of pastries and orders common ingredients used to make all pastry types each week. While all the pastries require flour, butter, sugar, and eggs, each of the five types of pastries uses one additional ingredient that the other four don’t. Common ingredients are ordered once a week. The store’s sales register program tracks the number of each type of pastry made, the number sold, and the number still available. The store would like you to add automated re-ordering methods to the sales register program for each pastry’s special ingredient: When the store has only 10 of a particular type of pastry left, an electronic order for its special ingredient should be generated to the particular store that sells this ingredient.

Homework 1 Download jdk1.4.2 using links from course web page Write your program (problem 1) using a simple text editor such as Notepad, emacs or vi Submit electronic version of homework to To get started running Java on Unix/Linux, MacOS, or Windows, please first read java/index.html

Homework 1 To set your PATH and CLASSPATH variables for Java on Windows 95 / 98 / 2000 / ME / NT please first read: To set your PATH and CLASSPATH variables for Java on Unix/Linux please first read:

Before Next Class Read Chapter 3 of Java text