CS 340 DATA STRUCTURES Instructor: Xenia Mountrouidou.

Slides:



Advertisements
Similar presentations
Object Oriented Programming with Java
Advertisements

All I Ever Need to Know about Testing I Learned in Kindergarten Column by Lee Copeland As presented by Andy Sawyer.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Roles Within Institutions
CS 211 Inheritance AAA.
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
Inheritance Inheritance Reserved word protected Reserved word super
OBJECT-ORIENTED PROGRAMMING. What is an “object”? Abstract entity that contains data and actions Attributes (characteristics) and methods (functions)
Lab#1 (14/3/1431h) Introduction To java programming cs425
ITEC200 – Week03 Inheritance and Class Hierarchies.
Liang,Introduction to Java Programming,revised by Dai-kaiyu 1 Chapter 10 Object-Oriented Modeling.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
For more Lectures and Notes Visit
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
ISE 582: Web Technology for Industrial Engineers University of Southern California Department of Industrial and Systems Engineering Lecture 4 JAVA Cup.
1 Object Oriented Programming Computer Systems Engineering (D2) and Programming (P)
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Advanced Inheritance Concepts. In this chapter, we will cover: Creating and using abstract classes Using dynamic method binding Creating arrays of subclass.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Object Oriented Software Development
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
Programming Languages and Paradigms Object-Oriented Programming.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
CS 106 Introduction to Computer Science I 04 / 13 / 2007 Friday the 13 th Instructor: Michael Eckmann.
CS 450 MODELING AND SIMULATION Instructor: Dr. Xenia Mountrouidou (Dr. X)
CS 150 PERSONAL PRODUCTIVITY USING TECHNOLOGY Instructor: Xenia Mountrouidou.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Lecture Objectives  Learn what is an ADT, why is it useful  Understand algorithm efficiency  Use Eclipse for coding and testing  Understand and use.
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.
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.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
JAVA BASICS Prepared by The Smartpath Information Systems
Address to the FCBA by Commissioner Kevin J. Martin February 1, 2001.
C# F 1 CSC 298 Object Oriented Programming (Part 1)
Getting Ready for Kindergarten At Carrville Mills P.S.
Object-Oriented Design CSC 212. Announcements This course is speeding up and we are starting new material. Please see me if you feel this is going too.
By Robert Fulghum Wisdom was not at the top of the graduate school mountain, but there in the sandpile at Sunday School. ALL I REALLY NEED TO KNOW ALL.
Grade 9 Human Sexuality Course. Self-concept Self-concept: According to our textbook, self- concept is the mental image you have about yourself. It is.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Coming up: Inheritance
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
OOP Basics Classes & Methods (c) IDMS/SQL News
SUBCLASSES - JAVA. The Purpose of Subclasses Class Farm String getOwner() void setOwner(String s) int getSize() void setSize(int s) Class DairyFarm String.
All I need to know I learned in Kindergarten by Robert Fulghum.
Open Source Community Chris Donley.
Objects as a programming concept
Chapter 11 Object-Oriented Design
Data Structures and Algorithms
CS240: Advanced Programming Concepts
"All I Ever Really Needed to Know I Learned in Kindergarten"
All I Really Need to Know I Learned in Kindergarten
Polymorphism and access control
CISC/CMPE320 - Prof. McLeod
Introducing Java.
"All I Ever Really Needed to Know I Learned in Kindergarten"
Presentation transcript:

CS 340 DATA STRUCTURES Instructor: Xenia Mountrouidou

Course Objectives  At the end of this class you will be able to:  Make design decisions on which data structure is best to use regarding performance, memory, and implementation efficiency.  Devise or use the most efficient algorithm in your projects.  Understand algorithmic complexity.  Think analytically and identify complexity of a program. 2

Course Objectives (cont.)  At the end of this class you will be able to:  Apply object oriented programming principles when you develop software.  Use and understand third party code.  Detect inefficiency of data structures and algorithms of third party code.  Develop projects using agile test driven approach (Junit).  Employ the Java API. CS 340 3

Why do you need CS 340?  Scenario:  You are a senior developer for e-bay.  You are working on their e-commerce application server!  You drop code, you are a java guru, OO programming is second nature to you… but you do not understand data structures and algorithms.  BIG DEAL! Everything runs perfectly. Until one day…  You need to use a sorting algorithm to sort all potential sellers of a product based in price or ranking. CS 340 4

Why do you need CS 340?  Scenario (cont.):  On every click for a product search, your sorting algorithm will be used.  You choose bubble sort. After all, it has a cool name!  Let’s see what happens:  Software is not just coding… It is design, performance, memory consumption It is an art, a riddle to be solved with every project CS 340 5

Lectures  We meet at 15:00-16:45, every Tues/Thurs, at Merritt Penticoff Science Bld, Room 130  Attendance will have a part in your grade.  Attendance means: active participation!  Check the schedule in our webpagewebpage  Reading and examples will be posted online.  Check the webpage for news frequently. CS 340 6

How to get help  Join my office hours!  Join the conversation on Piazza.  Check our website frequently.  Use the textbook:  “Data Structures: Abstraction and Design Using Java”, Second Edition by Elliot B. Koffman, Paul A. T. Wolfgang  Experiment with code. It’s fun… CS 340 7

Grading  Homework and Programming projects will be posted online CS 340 8

