1. Introduction: good programmers are supposed to be lazy

2. Other examples

3. Method definition and invocation

method definition invocation
Figure 1. Method definition and method invocation

4. Passing arguments by values

5. Modular programming

  • Modularization makes the code easy to maintain and debug and enables the code to be reused.

  • PrimeNumberMethod.java

6. Overloading methods

  • Overloading methods enables you to define the methods with the same name as long as their signatures are different.

  • TestMethodOverloading.java

7. The scope of variables

scope
Figure 2. A variable can be declared multiple times in non-nested blocks, but only once in nested blocks.

8. Method abstraction and stepwise refinement

approach printcalendar
Figure 3. The structure chart shows the hierarchical relationship of the subproblems in the program.
  • Example: PrintCalendar.java

  • Top-down vs. bottom-up

  • Stubs

  • Why?

    • Simpler Program

    • Reusing Methods

    • Easier Developing, Debugging, and Testing

    • Better Facilitating Teamwork