


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Introduces undesirable dependences. • Does not generalize to other collections. Solution: Provide a standard iterator object supplied by all data structures.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



CSE 331, Spring 2011 Section 4 cheat sheet JUnit, OO design patterns
Method annotations: tag description @Test @Test(timeout = time ) @Test(expected = exception .class) Turns a public method into a JUnit test case. Adding a timeout will cause the test case to fail after time milliseconds. Adding an expected exception will cause the test case to fail if exception is not thrown. @Before (^) Method to run before every test case @After (^) Method to run after every test case @BeforeClass (^) Method to run once, before any test cases have run @AfterClass (^) Method to run once, after all test cases have run Assertion methods: method description assertTrue( test ) fails if the Boolean test is false assertFalse( test ) fails if the Boolean test is true assertEquals( expected , actual ) fails if the values are not equal assertSame( expected , actual ) fails if the values are not the same (by ==) assertNotSame( expected , actual ) fails if the values are the same (by ==) assertNull( value ) fails if the given value is not null assertNotNull( value ) fails if the given value is null fail() (^) causes current test to immediately fail Each method can also be passed a string to display if it fails, e.g. assertEquals( “message” , expected , actual ) Unit testing tips:
“A standard solution to a common software problem in a context.”
Problem : To access all members of a collection, must perform a specialized traversal for each data structure.
Problem : We have an object that contains the functionality we need, but not in the way we want to use it.
Goal : Create and interact with an object that is the only object of its type. Includes:
You were not required to use object oriented design patterns in the first three homework assignments (besides Iterator and possibly the interning of Strings, thanks to the creators of Java). Now that you have learned several design patterns, consider their use in those assignments. Try answering questions such as: What classes would have made good Singletons? Where would you have liked to use a Factory? How could you have applied the Flyweight pattern? Discuss with your classmates. As a reminder, the classes used in each homework assignment were: Homework 1: Shopping