Chapter 5. Using objects
This chapter covers
- Using a template to write methods
- Validating method arguments and return values
- Dealing with failure inside a method
Having instantiated an object, you’re ready to use it. Objects can offer useful behaviors: they can give you information and they can perform tasks for you. Either way, these behaviors will be implemented as object methods.
Before we discuss the design rules that are specific for either retrieving information or performing tasks, we’ll first discuss something these methods should have in common: a template for their implementation.
5.1. A template for implementing methods
Whenever you design a method, you should remember the following template.
Listing 5.1. A template for methods ...
Get Object Design Style Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.