rancho
rancho

Reputation: 66

Getters and Setters vs Oject key value pair

Trying to whiddle down a method for storing lots of data on an HTML page, similar to using csv file. Is using Getters and Setters for storing large arrays considered bad practice if data does not need to be private. I have been using something similar to what is shown here http://ejohn.org/blog/javascript-getters-and-setters/

I am using getter and setter functions to hold data collected from user, to be later used to reconstruct page.

Basically, should I use object with key value pair over Getter Setter function?

Upvotes: 1

Views: 376

Answers (1)

Wallysson Nunes
Wallysson Nunes

Reputation: 750

I think you might choose to use get and setters as a interface to handle your data, in some cases it can help you to organize your code and don't mess it arround.

At many cases i stick with getters and setters, which makes my code secure, as only that keys (the ones specified at your setter) will be updated. Also, you can implement the visibility on it, so only inside the class could access some methods, it will vary with your needs.

Upvotes: 2

Related Questions