java - Specifying method in getter/setter -
to understand meaning of encapsulation, example class private fields must accessed through class public methods per definition, stll doesn't make difference field still accessible is.
so,i think there should processing inside getters/setters hide how field being handled. breaks principal of behind pojos. how can 1 handle situation?
i'm not sure according "the principle of pojos". following pojo , still hides implementation details behind getters , setters:
public class example { private int thousands; private int units; public void setvalue(int value) { thousands = value / 1000; units = value % 1000; } public int getvalue() { return 1000 * thousands + units; } }
Comments
Post a Comment