Immutable interface GudangMovies21 Rebahinxxi LK21

      In object-oriented programming, "immutable interface" is a pattern for designing an immutable object. The immutable interface pattern involves defining a type which does not provide any methods which mutate state. Objects which are referenced by that type are not seen to have any mutable state, and appear immutable.


      Example




      = Java

      =
      Consider a Java class which represents a two-dimensional point.

      The class Point2D is mutable: its state can be changed after construction, by invoking either of the setter methods (setX() or setY()).
      An immutable interface for Point2D could be defined as:

      By making Point2D implement ImmutablePoint2D, client code could now reference a type which does not have mutating methods, and thus appears immutable. This is demonstrated in the following example:

      By referencing only the immutable interface, it is not valid to call a method which mutates the state of the concrete object.


      Advantages


      Clearly communicates the immutable intent of the type.
      Unlike types implementing the Immutable Wrapper pattern, does not need to "cancel out" mutating methods by issuing a "No Operation" instruction, or throwing a runtime exception when a mutating method is invoked.


      Disadvantages


      It is possible for instances referenced by the immutable interface type to be cast to their concrete, mutable type, and have their state mutated. For example:
      Concrete classes have to explicitly declare they implement the immutable interface. This may not be possible if the concrete class "belongs to" third-party code, for instance, if it is contained within a library.
      The object is not really immutable and hence not suitable for use in data structures relying on immutability like hash maps. And the object could be modified concurrently from the "mutable side".
      Some compiler optimizations available for immutable objects might not be available for mutable objects.


      Alternatives


      An alternative to the immutable interface pattern is the immutable wrapper pattern.
      Persistent data structures are effectively immutable while allowing modified views of themselves.


      References

    Kata Kunci Pencarian:

    immutable interface javaimmutable interfaceimmutable interface typescriptc# immutable interfacecompose immutable interface
    Immutable Infrastructure | PDF | Cloud Computing | Amazon Web Services

    Immutable Infrastructure | PDF | Cloud Computing | Amazon Web Services

    Immutable | Powering The Next Generation Of Web3 Games

    Immutable | Powering The Next Generation Of Web3 Games

    Immutable Brand Guidelines

    Immutable Brand Guidelines

    Immutable

    Immutable

    Immutable | Build the best web3 games on Immutable

    Immutable | Build the best web3 games on Immutable

    Immutable Toolkit – Immutable

    Immutable Toolkit – Immutable

    Products | Immutable Documentation

    Products | Immutable Documentation

    A Game-Changing Partnership: Immutable and Polygon | Immutable Blog

    A Game-Changing Partnership: Immutable and Polygon | Immutable Blog

    Immutable Games Studio | Creating The Next Generation Of Web3 Games

    Immutable Games Studio | Creating The Next Generation Of Web3 Games

    Increasing Array’s immutable interface – Conffab

    Increasing Array’s immutable interface – Conffab

    Immutable Infrastructure Lab - WWT

    Immutable Infrastructure Lab - WWT

    immutable

    immutable