/* CSC 16 Notes Java is a language that allows for several styles of programming. You already know about the recursive versus non-recursive style. Many functions, such as binary search, can be written with or without recursion and the question as to which style is better is debatable. However, there are also examples, such as quicksort, were recursion offers a clear advantage over the "iterative" style of programming which relies only on loops. In this program, I will contrast two further sets of styles, these being: 1. object-oriented versus functional style 2. Constructive versus destructive style We first discuss object-oriented (oop) versus functional: In the oop style, function calls are made as in myaccount.withdraw(100); Where withdraw is defined as: class account { double balance; ... public void withdraw(double amount) { this.balance -= amount; } ... } That is, the object to the left of the "." determines the context of the call. Within the body of the function, "this" refers to the object that the function was invoked on. The functional style of programming, on the other hand, relies solely on static functions. For these functions, all data relevant to the processing of information are either passed in as variables, or are themselves also static information. That is, if we wrote the withdraw method of the simple bank account class as follows: public static void withdraw(account A, double amount) { A.balance -= amount } Then it would be in the functional style, and will have to be invoked in the following way: account.withdraw(myaccount,100); The name to the left of the "." is now the name of the CLASS, because the function is now independent of any instance of the class. This style of programming is also valid, and is in fact better for many recursive algorithms. ////// The second constrast in styles is between constructive and destructive programming: Constructive means we create new a structure, and destructive means we modify an existing structure. Suppose we want to write a procedure that adds one to every number inside an array. We can either create a new array with a new set of numbers, keeping the old array intact (constructive), or change the old array in place (destructive): // destructive version: public void add1(int[] A) { for(int i=0;i