Introduction to Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically.

Slides:



Advertisements
Similar presentations
Looking inside classes Fields, Constructors & Methods Week 3.
Advertisements

Object Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
Classes & Objects Computer Science I Last updated 9/30/10.
Object-Oriented Analysis and Design
CM10134-CM50147 Programming I Basic Programming in Java Marina De Vos.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
Objects First with Java A Practical Introduction using BlueJ
1 Basic Object Oriented Concepts Overview l What is Object-Orientation about? l What is an Object? l What is a Class? l Constructing Objects from Classes.
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
Programming with Objects Creating Cooperating Objects Week 6.
Understanding class definitions – Part II –. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 9 Thinking in Objects.
CSC 111 Course orientation
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
Chapter 8: Introduction to High-Level Language Programming Invitation to Computer Science, C++ Version, Fourth Edition.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Programming with Objects Object Interaction (Part 1) Week 9.
Object Oriented Software Development
Chapter 7 Designing Classes. Class Design When we are developing a piece of software, we want to design the software We don’t want to just sit down and.
1 Programming James King 12 August Aims Give overview of concepts addressed in Web based programming module Teach you enough Java to write simple.
M1G Introduction to Programming 2 1. Designing a program.
BCS 2143 Introduction to Object Oriented and Software Development.
Writing Classes (Chapter 4)
Programming 1 1. Introduction to object oriented programming and problem-solving.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Object Oriented Design: Identifying Objects
Java Classes Using Java Classes Introduction to UML.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Introduction to Java. 2 Textbook David J. Barnes & Michael Kölling Objects First with Java A Practical Introduction using BlueJ Fourth edition, Pearson.
OBJECTS AND CLASSES CITS1001. Concepts for this lecture class; object; instance method; parameter; signature data type multiple instances; state method.
1 COS 260 DAY 1 Tony Gauvin. 2 Agenda Class roll call Instructor Introduction Instructor’s Educational Philosophy Contract on Classroom Behavior Syllabus.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 5.0.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Introduction to Object-oriented Programming Java API.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
INM205 Object Oriented Programming in JAVA Dr. Michael Casey Department of Computing.
1 OO Analysis & Design - Introduction to main ideas in OO Analysis & design - Practical experience in applying ideas.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Next Back MAP MAP F-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All.
Programming. To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically assess the.
Software development For large and complex software use divide and conquer rule. Software design methods: Structured design Object-Oriented design.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 24, 2009.
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.
Chapter 11 An introduction to object-oriented design.
6.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
3-July-2002cse142-D2-Methods © 2002 University of Washington1 Methods CSE 142, Summer 2002 Computer Programming 1
Objects as a programming concept
Objects as a programming concept
Objects and Classes CITS1001 week 1.
COS 260 DAY 1 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
Objects as a programming concept
The Object-Oriented Thought Process Chapter 1
Object Oriented Programming
Objects First with Java A Practical Introduction using BlueJ
COS 260 DAY 2 Tony Gauvin.
Defining Classes and Methods
Objects First with Java A Practical Introduction using BlueJ
Workshop for Programming And Systems Management Teachers
Objects First with Java A Practical Introduction using BlueJ
Handout-2(a) Basic Object Oriented Concepts
Presentation transcript:

Introduction to Programming

To gain a sound knowledge of programming principles To gain a sound knowledge of object- orientation To be able to critically assess the quality of a (small) software system To be able to implement a (small) software system in Java Module Overview GOALS

Objects and classes Data types Constructors & methods Assignment - accessor & mutator methods Making choices: the conditional statement Object types & passing by reference Object interaction Repetition: using loops Collections: using array lists and arrays Module Overview TOPIC AREAS

Module Text Book BARNES & KOLLING Available from the university bookshop David J. Barnes & Michael Kölling Objects First with Java A Practical Introduction using BlueJ Fourth edition Pearson Education, 2008

Objects and Classes Week 1

Software development In order to design and build something complex, it is necessary to put some thought into how to break down the design into smaller chunks that are more easily dealt with. In software design, the most common methods are called Structured Design and Object- Oriented Design. Object-Oriented Design is the most recent type of development and the Java language is itself designed to support this type of design.

Object Oriented Design (OOD) Objects In OOD, a design is made up of a number of objects that may represent real-life objects and how they interact. These objects are comprised of two parts: attributes and methods. Attributes are data items that are associated with the object and methods are pieces of functionality. In other words attributes describe something about the object and methods are things that it can do, or have done to it. Classes In order to use an object we first define what that object is by means of a class description. A class description defines a type of object in terms of its attributes and methods. A class describes what all objects of a particular type have in common. Classes are the blueprints or templates for objects. Classes are used to create objects.

Specifying a class - Dog class what do dogs have in common? What attributes do dogs have? What behaviours do dogs have?

Dog class diagram Dog name colour size run sit bark bite eat attributes fields behaviours methods The Dog class is a template or blueprint for creating dog objects

Dog objects - instances of the class Dog class scooby snoopy mutley lassie From the Dog class we can create individual dog objects

Object State Each object has its own state. Its state is the values that the attributes are set to, which can be different from other objects of the same type State Methods Dog name scooby colour brown size big run() sit() bark() name snoopy colour white size small run() sit() bark() I am an object

Sending messages to objects - invoking methods We get objects to do things by calling their methods snoopy.run() calls the run() method on the object snoopy

Passing parameters to methods Sometimes when we call a method we need to pass some data to the method, to tell it exactly what to do. snoopy.run(10) scooby.bark(“loud”) scooby.sit(), snoopy.run() actual parameters

Object Orientation Advantages Reuse - Once we have defined a class we can use it over and over again to create many different objects of that type e.g. Dog class, BankAccount class Reuse - Once we have defined a class - someone else can use that class to create objects - so we can create class libraries Encapsulation - we can create objects from a class and use its behaviours without needing to know the internal details of how it works Reuse - when defining new classes we can compose classes from other existing classes to create complex objects

an object that is made up of other objects! Wheels, Seats, Chassis, Exhaust, Steering Wheel, etc, etc... Is this Aston Martin DB4 a Complex Object? And… a wheel itself is also a complex object! Tire, Trim, Hub Cap, etc, etc... WHAT IS A COMPLEX OBJECT? Object Model

CAR TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM TIRE HUB CAP TRIM CHASSIS WHEEL SEAT REGISTRATION NUMBER Object Model

BlueJ Demonstration

Object – Represents an actual thing! Class – ‘Blueprint’ for making an object Method – Things an object can do (behaviour) Parameter – input required by an object method Data type – what type of data is allowed! Object Model Basics FUNDAMENTAL CONCEPTS

Many objects (instances) can be created from a single class. An object has attributes (fields), and those attributes have values assigned to them. the class defines what fields an object has, but each object stores its own set of values (state) Each class has source code (Java) associated with it that defines its fields and methods. Object Model Basics OTHER OBSERVATIONS

Object Model Basics STATE

Object Model Basics OBJECT INSTANCES

Required Reading Objects First With Java – A Practical Introduction using BlueJ Chapter 1 pp 1-9 (Objects and Classes)