CSE 1030: Implementing Static Features Mark Shtern.

Slides:



Advertisements
Similar presentations
Chapter 1. The Phases of Software Development. Data Structure 2 Chapter outline  Objectives  Use Javadoc to write a method’s complete specification.
Advertisements

Utilities (Part 3) Implementing static features 1.
COMP 14 Introduction to Programming Miguel A. Otaduy May 25, 2004.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
COMP 110 Introduction to Programming Mr. Joshua Stough October 8, 2007.
Java Library Java provides a huge library or collection of useful programs A gold mine of well-tested code that can save you countless hours of development.
COMP 14 Introduction to Programming Mr. Joshua Stough February 28, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 8, 2005.
Information Hiding and Encapsulation
CS 225 Java Review. Java Applications A java application consists of one or more classes –Each class is in a separate file –Use the main class to start.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 7 Defining Your Own Classes Part 2.
© 2007 Lawrenceville Press Slide 1 Chapter 7 Top-Down Development  Problem-solving approach  Breaking a task down into smaller subtasks  First level.
Methods Chapter 6. 2 Program Modules in Java What we call "functions" in C++ are called "methods" in Java Purpose Reuse code Modularize the program This.
FALL 2001ICOM Lecture 21 ICOM 4015 Advanced Programming Lecture 2 Procedural Abstraction Reading: LNN Chapter 4, 14 Prof. Bienvenido Velez.
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.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
Java Program Components Java Keywords - Java has special keywords that have meaning in Java. - You have already seen a fair amount of keywords. Examples.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Utilities (Part 2) Implementing static features 1.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Methods (a.k.a. Functions)
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 5.
Vladimir Misic: Java1 Basic Java Syntax The java language will be described by working through its features: –Variable types and expressions.
Static Methods. 2 Objectives Look at how to build static (class) methods Study use of methods calling, parameters, returning values Contrast reference.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
Section 4 - Functions. All of the programs that we have studied so far have consisted of a single function, main(). However, having more than one function.
Documentation javadoc. Documentation not a programmer's first love lives in a separate file somewhere usually a deliverable on the schedule often not.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
CIS 270—Application Development II Chapter 8—Classes and Objects: A Deeper Look.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
1  lecture slides online
Class Design I Class Contracts Readings: 2 nd Ed: Section 9.5, Advanced Topic nd Ed: Section 8.5, Advanced Topic 8.2 Some ideas come from: “Practical.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Side effects A side effect is anything that happens in a method other than computing and/or returning a value. Example: public class hello { public int.
Defining Classes I Part B. Information hiding & encapsulation separate how to use the class from the implementation details separate how to use the class.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Classes - Intermediate
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
CPSC 233 Tutorial 5 February 9 th /10 th, Java Classes Each Java class contains a set of instance variables and methods Instance Variables: Type.
CSE 1020:Using Objects Mark Shtern 1-1. Summary Read API Method binding and overloading Development process Input validation Assert 1-2.
CSCI 51 Introduction to Programming Dr. Joshua Stough February 26, 2009.
CSE 1020:Using API Mark Shtern 1-1. Summary Delegation – Static Method, Object Client view vs Implementer view API, UML Errors Software Engineering Utility.
Functions + Overloading + Scope
Advanced Programing practices
Methods Chapter 6.
About the Presentations
Object Oriented Systems Lecture 03 Method
Introduction to javadoc
Static and non-Static Chapter 5.
Design by Contract Fall 2016 Version.
Subroutines Idea: useful code can be saved and re-used, with different data values Example: Our function to find the largest element of an array might.
CSE 1020: Introduction to Computer Science I
CSE 1030: Implementing Non-Static Features
CSE 1020:Programming by Delegation
Implementing Non-Static Features
Defining Classes and Methods
Data Structures and Algorithms for Information Processing
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Anatomy of a Java Program
Advanced Programing practices
Introduction to javadoc
CSE 1020:Software Development
Methods/Functions.
Presentation transcript:

CSE 1030: Implementing Static Features Mark Shtern

Course Objectives Improve development skills Introduce the concern of the implementer – Hands-on experience: Implementation of a subset of type.lib – Write API Java documentation – Study advanced programming techniques

What is the output? double sum = 0; double x = 2*Math.PI; for (int i = 0; i < ; i++) { int fact = 1; for (int j=0; j<2*i+1;j++ ) { fact = fact * j; } sum = sum + Math.pow(-1,i) * Math.pow (x,2*i +1)/fact; } System.out.println (“sum = “ + sum); Sum = Math.sin (x);

Problem Create application that calculates area of rectangle Solution Analysis  specify exactly input and output Design  make a plan for how the system will accomplish its goal Implementation  write and compile Testing  test correctness (normal and abnormal cases)

PARAMETERS Demo

Summary Software Development Cycle Robustness Methods – Code Reuse – Complexity Reduction – Maintainability Improvement Methods – Private vs Public – Call-by-value (Plug-in arguments for formal parameters) – Primitive type vs Non-primitive types – Return statement, void

Utility Class “A utility class is a class that defines a set of methods that perform common, often re-used functions” from Wikipediaclass A utility class is a class with only class-scope attributes and operations Instances are stateless or instances have the same state

Utility Class Attributes – Example public static final double PI = ; Methods – Example public static double min (double a, double b) Constructor – No public constructor

UML public class Math { public static final double PI = 3.14; public static double sqrt (double a) { double res = Double.NaN; //calculation..... return res; }

Contracts Precondition - the client’s responsibility Postcondition – the implementer’s responsibility

javadoc API text appears within the class definition as multi-line comments surrounded by /**(two asterisks instead of one) and */ API text is placed immediately before – every public attribute, constructor, and method in the class – class header to document the class as a whole

Ex 01 /** Returns the smaller of two int a An b Another The smaller of a and b. */ public static int min(int a, int b) {... }

Ex 02 /** Returns the value of the first argument raised to the second base The exponent The exponent >= base exponent. */ public static int pow(int base, int exponent) javadoc -tag param -tag pre.:a:"Precondition: " -tag return -d

EXERCISES

Ex 01 Write a static method max3() that takes three int values as arguments and returns the value of the largest one. Add an overloaded function that does the same thing with three double values.

Ex02 Write a static method odd() that takes three boolean inputs and returns true if an odd number of inputs are true, and false otherwise.

Ex03 Write a static method majority() that takes three boolean arguments and returns true if at least two of the arguments have the value true, and false otherwise. Do not use an if statement.