Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

3. Objects: Get Oriented!: Making code m... > Give your classes a natural structur...

Give your classes a natural structure

Take a second and remind yourself why you want to make your methods intuitive: because every program solves a problem or has a purpose. It might not be a business problem—sometimes a program’s purpose (like FlashyThing) is just to be cool or fun! But no matter what your program does, the more you can make your code resemble the problem you’re trying to solve, the easier your program will be to write (and read, and repair, and maintain...).

Use class diagrams to plan out your classes

A class diagram is a simple way to draw your classes out on paper. It’s a really valuable tool for designing your code BEFORE you start writing it.

ClassName

Method()

Method()

Method()

Write the name of the class at the top of the diagram. Then write each method in the box at the bottom. Now you can see all of the parts of the class at a glance!


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial