Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [getters]

The tag has no usage guidance.

0
votes
0answers
16 views

Is a bad practice to instantiate an Activity class just to use a getter from onPostExecute within an AsyncTask?

GOAL: I need to get a value within an async task. The value is declared within a previous called Activity. QUESTION: is a bad practice to instantiate the Activity from which I need the value just to ...
-2
votes
1answer
149 views

Set result of getter instead of setter [closed]

Is this a legit use of getter Lady lady = new Lady(); lady.getWater() = "hot water"; if we suppose getter returns Class Lady { public String getWater() { this.water; }} ?
3
votes
2answers
179 views

OOP in Java - What can getters be used for?

Usually, getters always return the value of a variable. I learned in my literature that access to fields is controlled by getters and setters. When I had my code rated by programmers, it was suddenly ...
2
votes
2answers
330 views

Is there any reason to avoid private getters?

Even though I could write something like this (In C#. There are, of course, equivalents in other languages): public int SomeNumber { private get; set; } I have never encountered something like this. ...
11
votes
5answers
3k views

Is it a bad idea to use getters/setters and/or properties at all? [duplicate]

I am perplexed by comments under this answer: https://softwareengineering.stackexchange.com/a/358851/212639 A user is arguing there against the use of getters/setters and properties. He maintains ...
3
votes
2answers
514 views

Dealing with a lot of getters and setters

I've already asked "Dealing with a large interface". I have a further question regarding that situation. It was pointed out to me that I used a lot of getters and setters and so I broke encapsulation....
7
votes
4answers
423 views

Encapsulation and Displaying Information

This site and SO contain many pages about getters/setters and if they break encapsulation or enforce it. My question is for those developers that agree that getters/setters break encapsulation and ...
4
votes
4answers
476 views

How exactly are getters and setters defined?

Note: Questions with similar title have been asked before, but please read the full text before claiming that this is a duplicate. Since everybody in OOP uses the terms getter and setter, I would ...
1
vote
2answers
157 views

Conflict in getter and setter method names in ruby api design

I am inheriting an api decision in an SDK I am writing where I am required to fetch domain objects (entries) from the server like this: blogEntries = client.content_type('blog').entries As you can ...
0
votes
2answers
799 views

Should the getters and setters of a stl container access the container itself or the elements inside it?

Consider I have a vector and map as class members: class MyClass{ protected: std::vector<int> myVector; std::map<int,std::string> myMap; }; Should the getter and setter access ...