Lecture21 - Object-Oriented Design / Testing Method Design...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Object-Oriented Design / Testing Method Design Method Decomposition Method Overloading Testing Reading for this lecture: L&L 6.7 - 6.9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Method Design As we've discussed, high-level design issues include: identifying primary classes and objects assigning primary responsibilities After establishing high-level design issues, its important to address low-level issues such as the design of key methods For some methods, careful planning is needed to make sure they contribute to an efficient and elegant system design
Background image of page 2
3 Method Design An algorithm is a step-by-step process for solving a problem Examples: a recipe, travel directions Every method implements an algorithm that determines how the method accomplishes its goals An algorithm may be expressed in pseudocode , a mixture of code statements and English that communicate the steps to take
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Method Decomposition A method should be relatively small, so that it can be understood as a single entity A potentially large method should be decomposed into several smaller methods as needed for clarity A public service method of an object may call one or more private support methods to help it accomplish its goal Support methods might call other support methods if appropriate
Background image of page 4
5 Method Decomposition Let's look at an example that requires method decomposition – translating English into Pig Latin Pig Latin is a language in which each word is modified by moving the initial sound of the word to the end and adding "ay" Words that begin with vowels have the "yay" sound added on the end book ookbay table abletay item itemyay chair airchay
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Method Decomposition The primary objective (translating a sentence) is too complicated for one method to accomplish Therefore we look for natural ways to
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

Lecture21 - Object-Oriented Design / Testing Method Design...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online