#171 Code Review of a Client Model

Companies:
Rostelecom
Themes:
JavaOOPCode Review

Perform a code review:

Java
public final class Client {
    public long id;
    public String name;
    public static ArrayList<String> roles = new ArrayList<>();

    private Client(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public synchronized void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        Client client = (Client) o;
        return id == client.id && name == client.name;
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in