Download presentation
Presentation is loading. Please wait.
Published byMartin Skinner Modified over 9 years ago
1
Overview of the Course 15-111 Ananda Gunawardena -- Lecture – School of Computer Science – Phone : x81559 – Office: WeH 5113 – guna@cs.cmu.edu Teaching Assistants – Lab Help, Grading – Leal Vona (lvona@andrew.cmu.edu)lvona@andrew.cmu.edu – Ruth Lin (rlin@cs.cmu.edu)
2
15-111 Prerequisites – Prior Programming experience in C++ … – Loops, conditionals, arrays, basic I/O – File processing, Data types – Know how to write/run a program starting from a problem statement Problem solving skills Time management skills
3
How to be Successful in this course Attend class Do the homework – they are designed to help you digest the chapter Do the labs (programming assignments) – they are designed to help you learn how to use the concepts covered in the chapter and discussed during lecture – start the labs early, programming assignments ALWAYS take longer than you think they will The material in each session builds on the material from the previous session
4
Course Web Site http://www.andrew.cmu.edu/~guna/15-111 All important information about the course is posted at this site… Check it for whats new Course policies are posted here… Syllabus, Cheating Policy, and Lecture notes, Labs, Exam help Contact information is posted here… Office Hours, TA’s Assignment information is posted here… Due Dates (where you will find links to labs and homework All classwork is saved in… classwork I will save frequently asked questions in… FAQ’s Need to tell me something anonymously use… Anonymous link Submit Assignments electronically … submit Lots of useful resources in… Miscellaneous
5
What we are going to study overview of fundamental programming concepts using Java Introduction to object-based programming techniques Classes and Objects Inheritance OOP design
6
What we are going to study… data aggregates self-referential data structures – linked lists – Stacks – queues – Trees – Graphs analysis of algorithms Next course : 15-211 – Data Structures
7
Problem Solving Process Review – Algorithm – Top-down design – stepwise refinement – Pseudocode – Flow Chart Phases of software development – Planning: figuring out the problem specs – Design: the algorithm, use pseudocode etc – Code: Translate the design into C++/Java syntax – Code review: “Spell-check” your code. Simulate the compiler looking for syntax errors – Compile: With a thorough code review, compile time is small – Test/debug
8
Problem Solving Process Review: – Algorithm – Top-down design, stepwise refinement – Pseudocode – Flow Chart Phases of software development – Planning: figuring out the problem specs – Design: the algorithm, use pseudocode etc – Code: Translate the design into C++/Java syntax – Code review: “Spell-check” your code. Simulate the compiler looking for syntax errors – Compile: With a thorough code review, compile time is small – Test/debug
9
System Costs: Hardware vs. Software* 100% 19502000 Software Hardware Percent System Cost Year * courtesy R.Pattis
10
Motivation for Design before Coding Analogy: Think about how you write a paper – Problem Statement? Outline? Abstract? Fill in details based on the outline? Refine sections/paragraphs? How do you proof your paper? Do you just type something and watch the spell-checker or do you print it out and read it for errors? Your solution is only as good as your design Coding should be low priority compared to design If you take short cuts, you will end up spending a lot more time on the program. Bottom Line: There is nothing mysterious about coding!!!
11
OOP Versus Non-OOP Procedural programming OOP - Identify tasks/sub-tasks - Design the classes - Write procedures - Design the methods - Procedures act upon data - Objects communicate to solve to solve the problem the problem - Start with “verbs” - Start with “nouns” - Data is secondary - Data is primary
12
Problem Solving - OO Design Identify the objects Identify the operations Design the algorithm/decompose into smaller chunks E.g: Compute the amount of tuition to be paid Name the objects – # credit hours – cost per credit hour – Other costs, such as student activity fee etc – Any discounts Name the operations to be performed: – Addition, subtraction, multiplication Algorithm
13
Key Elements of OOP Abstraction: Focus on the important, ignore the details – e.g. Driving a car The interface of the car is what the driver sees on the outside, i.e. the dash board, the gas pedal and so on. The implementation is a detail, e.g. what exactly happens when I step on the gas pedal. Encapsulation: Information hiding – The details of an object are hidden. – Users are not allowed to make changes to the implementation. – If there is any change in the implementation, it does not affect the users(clients) of the interface. – E.g. A Stack Class has as its interface: init, push, pop. The implementation may be changed from an array to a linked list
14
Key Elements of OOP Inheritance – Building upon what is already defined – A class can inherit from another class much like a child inherits from its parent Polymorphism – Greek for “many shapes” – Same name for different things – Two forms in OOP Overloading: Functions with the same name Over-riding: A child class redefining its parent’s functions
15
OOP Terminology Program = objects cooperating to solve a problem Properties of an object: State ==> data ==> nouns Operations ==> behavior ==> verbs Identity
16
Object Examples Example 1: An electronic mailbox States:full or empty Operations:add, delete... Identity: any 2 mailboxes will be different e.g. hou and aj29 each have a mail box Example 2: traffic signal
17
Object Components An object is composed of both data and Operations which can act upon the data Data Operations In an object: Operations ==> member functions (methods) Data ==> data members
18
Classes Class: – A collection of related objects. – Instance of a class = object – Factory with blueprints/instructions to build gadgets – Objects: the gadgets the factory makes. Example: – Class : checkingaccount – Objects: minnieCheckacct, mickeyCheckacct
19
Example: OOP Design Problem: write a program to simulate an ATM Data (nouns): – Account name – Account balance –... Operations /behavior(verbs): – Deposit – Withdraw – Inquire balance –...
20
Problem ( Elevator Control Problem) Simulation of an elevator control system. 20 floors, 4 elevators 1. Identify the data objects 2. Identify the data operations 3. Solve the problem Any questions Email : guna@cs.cmu.edu
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.