Java method | side effects if it does not modify any data, and does not leave behind any information, other than its result, that would have an effect on other computations | a comment at its head if the method is non-obvious | when using a certain procedure, a programmer does not need to worry about all the details of how it performs its computations; he or she only needs to know how to call it and what it computes | public except for those that will definitely need to be called from outside the package | its caller from only one place which should be the last statement | | method | 9.1 - The Process of Design | | a method in a superclass with the same name | the details of procedures | | a special-purpose function such as the user interface for a particular system | other methods and variables in any class in the same package by default | | if related aspects of a system are kept together in this module, and unrelated aspects are kept out |
Java constructor | side effects if it does not modify any data, and does not leave behind any information, other than its result, that would have an effect on other computations | the same name as its class | when using a certain procedure, a programmer does not need to worry about all the details of how it performs its computations; he or she only needs to know how to call it and what it computes | public except for those that will definitely need to be called from outside the package | its caller from only one place which should be the last statement | a class | Java method | The Basics of Java | public Account(String accountHolder, float initialBalance) { this.accountHolder = accountHolder; balance = initialBalance; opened = new Date(); } public Account(String accountHolder) { this.accountHolder = accountHolder; balance =0.0; opened = new Date(); } | a method in a superclass with the same name | the details of procedures | to initialize the instance variables of a newly created object and perform any other needed initialization | a special-purpose function such as the user interface for a particular system | other methods and variables in any class in the same package by default | | if related aspects of a system are kept together in this module, and unrelated aspects are kept out |