Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The State of a system is the stored information that determines its current status at a certain point in time.

Stateless system

Does not store information about past interactions with the system. So, it’s like the first interaction each time.

Code Block
languagejava
class Return{
    String interact(String input) {
        return input; 
    }
}

Other example of stateless system : HTTP (application layer protocol in the TCP/IP model used to transfer information between devices in a network); IP or Internet Protocol (network layer in the TCP/IP model used for sending packets from source to destination).

Statefull system

Stores information about the last interaction and the system may produce different outputs than the previous interactions.

Code Block
languagejava
class Counter {
    private int count = 0;

    int count() {
        count++;
        return count;
    }
}