What is an unchanging object?
In object -oriented programming, an unchangeable object is an object whose properties cannot be changed after creation. On the other hand, most objects are variable objects, which means that some or all their properties can be freely changed after creation. Many computer languages have the ability to create unchanging objects, including Java, C ++, Erlang, TCL and Scala.
An unimpressed object can be created in one of the two ways: by creating a class that is by definition or explicitly declares an otherwise rewardable object. The methodology for creating a fixed class varies depending on the computer language used. Regardless of the language, the unchanged class must not have any methods that can change its internal data and no way to change methods - ie overload or overload - in a way that would change its internal data. This is more complicated from two approaches. Creating an unchanged object from Otherwise mutable object, on the other hand, can often be used a keyword to indicate the object as unchanged.
As an example, the creation of objects in Java strongly relies on the "final" keyword. The quick way to make the class of unchanging in Java is to declare a class, as well as all its methods and data members, the finals. A similar strategy can also be used in C ++ with the keyword "Const". However, these approaches may not be the best depending on the content of the class. In general, objects can usually be not changed by careful maintenance of their internal data.
creation of a constant object using the keyword, as in the above example, is often much easier than to write the entire class to be non -changing. However, the use of this approach has its dangers. When explicitly marking a constant object, it is important that the programmer assures that all appropriate data properties were first incorporated into the object. Relying on an incomplete building can be dangerous, especially if the basic information is missing.
If Je Object variable, but requires that the unchanged data be correctly created, unchanging data must be initiated before the variable object is performed. Immitable objects are always unchanging, whether they are data or large objects and must always be treated. In general, after its creation, an unchanged object cannot be transformed, although it is sometimes copied as variable objects. Usually it can be assumed that there is also an unchanging unchangeable object and some of its copies, which can prevent data or memory problems.