Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Mutable classes should not inherit from Immutable ones #14

@punkstarman

Description

@punkstarman

A mutable class that inherits from an immutable one does not respect the Liskov Substitution Principle, a.k.a. the L in SOLID. An immutable object and its responses to getters can be cached indefinitely whereas a mutable object does not allow this.

For example, AbstractPersistentArray inherits from AbstractPersistentImmutableArray, adding setters that render what should be immutable, per the contract of AbstractPersistentImmutableArray.

This may just be a naming issue. If a suitable replacement for the term Immutable were found that doesn't imply a specific contract, for instance Readable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions