1/27/2014. OO design approach with examples. UML and project clarifications (2) Project clarifications 1. UML
|
|
- Winifred Doyle
- 5 years ago
- Views:
Transcription
1 OO design approach with examples Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX URL: 1. UML UML and project clarifications Each class should be represented using appropriate notation for public, private, protected, and static attributes and methods. Constructors should be identified as such. Make sure parameters, return types are properly indicated Relationships between classes should be represented using labels, cardinality information (where appropriate). Later, Is a, has a, and uses a need to be represented Later, abstract classes and interfaces need to be represented See (but make sure you use modifiers and constructors, parameters and return types) UML and project clarifications (2) 3. Course and textbook There is a prescribed textbook for the course which means that you need to read it Many questions I am getting about the project (e.g., UML diagrams) are also answered in the textbook My lecture notes are not sufficient for doing well on the quizzes/exams or projects Chapters covered are mentioned on my web along with homework problems for each chapter Please post all class related (project or otherwise) questions on the blackboard Project clarifications 1. Many students are asking me as to what chapters one needs to read to do the projects Since the chapters (as organized in the book) do not give all the information needed to finish a project Attending classes Going over my slides Heeding pointers and clarifications I provide are going to be useful for doing projects. 1. Also, my quizzes and exams cover not only the chapters indicated, but also the material covered in the class 1
2 Design of a class (general guidelines) Choosing attributes/methods as private makes them visible only inside a class Choosing attributes/methods as public makes them visible everywhere (with in a class, within subclasses, within same packages, and in other packages) (C-style code in Java!) Hence, you have to choose access modifiers judiciously! How do you do that? 5 Design of a class (general guidelines) One approach is to make everything private and relax as needed to get maximum encapsulation! Relax from private one visibility step (package-private, protected) at a time to accomplish the above In other words, do not make any attribute/method public unless absolutely necessary Use the principle of need to know 6 Design of a class Want to design an alarm clock Need to identify visible attributes, interfaces and separate them from implementation If it is an alarm clock combined with a radio, you will have to think of these objects that together form the system (recall has-a association) Do not combine separate concepts into a single class Example of an object Alarm clock as an object What are its private attributes/fields? Current second (a value in the range 0 59) Current minute (a value in the range 0 59) Current hour (a value in the range 1 12) The time the alarm is set for (a valid hour and minute) Whether the alarm is on or off Am, pm indicator The fields merely describe values that define the current state of the alarm clock The above cannot be changed unless knobs are provided for that purpose (methods/visible interface in our case) 7 8 2
3 Example of an object (2) Alarm clock as an object What are its public attributes? There may not be any public attributes! What are its public methods (visible front end)? Set time (to a valid time) Set alarm time (to a valid time) Turn alarm on/off (one or two methods) Read time Read current alarm time Each method manipulates one or more fields The above are public methods 9 Example of an object Alarm clock as an object What are its private methods? Increment the current second Increment the current minute Increment the current hour Sound alarm Note that these methods also change the attributes of the clock class (or state of that object). In addition, they have to manipulate the fields correctly When the second reaches 59, minute is incremented by 1 and second is set to zero, wrap around of hours etc. Similarly for alarm time 10 Class Design Hints 1. Always keep as much data private as possible This is important. Otherwise, it violates encapsulation. You may have to write accessor/observer and/or mutator methods, but you are still better off keeping the instance fields private. Provides separation from implementation Experience shows that data representation or implementation is likely to change more often than usage. Plus, bugs are easier to detect 2. Always initialize class attributes Although Java initializes instance and class attributes of objects, defaults may not make sense always. Explicitly initialize them (e.g., default date) Class Design Hints (2) 3. Don t use too many basic types in a class The idea is to replace multiple related uses of basic types with other classes. This keeps your classes small, easier to understand, and manage. For example, replace the following fields in a class private String street; private String city; private int zip; private STATE state; // using enum This is how you build new classes using existing ones With a new class called Address. This way you can cope with changes to addresses and deal with international addresses. Will not disturb other classes You will be using these ideas in your projects 3
4 Class Design Hints (3) 4. Not all fields need individual accessors and mutators You may need to get and set an Employee s name. Hiring date, for example, does not change once the object is constructed. Quite often objects have fields that you don t want others to get or set (this is part of information hiding) Employee s salary may not be visible to everyone. Hence not public. It may be protected or packageprivate so that only required modules can access it. Class Design Hints (3) 5. Use a standard layout for class definition (in this order) Attributes Methods Within each of the above, list static members public members Package private members, and private members Some put the attributes at the bottom of the class. Class Design Hints (4) 6. Breakup classes that have too many (independent) responsibilities This may be a bit vague and subjective. If you can decompose one intermingled class into two simpler classes, do it. However, classes with only one/very few attributes/methods may be an overkill public class CardDeck{ private int[] value; //private int[] value = new int[52]; private String[] suit; public CardDeck() { public void shuffle() { //contrast with Date public int gettopvalue() { public String gettopsuit() { Public?? draw () { Class Design Hints (5) In the previous example Two concepts are intermingled: card and deck. shuffle applies to the Deck gettopvalue() and gettopsuit() refer to cards. draw applies to the deck but returns a card (i.e., 2 values) You cannot return multiple values in a programming language except as an object! Therefore, it is better to separate this into two concepts/classes with their own responsibilities 4
5 CardDeck classes public class Card{ //good design private int value; //default does not make sense! private String suit; //can be enum type public Card(int avalue, String asuit) { public int getvalue() { public String getsuit() { public class CardDeck{ //better design private Card[] deck; //private card[] deck = new Card[52]; public CardDeck() { public void shuffle() { private Card gettopcard() { Public Card draw() { CardDeck classes with enum public class Card{ //good design private enum Suits {DIAMOND, HEART, SPADE, CLUB private int value; //default does not make sense! private Suits suit; public Card(int avalue, String asuit) { public int getvalue() { public String getsuit() { public class CardDeck{ //better design private Card[] deck; //private card[] deck = new Card[52]; public CardDeck() { public void shuffle() { private Card gettopcard() { Public Card draw() { Card acard = new Card(1, DIAMOND ); System.out.println(aCard.value +, + acard.suit); // will print 1,DIAMOND Card instance/class attributes class Card implements CardDeckConstants{ private static enum Suits {SPADE, CLUB, DIAMOND, HEART; private static String[] cardvalues = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" ; private String value; // default does not make sense! private Suits suit; Card class constructor public Card(int avalue, String asuit) { if (!isvalid(avalue, asuit.touppercase())){ System.out.println("1: Invalid card: (" + avalue + ", " + asuit + ")"); System.exit(ABNORMAL_EXIT); value = avalue; suit = Suits.valueOf(aSuit.toUpperCase()); // constructor public class CardDeck implements CardDeckConstants{ private Card[] deck = new Card[CARDS_IN_A_DECK]; cse 1325: chakravarthy 19 cse 1325: chakravarthy 20 5
6 CardDeck constructor public CardDeck() { System.out.println("Create a valid Deck without jokers:\n"); int card = 0; for (String s : cardsuits) for (int i=1; i <= CARDS_IN_A_SUIT; i++) deck[card++] = new Card(i, s); public void shuffle(int randomseed) { System.out.println("Shuffling the deck using " + randomseed + " as seed"); Random randgen = new Random(randomSeed); int times = TIMES_TO_SHUFFLE + randgen.nextint(times_to_shuffle); for (int i = 0; i < times; i++) { int pos_1 = randgen.nextint(cards_in_a_deck); // 0 to 51 int pos_2 = randgen.nextint(cards_in_a_deck); Card tmpcard = deck[pos_1]; deck[pos_1] = deck[pos_2]; deck[pos_2] = tmpcard; cse 1325: chakravarthy 21 Class Design Hints (7) 7. Make names of your classes and methods reflect their responsibilities Analogous to attributes and local variables having meaningful names that reflect what they represent A good convention is to use nouns for class names (e.g., Order) or a noun preceded by an adjective (e.g., RushOrder) or a gerund (e.g., BillingAddresss) Begin with a lowercase get for accessor methods Begin with a lowercase set for mutator methods Summary Identify classes each should have an independent existence and have its own properties; distinguishability of objects is provided by Java Identify attributes/fields decide its characteristics (public vs. private (or protected or package-private) static vs. non static, final (constants) Identify constructors one or more depending on need Include proper comments for javadoc Summary Identify methods: public depending on how objects are manipulated from outside and private how objects are manipulated from within the class Identify static and non static methods; also what each method returns including void Use principle of minimality for all of the above Do the UML diagram for classes (go over associations) Test each class individually (unit testing) before integrating it into the larger project (with a main in each class) 6
7 UML for the CardDeck <<Class>> CardDeck <<Class>> +Card What are its attributes/fields? What are its methods? We want to capture a date consisting of month, day, and year and manipulations of date For example, does date1 precede date2? If I add 40 days to date1, what will be the resulting date? How many full months are there between date1 and date2? Attributes/fields month to represent the month (mm) date to represent a day (dd) year to represent a year (yyyy) What are their types and visibility? Who makes sure that day is in the range 1 to 31 depending on the month (in the range 1 to 12)? Who handles the correctness of a date? or public class Date{ private final int month;// month (between 1 and 12) private final int day;// day (between 1 and 31) private final int year; // year Why final? Makes the object immutable! It is not difficult to check months for range However, it is not so easy to do it for days as the number of days vary from month to month How can we cope with that? Do not want to construct a date that is not valid! 7
8 public class Date implements Proj2Constants{ private static final int[] DAYS = { 0,31,29,31,30,31,30,31,31,30,31,30,31 ; private final int month;// month (between 1 and 12) private final int day;// between 1 and DAYS[month]) private final int year; // year Let us look at constructors Methods A default constructor initialized to default values does not seem appropriate for this class as it results in an invalid date (0 0 0)! /** * Constructor: Does bounds-checking to ensure object represents a valid date m represents the month between 1 and 12 d represents the date between 1 and the corresponding number from array DAYS y represents the year RuntimeException if the date is invalid */ public Date(int m, int d, int y) { if (!isvalid(m, d, y)) throw new RuntimeException( 1: Invalid date"); month = m; day = d; year = y; public Date(String sdate){ int m, d, y; String [] chopdate = sdate.split( -"); m = Integer.parseInt(chopDate[ZEROI]); d = Integer.parseInt(chopDate[ONEI]); y = Integer.parseInt(chopDate[TWOI]); if (!isvalid(m, d, y)) throw new RuntimeException( 2: Invalid date"); month = m; day = d; year = y; /** * Is the given date valid? month, day and year false if month exceeds 12 or is less than 1 false if day exceeds the corresponding days for a month from array false if leap year is not correct */ Why is this method static? private static boolean isvalid(int m, int d, int y){ if (m < 1 m > 12) return false; if (d < 1 d > DAYS[m]) return false; if (m == 2 && d == 29 &&!isleapyear(y)) return false; return true; // note short circuit operators 8
9 /** * is y a leap year? y represents the year specified true if year divisible by 400 false if year divisible by 100 and not by 400 */ private static boolean isleapyear(int y) { if (y % 400 == 0) return true; if (y % 100 == 0) return false; return (y % 4 == 0); The order of check is very important! Date and Time Class Summary You can take a look at the rest of the methods Can add more methods as needed User of the does not have to know the implementation details Can change implementation as long the public interface is kept the same Follow this example for your design and implementation DateTime Class Suppose you are asked to create a DateTime class that can manage both date and time (Oracle has something like this) Would you make a separate class? Why? Or would you combine all attributes into one class? Or would you add Date to Time class or Time to Date class? Why? What are the implications of the above? What are the methods (public and private) You may want to do this as homework to understand the design, and concept separation discussed earlier! DateTime Class (2) Time has been implemented to wrap around That is, if you add 2 hours to 23:00:00, you get 01:00:00 This is not appropriate for DateTime class where if you add 2 hours to , 23:00:00, you should get , 01:00:00 (not , 01:00:00) To accomplish the above, you need to know when the wraparound happens! See how you can do the above problem! 9
10 Project 2 Is about designing a few classes based on the given specification. Implement constructors and methods in each class Do the UML for all the classes Thank You! Identify attributes of each class Identify visibility of attributes of each class Identify visibility of methods of each class We will also give you code for reading input Please study the code given to you Follow good programming practices and javadoc annotations as shown in the code given to you January 13, 2010 cse 1325: chakravarthy 38 10
OOP, Java classes and Objects (Chapter 3 and 8)
OOP, Java classes and Objects (Chapter 3 and 8) Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington,
More information1/17/2014. UML Help and Details (from: UML for cse UML for a class. UML and project clarifications
UML Help and Details (from: http://enwikipediaorg/wiki/class_diagram) Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas
More informationJava. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)
Summary: Chapters 1 to 10 Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationSample file. Practice Exam One COMPUTER SCIENCE A SECTION I. Directions: Determine the answer to each of the following questions or incomplete
Practice Exam One / Level A Diagnostic Test 5 Practice Exam One COMPUTER SCIENCE A SECTION I Time 1 hour and 15 minutes Number of questions 40 Percent of total grade 50 Directions: Determine the answer
More informationContents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance
Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass
More informationObject-Oriented Programming in Java. Topic : Objects and Classes (cont) Object Oriented Design
Electrical and Computer Engineering Object-Oriented in Java Topic : Objects and Classes (cont) Object Oriented Maj Joel Young Joel.Young@afit.edu 11-Sep-03 Maj Joel Young Using Class Instances Accessing
More informationEECS168 Exam 3 Review
EECS168 Exam 3 Review Exam 3 Time: 2pm-2:50pm Monday Nov 5 Closed book, closed notes. Calculators or other electronic devices are not permitted or required. If you are unable to attend an exam for any
More informationProject 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with
Project 1 and Java Intro Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The University of Texas at Arlington, Arlington, TX 76019 Email: sharma@cse.uta.edu
More informationClasses Classes 2 / 36
Classes 1 / 36 Classes Classes 2 / 36 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationCS112 Lecture: Defining Instantiable Classes
CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:
More informationClasses Classes 2 / 35
Classes 1 / 35 Classes Classes 2 / 35 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationJava enum, casts, and others (Select portions of Chapters 4 & 5)
Enum or enumerates types Java enum, casts, and others (Select portions of Chapters 4 & 5) Sharma Chakravarthy Information Technology Laboratory (IT Lab) Computer Science and Engineering Department The
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done
More informationCPS122 Lecture: Defining a Class
Objectives: CPS122 Lecture: Defining a Class last revised January 14, 2016 1. To introduce structure of a Java class 2. To introduce the different kinds of Java variables (instance, class, parameter, local)
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationEncapsulation in C++
pm_jat@daiict.ac.in In abstract sense, it is all about information hiding Informally, you can call it as packaging of data and function together in a single entity called class such that you get implementation
More informationClasses and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון 22 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationTopic 03 - Objects and Classes. I. Classes and Objects Casual Preview. Topic 03. VIII. Benefits of Encapsulation. XIII. Overloading methods, Signature
Contents Topic 03 - Objects and Classes I. Casual Preview Day, Employee, Initializing fields, Array of objects, tostring II. Introduction to OOP Terminologies: Instance, Instance fields, Methods, Object
More informationCS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class
CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount
More informationClasses and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationNote: This is a miniassignment and the grading is automated. If you do not submit it correctly, you will receive at most half credit.
Com S 227 Fall 2017 Miniassignment 1 50 points Due Date: Monday, October 16, 11:59 pm (midnight) Late deadline (25% penalty): Tuesday, October 17, 11:59 pm General information This assignment is to be
More informationCS111: PROGRAMMING LANGUAGE II. Lecture 1: Introduction to classes
CS111: PROGRAMMING LANGUAGE II Lecture 1: Introduction to classes Lecture Contents 2 What is a class? Encapsulation Class basics: Data Methods Objects Defining and using a class In Java 3 Java is an object-oriented
More informationCSE115 Introduction to Computer Science for Majors I Spring 2008 Final Exam. First/Given Name (PRINT) May 6, 2008
CSE115 Introduction to Computer Science for Majors I Spring 2008 Final Exam First/Given Name (PRINT) May 6, 2008 Last/Family Name (PRINT) Person #: Recitation Section: B1: T 2:00pm B2: W 10:00am (Circle
More informationIntroduction to Computing II (ITI 1121) Final Examination
Université d Ottawa Faculté de génie École de science informatique et de génie électrique University of Ottawa Faculty of Engineering School of Electrical Engineering and Computer Science Introduction
More informationMutating Object State and Implementing Equality
Mutating Object State and Implementing Equality 6.1 Mutating Object State Goals Today we touch the void... (sounds creepy right... see the movie, or read the book, to understand how scary the void can
More informationProgramming Exercise 14: Inheritance and Polymorphism
Programming Exercise 14: Inheritance and Polymorphism Purpose: Gain experience in extending a base class and overriding some of its methods. Background readings from textbook: Liang, Sections 11.1-11.5.
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2017 Assignment 1 80 points Due Date: Thursday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Friday, February 3, 11:59 pm General information This assignment is to be done
More informationCMPT 117: Tutorial 1. Craig Thompson. 12 January 2009
CMPT 117: Tutorial 1 Craig Thompson 12 January 2009 Administrivia Coding habits OOP Header Files Function Overloading Class info Tutorials Review of course material additional examples Q&A Labs Work on
More informationCS1004: Intro to CS in Java, Spring 2005
CS1004: Intro to CS in Java, Spring 2005 Lecture #13: Java OO cont d. Janak J Parekh janak@cs.columbia.edu Administrivia Homework due next week Problem #2 revisited Constructors, revisited Remember: a
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationChapter 6 Lab Classes and Objects
Gaddis_516907_Java 4/10/07 2:10 PM Page 51 Chapter 6 Lab Classes and Objects Objectives Be able to declare a new class Be able to write a constructor Be able to write instance methods that return a value
More informationClasses and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות
Classes and Methods עזאם מרעי המחלקה למדעי המחשב אוניברסיטת בן-גוריון מבוסס על השקפים של אותו קורס שניתן בשנים הקודמות 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static,
More informationReviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand
More informationWho we are: Lecture 1: Overview & Java. Why CS 62? Sample Problems. CS 62 Fall 2016 Kim Bruce & Peter Mawhorter
Who we are: Lecture 1: Overview & Java CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Kim Bruce Andi Chen Ornella Altunyan Peter Mawhorter Marina Kent Sara Gong TAs: Andi Chen, Ornella Altunyan, Marina Kent,
More informationObjects and Classes. Basic OO Principles. Classes in Java. Mark Allen Weiss Copyright 2000
Objects and Classes Mark Allen Weiss Copyright 2000 8/30/00 1 Basic OO Principles Objects are entities that have structure and state. Each object defines operations that may access or manipulate that state.
More informationArray Based Lists. Collections
Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular
More informationIntroduction. Object Orientated Analysis and Design. Benjamin Kenwright
Introduction Object Orientated Analysis and Design Benjamin Kenwright Outline What do we mean by Object Orientated? Why do we need to analyze and design our solutions? Give examples What analysis and design
More informationCS 101 Fall 2006 Midterm 3 Name: ID:
You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure
More informationA - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models
CS 494 Object-Oriented Analysis & Design UML Class Models Overview How class models are used? Perspectives Classes: attributes and operations Associations Multiplicity Generalization and Inheritance Aggregation
More informationCMSC 132, Object-Oriented Programming II Summer Lecture 5:
CMSC 132, Object-Oriented Programming II Summer 2018 Lecturer: Anwar Mamat Lecture 5: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 5.1 Comparable
More informationOrganization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?
Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic
More informationGuessing Game with Objects
Objectives Lab1: Guessing Game with Objects Guessing Game with Objects 1. Practice designing and implementing an object-oriented program. 2. Use Console I/O in Java. Tasks 1. Design the program (problem
More informationCS112 Lecture: Working with Numbers
CS112 Lecture: Working with Numbers Last revised January 30, 2008 Objectives: 1. To introduce arithmetic operators and expressions 2. To expand on accessor methods 3. To expand on variables, declarations
More informationPrelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer
Prelim 1 SOLUTION CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader 0. Name (1 point)
More informationOutline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003
Outline Object Oriented Programming Autumn 2003 2 Course goals Software design vs hacking Abstractions vs language (syntax) Java used to illustrate concepts NOT a course about Java Prerequisites knowledge
More informationUML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011
UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation
More informationMathematics/Science Department Kirkwood Community College. Course Syllabus. Computer Science CSC142 1/10
Mathematics/Science Department Kirkwood Community College Course Syllabus Computer Science CSC142 Bob Driggs Dean Cate Sheller Instructor 1/10 Computer Science (CSC142) Course Description Introduces computer
More information6.001 Notes: Section 8.1
6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationYou must pass the final exam to pass the course.
Computer Science Technology Department Houston Community College System Department Website: http://csci.hccs.cc.tx.us CRN: 46876 978-1-4239-0146-4 1-4239-0146-0 Semester: Fall 2010 Campus and Room: Stafford
More informationLesson 10B Class Design. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10B Class Design By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Encapsulation Inheritance and Composition is a vs has a Polymorphism Information Hiding Public
More informationLecture 5 Abstract Data Types
CSE 331 Software Design and Implementation Lecture 5 Abstract Data Types Leah Perlmutter / Summer 2018 Platonic Forms Quote Announcements Announcements Section tomorrow! Loop reasoning useful for HW2 historically
More informationInitial Coding Guidelines
Initial Coding Guidelines ITK 168 (Lim) This handout specifies coding guidelines for programs in ITK 168. You are expected to follow these guidelines precisely for all lecture programs, and for lab programs.
More informationCSCE 156 Computer Science II
CSCE 156 Computer Science II Lab 04 - Classes & Constructors Dr. Chris Bourke Prior to Lab 1. Review this laboratory handout prior to lab. 2. Read Object Creation tutorial: http://download.oracle.com/javase/tutorial/java/javaoo/objectcreation.
More informationCS 211 Programming Practicum Fall 2018
Due: Wednesday, 11/7/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will
More informationCSE P 501 Exam 8/5/04
Name There are 7 questions worth a total of 65 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. You may refer to the following references: Course
More informationCS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.
Name CS 110 Practice Final Exam originally from Winter, 2003 Instructions: closed books, closed notes, open minds, 3 hour time limit. There are 4 sections for a total of 49 points. Part I: Basic Concepts,
More informationCPS122 Lecture: Detailed Design and Implementation
CPS122 Lecture: Detailed Design and Implementation Objectives: Last revised March 3, 2017 1. To introduce the use of a complete UML class box to document the name, attributes, and methods of a class 2.
More informationCST141 Thinking in Objects Page 1
CST141 Thinking in Objects Page 1 1 2 3 4 5 6 7 8 Object-Oriented Thinking CST141 Class Abstraction and Encapsulation Class abstraction is the separation of class implementation from class use It is not
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationSoftware Design and Analysis for Engineers
Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 1 Date:
More informationPart 1: Group Brainstorm (NO computers during this time) Part 2: Submit Individual Brainstorm (You can now use a computer)
Part 1: Group Brainstorm (NO computers during this time) Good programmers think before they begin coding. Part I of this assignment involves brainstorming with a group of peers with absolutely no computers
More informationObject Orientated Analysis and Design. Benjamin Kenwright
Notation Part 2 Object Orientated Analysis and Design Benjamin Kenwright Outline Review What do we mean by Notation and UML? Types of UML View Continue UML Diagram Types Conclusion and Discussion Summary
More informationChapter 6 Lab Classes and Objects
Lab Objectives Chapter 6 Lab Classes and Objects Be able to declare a new class Be able to write a constructor Be able to write instance methods that return a value Be able to write instance methods that
More informationPrelim 1. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants
Prelim 1 CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader The exam is closed book
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 31 Static Members Welcome to Module 16 of Programming in C++.
More informationCreating an Immutable Class. Based on slides by Prof. Burton Ma
Creating an Immutable Class Based on slides by Prof. Burton Ma 1 Value Type Classes A value type is a class that represents a value Examples of values: name, date, colour, mathematical vector Java examples:
More informationProject 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.
Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple movie data system. Milestones: 1. Use
More informationClasses. 1 Data Abstraction. 2 A Complex Number ADT
Classes 1 Data Abstraction An abstraction of a concept attempts to capture the essence of the concept its essential properties and behaviors by ignoring irrelevant details. Process abstraction - group
More informationAssignment 1 due Monday at 11:59pm
Assignment 1 due Monday at 11:59pm The heart of Object-Oriented Programming (Now it gets interesting!) Reading for next lecture is Ch. 7 Focus on 7.1, 7.2, and 7.6 Read the rest of Ch. 7 for class after
More informationCS161: Introduction to Computer Science Homework Assignment 10 Due: Monday 11/28 by 11:59pm
CS161: Introduction to Computer Science Homework Assignment 10 Due: Monday 11/28 by 11:59pm Many cable packages come with a search interface that let s you search for a show or movie by typing the name
More informationDealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009
Dealing with Bugs Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009 University of Colorado, 2009 1 Goals 2 Review material from Chapter 11 of Pilone & Miles Dealing with
More informationDefining Classes and Methods. Objectives. Objectives 6/27/2014. Chapter 5
Defining Classes and Methods Chapter 5 Objectives Describe concepts of class, class object Create class objects Define a Java class, its methods Describe use of parameters in a method Use modifiers public,
More informationPractice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course
: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course 1. Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... In what order
More informationClaremont McKenna College Computer Science
Claremont McKenna College Computer Science CS 51 Handout 4: Problem Set 4 February 10, 2011 This problem set is due 11:50pm on Wednesday, February 16. As usual, you may hand in yours until I make my solutions
More informationPRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE. Speaking the Language of OO
PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 00. WELCOME TO OBJECTVILLE Speaking the Language of OO COURSE INFO Instructor : Alper Bilge TA : Gökhan Çıplak-Ahmet Alkılınç Time : Tuesdays 2-5pm Location
More informationBinghamton University. CS-140 Fall Problem Solving. Creating a class from scratch
Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationLinked Structures - Review Chapter 13. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013
Linked Structures - Review Chapter 13 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Scope Introduction to Linked Structures: Object references as links Linked vs. array-based structures
More informationBCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING
BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING Wednesady 23 rd March 2016 Afternoon Answer any FOUR questions out of SIX. All
More informationModule Contact: Dr Taoyang Wu, CMP Copyright of the University of East Anglia Version 1
UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2016-17 PROGRAMMING FOR NON-SPECIALISTS CMP-5020B Time allowed: 2 hours Section A (Attempt all questions: 80 marks) Section
More informationCS 142 Style Guide Grading and Details
CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba Laboratory Session: Exercises on classes Analogy to help you understand classes and their contents. Suppose you want to drive a car and make it go faster by pressing down
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationProgramming Language Concepts: Lecture 2
Programming Language Concepts: Lecture 2 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 2, 19 January 2009 Classes and
More informationCSE 1325 Project Description
CSE 1325 Summer 2016 Object-Oriented and Event-driven Programming (Using Java) Instructor: Soumyava Das Project III Assigned On: 7/12/2016 Due on: 7/25/2016 (before 11:59pm) Submit by: Blackboard (1 folder
More informationCompuScholar, Inc. 9th - 12th grades
CompuScholar, Inc. Alignment to the College Board AP Computer Science A Standards 9th - 12th grades AP Course Details: Course Title: Grade Level: Standards Link: AP Computer Science A 9th - 12th grades
More information6.001 Notes: Section 6.1
6.001 Notes: Section 6.1 Slide 6.1.1 When we first starting talking about Scheme expressions, you may recall we said that (almost) every Scheme expression had three components, a syntax (legal ways of
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Creating Your Own Class Lecture 7 Readings This Week s Reading: Ch 3.1-3.8 (Major conceptual jump) Next Week: Review Ch 1-4 (that
More informationObject-Oriented Design Lecture 3 CSU 370 Fall 2007 (Pucella) Friday, Sep 14, 2007
Object-Oriented Design Lecture 3 CSU 370 Fall 2007 (Pucella) Friday, Sep 14, 2007 Java We will be programming in Java in this course. Partly because it is a reasonable language, and partly because you
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 43 Dynamic Binding (Polymorphism): Part III Welcome to Module
More informationAdvanced Programming - CS239
Advanced Programming - CS239 Department of Computer Science LAB: EXPERIMENTING WITH SPECIALIZATION Getting Ready: Before going any further you should: 1. Make a directory on your N: drive for this lab.
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.
More information1 of 8 3/28/2010 8:03 AM C++ Special Topics Home Class Info Links Lectures Newsgroup Assignmen This is a short review of special topics in C++ especially helpful for various assignments. These notes are
More informationpublic Student(int theage, String thename, char thegrade) { age = theage; name = thename; grade = thegrade; } public int getage() { return age;}
Java Class Types CSCI 136: Fall 2018 Handout 3 12 September Class Types We noted earlier that the String type in Java was not a primitive (or array) type. It is what Java calls a classbased (or class)
More information