Immutable Objects and classes
immutable classes need to meet the conditions:
-All data fields are private
-Methods without a modifier
-without an accessor, it will return a carton variable data field reference variable scope class variable/data field
instance variables and static variable local variables for a class
Variables defined internally by methods
If a local variable has the same name as a class variable, then the local variable takes precedence, and the class variable with the same name is hidden. This reference
keywordthis: refers to the reference name of the calling object itself. A common use is to reference the hidden data fields of a class. abstraction and encapsulation of classes
Class Abstraction
Detach the implementation and use of a class. The creator of the class provides a description of the class, letting the user know how to use the class. All of the methods and data fields that can be accessed from outside the class, as well as descriptions of how they are expected to act, are collectively referred to as contracts for that category.
Encapsulation of a class
The details of the implementation are encapsulated and hidden from the user. the design principle cohesion of the class
A class should describe a single entity, and all class operations should logically work together to support a coherent goal. Consistency
Follow standard Java program design style and naming conventions. Encapsulation of
A class should use the private modifier to hide its data, so that it is easy to maintain, so that the user can access it directly. Clarity of
Class should have a clear contract that is easy to interpret and understand. Integrity
In order to be used in a wide range of applications, a class should provide a variety of scenarios through properties and methods to suit the different needs of the user. instance and static
A variable or method that relies on a specific instance of a class should be an instance variable or method, and if a variable is shared by all instances of the class, it should be declared static.