Tuesday, September 11, 2007

Java For Artists Chapter 1 summary

Chapter 1: An approach to the art of programming

There are five steps to the programming cycle: plan, code, test, integrate, and refactor.

Use method stubbing to test sections of source code without having to code the entire method.

There are two types of complexity: conceptual and physical. Object-oriented programming and design techniques help manage conceptual complexity. Physical complexity is managed with smart project file-management techniques, by splitting projects into multiple files, and using packages to organize source code.

Self-commenting source code is easy to read and debug. Adopt smart variable, constant, and method-naming conventions and stick with them.

Maximize cohesion minimize coupling!

Chapter 1 Self test


1.
List at least seven skills you must master in your studies of the Java programming language.
The seven skills which must be mastered in order to be competent as a JAVA programmer are:
a. A development environment. You must have at least a text editor and a compiler to begin your work.
b. A computer
c. Problem Solving skills
d. Knowledge of how to approach programming tasks and projects.
e. How to put yourself in the mood to program
f. Object oriented programming and complexity
g. OO programming skills
h. An API


2. What three development roles will you play as a student?
Analyst -- At first you will play the role of analyst. You will need to work through the problem/task you are trying to accomplish and think of the many facets it may have.
Architect -- Once you understand your problem, you must design a solution for the problem. Two components of a good design are the scalability and a lack of complexity if possible.
Programmer -- You will then play programmer and actually code the project.

3. What is the purpose of the project-approach strategy?
The purpose of the project approach strategy is to give you directions and goals. It allows you to break large projects down into smaller units and accomplish small portions at a time.

4. List and describe the four areas of concern addressed in the project-approach strategy.
1. Application Requirements -- These requirements make assumptions about the application behavior.
2. Problem Domain -- This is the specific problem you are being asked to solve.
3. programming language features -- this is a listing of all features that will be used. review the list to make sure all components are understood.
4. High-Level Design & Implementation Strategy -- This can be a procedural based design approach or an object oriented design approach.
A procedural approach breaks the problem down into many smaller problems and keeps the code seperate from the data structures it manipulates.
An object oriented approach thinks about objects and the interactions between those objects. The data an object needs to maniupulate or work is contained within the object itself.
5. List and describe the five steps of the programming cycle.


6.
What are the two types of complexity?
There are 2 basic types of complexity. There is conceptual complexity which is that part of the software that is controlled by its architectural design. The better the architecture the better the design. If you plan well enough then scalability and changes are made easily.
The second type of complexity is physical complexity. Physical complexity is the number of designs and documents created by the programmers during the designing of the software.

7.
What is meant by the term isomorphic mapping ?
Isomorphic mapping refers to the idea that though 2 or more things can have differnt outwardly physical properties they are structurally the same and can be used intercahngebly. For example you have a brown deck of cards and a green deck. Even though the backs are different colors you could if you chose to divide them in two and play then mix them and still play cards.

8.
Why do you think it would be helpful to write self-commenting source code?
Self commenting code is an identifier naming technique that can be used to effectively manage both the physical and conceptual complexity. An identifier is a sequence of java characters or digits used to form names of entities used in your program. Examples of entities include classes, constants, variables and methods. All you have to do to write self commenting codes is to give meaningful names to your program entities and adopt a consistent naming convention. Because java allows unlimited identifier names you can be pretty desvriptive. The benefits of self commenting code are it is easier to read and therefore understand thereby making it easier to track down logic errors and mistakes.
There is a standard for self commenting code:

ClassNames should start with an initial capital letter and if there is more than one word in the class name capitalize each subsequent word used to fork the class name.
Examples: EngineController, ConditionReport, DataReferenceSync,

CONSTANT_NAMES Constants represent values in your code that cannot be changed once initialized. They should also describe the values they contain and should be all capitalized.
Examples: PI, MAX, MAX_MILES

variable_names Variable names represent values that can change while the program is running. Variable names should be formed from lowercase characters to set them apart from constants.
Examples: size, current_row, engine_size

methodNames A method represents a named series of JAVA statements that perform some action when called in a program. Since methods invoke actions their names should only be formed from action words(verbs) that describe what they do. Begin method names with a lower case character and capitalize each subsequent word of a multiple-word method.
Examples: printFloor, setMaxValue, getMaxValues


9.
What can you do in your source code to maximize cohesion?

Cohesion is the degree to which a piece of software sticks to its intended purpose. A high degree od module cohesion is desired. For example, a method intended to display an image on the screen would have a high degree of cohesion if that is all it did and poor cohesion if it did other things as well. So in order to maintain maximum cohesion, if you have other things to do put them in a different class or method.



10.
What can you do in your source code to minimize coupling?

Coupling is the degree to which one software module depends on software modules external to itself. A low degree of coupling is desired. Coupling can be controlled in object oriented software by depending upon interfaces or abstract classed rather than upon concrete implementation classes.

No comments: