1 / 4

Dividing Complicated Methods into Simpler Ones

Learn how to decompose potentially large methods into smaller, more understandable entities to improve clarity and support readability. Explore the method decomposition process and the example of translating English sentences into Pig Latin.

thompkins
Download Presentation

Dividing Complicated Methods into Simpler Ones

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. C4 D6 Obj: section 4.4, to learn to divide complicated methods into simpler, supporting methods HW: p. 246 #4.7 – 4.10 Do Now: p.245 #4.2 – 4.6

  2. Sec 4.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 service method of an object may call one or more support methods to accomplish its goal • Support methods could call other support methods if appropriate

  3. Pig Latin • The process of translating an English sentence into Pig Latin can be decomposed into the process of translating each word • The process of translating a word can be decomposed into the process of translating words that • begin with vowels • begin with consonant blends (sh, cr, tw, etc.) • begins with single consonants • See PigLatin.java (page 224) • See PigLatinTranslator.java (page 225)

  4. “Tracking Grades” Lab

More Related