3 ms·
You don't seem to realize it but your countLines() method is a getter. At the end of the day, you need to get values from your class, otherwise, they are usele
by incepted 11y ago
You don't seem to realize it but your countLines() method is a getter.
At the end of the day, you need to get values from your class, otherwise, they are useless (and they do side effects).
- jasode 11y ago>At the end of the day, you need to get values from your class, Yes, you eventually have to <scarequote>"get"</scarequote> values from the class but you don't literally have to mindlessly create a one-to-one set of "get()" for every private member variable. The author's example and my response to it were talking about a literal thin wrapper of public getX() for a private int x. This practice deceptively looks like OOP (I "hid" that private member with a public method) but it's not really OOP. Instead of gets() & sets(), the programmer should find the higher level concepts to turn into higher-level methods. This way, the gets()/sets() is kept to a bare minimum.