`
samsongbest
  • 浏览: 171594 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Chapter 6. Methods

 
阅读更多

 

Chapter 6. Methods

This chapter discusses several aspects of method design: how to treat parameters and return values, how to design method signatures, and how to document methods. Much of the material in this chapter applies to constructors as well as to methods. Like Chapter 5, this chapter focuses on usability, robustness, and flexibility.

 

Item 23: Check parameters for validity

Most methods and constructors have some restrictions on what values may be passed into their parameters. For example, it is not uncommon that index values must be nonnegative and object references must be non-null. You should clearly document all such restrictions and enforce them with checks at the beginning of the method body.

This is a special case of the general principle, and you should attempt to detect errors as soon as possible after they occur. Failing to do so makes it less likely that an error will be detected and makes it harder to determine the source of an error once it has been detected.

 

分享到:
评论

相关推荐

    The.Go.Programming.Language.0134190440.epub

    Chapter 6. Methods Chapter 7. Interfaces Chapter 8. Goroutines and Channels Chapter 9. Concurrency with Shared Variables Chapter 10. Packages and the Go Tool Chapter 11. Testing Chapter 12. Reflection...

    Get Programming with Go

    Chapter 6. Capstone: The Vigenère Cipher Unit 3 - BUILDING BLOCKS Chapter 1. Functions Chapter 2. Methods Chapter 3. First-Class Functions Chapter 4. Capstone: Temperature Tables Unit 4 - ...

    JavaScript The Good Parts

    Chapter 6. Arrays Chapter 7. Regular Expressions Chapter 8. Methods Chapter 9. Style Chapter 10 Beautiful Features Appendix A. Awful Parts Appendix B. Bad Parts Appendix C. JSLint Appendix D. Syntax ...

    Java.SE.7.Programming.Essentials

    Chapter 6. Encapsulating Data and Exposing Methods in Java Chapter 7. Using Java Methods to Communicate Chapter 8. Using Java Constructors Chapter 9. Inheriting Code and Data in Java Chapter 10. ...

    Digital Signal Processing Using Matlab

    Chapter 6. Linear and Invariant Discrete-Time Systems Chapter 7. Infinite Impulse Response Filters Chapter 8. Finite Impulse Response Filters Chapter 9. Detection and Estimation Chapter 10. Power ...

    Learn.Swift.on.the.Mac.For.OS.X.and.iOS.1484203771

    Chapter 6. Operators Chapter 7. Flow Control Chapter 8. Functions and Closures Chapter 9. Classes and Structures Chapter 10. Methods Chapter 11. Access Control Chapter 12. Inheritance Chapter 13. ...

    iOS.9.App.Development.Essentials

    Chapter 6. Swift Data Types, Constants and Variables Chapter 7. Swift Operators and Expressions Chapter 8. Swift Flow Control Chapter 9. The Swift Switch Statement Chapter 10. An Overview of Swift 2 ...

    JAVA How to Program(the sixth edition)

    老师推荐以及教学用书,是英文版本的 ...Chapter 6. Methods: A Deeper Look Chapter 7. Arrays Chapter 8. Classes and Objects: A Deeper Look Chapter 9. Object-Oriented Programming: Inheritance 等29章

    PHP.Web.Services.APIs.for.the.Modern.Web.2nd.Edition

    Chapter 6. XML Chapter 7. RPC and SOAP Services Chapter 8. REST Chapter 9. Webhooks Chapter 10. HTTP Tools Chapter 11. Maintainable Web Services Chapter 12. Making Service Design Decisions Chapter 13....

    Core Java 9th Edition(Vol1,Vol2)

    Chapter 6. Interfaces and Inner Classes Chapter 7. Graphics Programming Chapter 8. Event Handling Chapter 9. User Interface Components with Swing Chapter 10. Deploying Applications and Applets Chapter...

    MATLAB for Machine Learning

    Chapter 6. Identifying Groups Of Data Using Clustering Methods Chapter 7. Simulation Of Human Thinking - Artificial Neural Networks Chapter 8. Improving The Performance Of The Machine Learning Model -...

    Fluent.Python.1491946008

    Chapter 6. Design patterns with first-class functions Chapter 7. Function decorators and closures Part IV. Object Oriented Idioms Chapter 8. Object references, mutability and recycling Chapter 9. A ...

    Cplusplus.Language.Tutorial.For.Beginner.Learn.Cplusplus.in.7.days

    Title: C++ Language ...Chapter 6. Classes Chapter 7. Overloading Chapter 8. Derived Classes Chapter 9. Templates Chapter 10. Exception Handling Chapter 11. The IO Library Chapter 12. The Preprocessor

    Real-time.Analytics.with.Storm.and.Cassandra.1784395498

    Chapter 6. Adding NoSQL Persistence to Storm Chapter 7. Cassandra Partitioning, High Availability, and Consistency Chapter 8. Cassandra Management and Maintenance Chapter 9. Storm Management and ...

Global site tag (gtag.js) - Google Analytics