vendredi 16 juin 2017

Is it bad design if we add logic in getter and setter of entity class

JAVA 8

I have user pojo class {name(string), password(string)} which i will use as an entity class.

In the getter/setter of password, I want to add decryption/encryption logic.

public String getPassword() {
        return EncryptionFactory.decryption(password);
    }
    public void setPassword(String password) {
        this.password = EncryptionFactory.encryption(password);
    }

EncryptionFactory is a utility class which encrypt or decrypt as string.

My question is : Based on the General Java coding guidelines if i add logic to alter password, Does it break design or its a bad design ?

While using it i got bad design feedback from my professors.

Aucun commentaire:

Enregistrer un commentaire