Programming Projects  They involve  Design  Coding  Testing  Debugging  Some of these can be done in pairs  Both team members will need to answer detailed questions about the implementation  Each team member will evaluate his/her team mate CS 340 9

Principles of Pair Programming CS

12 Principles of Pair Programming  All I Really Need to Know about pair programming I Learned in Kindergarten  Share everything.  Play fair.  Don’t hit people.  Put things back where you found them.  Clean up your own mess.  Don’t take things that aren’t yours.  Say you’re sorry when you hurt somebody. CS 340

13 Principles of Pair Programming  Wash your hands before you eat.  Flush.  Warm cookies and cold milk are good for you.  Live a balanced life – learn some and think some and draw and paint and sing and  Dance and play and work every day some.  Take a nap every afternoon.  When you go out into the world, watch out for traffic, hold hands and stick together.  Be aware of wonder. CS 340

Policies  Read the collaboration policy carefully.  Late policy:  1 st day late: 10% off  10% is reduced by every day the homework is late CS

Java… a bit of history CS

16 Java timeline  CS 340

17 Java Design Goals  Simple, object oriented, and familiar  Robust and secure  Architecture neutral and portable  High performance  Interpreted, threaded, and dynamic CS 340

17 Java abbreviations  JDK: Java Development Kit  JSDK: Java Servlet Development Kit  JVM: Java Virtual Machine  J2EE: Java Platform, Enterprise Edition. A widely used platform for server programming. CS 340

OOP or… Object Oriented Programming 18 CS 340

Object-Oriented Programming  Object-oriented programming (OOP) is popular because:  enables reuse of previous code  saves time  If a new class is similar to an existing class, the existing class can be extended  This is called inheritance CS

20 Java is object oriented  Old programming languages:  code was executed line by line and accessed variables or records  Java  objects that come with their own methods  When coding in Java one is always thinking about “which object is running this code?” CS 340

Inheritance  Meat is a Food  Meat has all the data fields and methods defined by Food  Food is the superclass of Meat  Meat is a subclass of Food  Meat may define other variables and methods that are not contained in Food Food expirationDate() Meat percentageOfProtein() CS

A Superclass and Subclass Example  Robot  A robot has a  manufacturer  processor  disk  parts  processor speed CS Write the robot class

A Superclass and Subclass Example (cont.)  Robot  A robot has a  manufacturer  processor  disk  parts  processor speed Robot String manufacturer String processor int diskSize int numberOfParts double processorSpeed CS

A Superclass and Subclass Example (cont.) Robot String manufacturer String processor int diskSize int numberOfParts double processorSpeed int getDiskSize() double getProcessorSpeed() int getParts() String toString() CS

A Superclass and Subclass Example (cont.)  Cylon  A Cylon has all the properties of Robot,  manufacturer  processor  disk  parts  processor speed  plus,  vision (pixels)  hands (battle speed) CS What is a Cylon class?

A Superclass and Subclass Example (cont.) Cylon double pixels double battleSpeed Robot String manufacturer String processor int diskSize int numberOfParts double processorSpeed int getDiskSize() double getProcessorSpeed() int getParts() String toString() CS

A Superclass and Subclass Example (cont.)  The constructor of a subclass begins by initializing the data fields inherited from the superclass(es) super(man, proc, parts, disk, procSpeed); which invokes the superclass constructor with the signature Robot(String man, String processor, int parts, int disk, double procSpeed) CS

A Superclass and Subclass Example (cont.) /** Class that represents a robot */ public class Robot { private String manufacturer; private String processor; private int numParts; private int diskSize; private double processorSpeed; public Robot(String man, String processor, int numParts, int disk, double procSpeed) { //constructor manufactuer = man; this.processor = processor; this.numParts = numParts; diskSize = disk; processorSpeed = procSpeed; } 28 Write the methods’ code

A Superclass and Subclass Example (cont.) public double getProcessorSpeed() { return processorSpeed; } public int getDiskSize() { return diskSize; } public int getParts() { return numParts; } public String toString() { String result = "Manufacturer: " + manufacturer + "\nCPU: " + processor + "\nBody parts: " + numParts + "\nDisk: " + diskSize + " gigabytes" + "\nProcessor speed: " + processorSpeed + " gigahertz"; return result; } CS

A Superclass and Subclass Example (cont.) public class Cylon extends Robot { private double pixels; private double battleSpeed; public Cylon(String man, String processor, int parts, int disk, double procSpeed, double pix, double bSpeed) { super(man, proc, parts, disk, procSpeed); pixels = pix; battleSpeed = bSpeed; } CS

Protected Visibility for Superclass Data Fields  Variables with private visibility (defined by the keyword private ) cannot be accessed by a subclass  Variables with protected visibility (defined by the keyword protected ) are accessible by any subclass or any class in the same package  By default variables are public, i.e., they can be accessed by any package CS

Is-a versus Has-a Relationships  In an is-a or inheritance relationship, one class is a subclass of the other class  In a has-a or aggregation relationship, one class has the other class as an attribute CS

Is-a versus Has-a Relationships (cont.) public class Robot { private Memory mem;... } public class Memory { private int size; private int speed; private String kind;... } A Robot has only one Memory But a Robot is not a Memory (i.e. not an is-a relationship) If a Cylon extends Robot, then the Cylon is- a Robot CS