Alessandro100 / concordia-campus-guide

React project that allows navigation of concordia campuses
GNU General Public License v3.0
1 stars 0 forks source link

Use proper Typescript practices for setters and getters #133

Open wltrf opened 4 years ago

wltrf commented 4 years ago

The classes under ./classes all implement the setProp() and getProp() methods while also leaving the property itself public. This should be changed to follow proper practices which looks like the following:

private _value : string;
public get value() : string {
  return this._value;
}
public set value(v : string) {
  this._value = v;
}

This allows to call the prop directly as if it was a public property, but in the background it actually calls the proper set or get methods. E.g. calling instance.prop="test" will be actually call the set method.

wltrf commented 4 years ago