CS 2110 Lecture Notes - Lecture 4: Test Case

18 views2 pages
Published on 21 Jan 2017
School
Cornell University
Department
Computer Science
Course
CS 2110
Professor
CS 2110 Day 4 Lecture Notes
Notes:
I. Testing
a. Test case: set of input values, together with the expected output
b. Develop test cases from method specs, even before writing the actual method
II. Static
a. Static methods and variables are associated with the class, not a specific object
b. Allows you to call methods without creating a new object to use them
c. Only one copy (no copies are created when objects are instantiated)
III. Class Object:
a. Every class that does not extend another extends class Object
b. Has methods toString, equals, and hashCode
IV. Design notes
a. Do not use extends just to get acess to hidden members
b. A should extend B only if A is a B
c. Inheritance Hierarchy should reflect modeling semantics not implementation shortcuts
V. Name of the object
a. Contains a pointer to the object (its address in memory)
b. Variable c declared as PhD c; contains the name of the object (pointer to the object) and
not the actual object
VI. Method toString
a. Object.toString() returns name of the object (ex: W@af)
b. Convention:
i. Define toString() in any class to return representation of an object
ii. Give info about the values in its fields
iii. Any new definition of toString() override Object.toString()
VII. This
a. Evaluates to the name of the object in which it occurs
b. Makes it possible for an object to access its own name or pointe
VIII. Java application
a. Bunch of classes with at least one class that has the main procedure
i. public static void main(String[] args)
b. Running app calls method main
c. Command line can be entered with args
IX. Static variables
a. Maintain info about created objects
i. You can get the number of objects created by incrementing in the constructor
Homework:
I. Read textbook A.1-A.3
II. Read about if statmet A.38-A.40
III. Code Style Guidelines
a. 2. Format Conventions
b. 4.5 About then-part and else-part of if-statement
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Iii: test case: set of input values, together with the expected output, develop test cases from method specs, even before writing the actual method. Static: static methods and variables are associated with the class, not a specific object, allows you to call methods without creating a new object to use them, only one copy (no copies are created when objects are instantiated) Class object: every class that does not extend another extends class object, has methods tostring, equals, and hashcode. Design notes: do not use extends just to get acess to hidden members, a should extend b only if a is a b. Inheritance hierarchy should reflect modeling semantics not implementation shortcuts. Name of the object: contains a pointer to the object (its address in memory, variable c declared as phd c; contains the name of the object (pointer to the object) and not the actual object.

Get OneClass Grade+

Unlimited access to all notes and study guides.

YearlyMost Popular
75% OFF
$9.98/m
Monthly
$39.98/m
Single doc
$39.98

or

You will be charged $119.76 upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.