A fifth virtue of procedure abstraction is that you easily can
improve how a computation is done.
You might decide, for example, that it is wasteful for your
movieRating
method to add up the ratings for the script, acting, and
direction twice. Accordingly, you decide to do the computation just once,
assigning the value to a variable:
public class Movie { // Define movieRating: public static int movieRating (int s, int a, int d) { int result = s + a + d; System.out.print("The rating of the movie is " + result); return result; } }
Again, you do not need to bother to find all the places where the rating is
computed via the movieRating
method; you need to change
only the movieRating
method's definition.