Skip to main content

Questions tagged [getters]

4 votes
2 answers
2k views

I've read somewhere about a pattern that is as follows: if it'll change the state of the instance, the method should be named with a verb and return void; and if the method just returns something (...
Bernardo Benini Fantin's user avatar
2 votes
1 answer
451 views

Might be a silly question or something I might have just messed up in my head but here we go... I saw a code example of someone using getPos() in their own class to retrieve the current position of an ...
darclander's user avatar
-2 votes
2 answers
767 views

Everywhere is said that a private member can only be accessed from inside the same class, but at the same time, we can access the private member using getters and setters, therefore my question is: ...
Ian Mozz's user avatar
84 votes
12 answers
31k views

I’m still really new to learning to program. Just learning the syntax for a few programming languages at the moment. The courses I viewed for C# and Java touched only very briefly on getters & ...
ProjectDiversion's user avatar
2 votes
2 answers
428 views

Consider the following JavaScript code: class MyClass { #myPrivateField; constructor() { #myPrivateField = new AnotherClass(); this.theGetter.method1(); // or: this.#myPrivateField....
goodUser's user avatar
  • 129
3 votes
4 answers
2k views

I work on refactoring an Java application based on a CAST audit. One of the criterion says that To respect OO encapsulation concepts, private fields should always be accessed through accessors So ...
The Once-ler's user avatar
0 votes
1 answer
595 views

I have a doubt about if there are some recommendations for call directly an attribute in a class I think that in OOP you always should call an attribute by the get method. For example: On set ...
Tlaloc-ES's user avatar
  • 387
0 votes
0 answers
2k views

To provide a very blunt example (as I am at work and can't currently think of a sensible example). If I write a groovy class like this class Wendy{ byte[] frank String doSomethingWithFrank(){...
WendyG's user avatar
  • 133

15 30 50 per page