Peter Griffin
Sept 22 2005
This week we hit upon the key objectives of the class: abstraction and modularization. It is these modeling and thinking techniques that make for truly simple and intuitive programs. We looked at many different kinds of models, especially on thier difference in focus compared to how the object or task was modeled. For instance, from the perspective of an FBI agent, the details about a person that are important are things like their name, age, family history, criminal record, finger prints, DNA structure; and if they were being modeled by a docot, the doctor would look at them entirely differently. Although both cases model a human, the focus of the task is different, so some different properties of humans are modularized. The more time a project is spent in the thinking and planning phases, the less time and agony will be spent debugging and cursing.
Next we looked at the scope of a variable. This is an interesting feature implemented by Java that allows you to reuse names of variables and save on confusion and agony. Instance variables are created such that they may be accessed through any point in the class; but local variables and parameters are only recognized within the method they are created.
This leads to our next discovery: the "this" prefix. If you have a method that you wish to have a parameter of the same name as a field (which happens often), then you use the fieldname for the parameter name, and set it to the instance variable, using the "this./instance variable name"/ to differentiate between the "/parameter name" with the same name. /This is unimaginably useful and reduces the number of things one must remenber outside of what the code intuitively tells you.
We then touched upon the difference between internal method calls and external method calls. Internal method calls invoke methods inside the same object, when external ones call upon other objects and tell them to execute their method of the same name. This is written "Name of Object.Name of Method" and is one way objects interact with each other.
We also ran into the topic of method overloading. This is another way of Java allowing us to make our programs simple and intuitive. We are allowed to reuse method names, along as they differ in number or their parameters. This is used if, sometimes you want to "CreaeSquare" of set dementions, and othertimes "CreateSquare" and input the dimensions manually. Both of these constructors (for constructors are in themselves methods), would have the same name, but with different parameters.
I am enjoying the class and the lectures, and have no trouble with the tasks or anything else.
Thank you and see you Monday!