Basic Java Concepts
Basic Java Concepts
Java Chapter Basic Summary
- A class should represent a single concept from the problem domain, such as business, science, or mathematics.
- The public interface of a class is cohesive if all of its features are related to the concept that the class represents.
- A class depends on another class if it uses objects of that class.
- It is a good practice to minimize the coupling/dependency between classes.
- An immutable class has no mutator methods.
- A side effect of a method is any externally observable data modification.
- You should minimize side effects that go beyond modification of the implicit parameter.
- In Java, a method can never change parameters of primitive type.
- In Java, a method can change the state of an object reference parameter, but it cannot replace the object reference with another.
- A precondition is a requirement that the caller of a method must meet. If a method is called in violation of a precondition, the method is not responsible for computing the correct result.
- An assertion is a logical condition in a program that you believe to be true.
- If a method has been called in accordance with its preconditions, then it must ensure that its post-conditions are valid.
- A static method is not invoked on an object.
- A static field belongs to the class, not to any object of the class.
- The scope of a variable is the region of a program in which the variable can be accessed.
- The scope of a local variable cannot contain the definition of another variable with the same name.
- A qualified name is prefixed by its class name or by an object reference, such as Math.sqrt or other.balance.
- An unqualified instance field or method name refers to the 'this' parameter.
- A local variable can shadow a field with the same name. You can access the shadowed field name by qualifying it with the 'this' reference'.
- A package is a set of related classes.
- The 'import' directive lets you refer to a class of a package by its class name, without the package prefix.
- Use a domain name in reverse to construct unambiguous package names.
- The path of a class file must match its package name.
- Unit test frameworks simplify the task of writing classes that contain many test cases. The JUnit philosophy is to run all tests whenever you change your code.
- Mutator methods modify the object on which it is invoked
- Accessor method accesses info without making any mods.
- Always get the same answer, unlimited, and state of object does not change.
- Immutable methods have only accessor and not mutator
- Safe to give out references to its objects freely
- Once a string is constructed, its contents never change.
- A class should represent a single concept from the problem domain, such as business, science, or mathematics.
You can leave a response, or trackback from your own site.
Wednesday, April 14, 2010
nahid5692001
,
0 Response to "Basic Java Concepts"
Post a Comment