Answer the question
In order to leave comments, you need to log in
Is this a violation of encapsulation?
Pseudocode:
class Changeable {
private state: string;
public createSnapShot(): Snapshot {
new Snapshot(state);
}
}
class Snapshot {
private state: string
public Snapshot(string state1) {
state = state1;
};
public getState() {
print(state);
}
}
getState()
breaks encapsulation Changeable
by exposing a private Changeable field to a public method? If not, in what case would the encapsulation be broken?
Answer the question
In order to leave comments, you need to log in
Is a violation.
More precisely, there is such a situation - you seem to have hidden it behind a method, but it seems like you have revealed it :) That is, you simulated enapsulation to violate it
. Getters / setters and the problem with encapsulation in Symfo ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question