Linked Questions

242 votes
16 answers
88k views

I'm currently working on a simple game in Java with several different modes. I've extended a main Game class to put the main logic within the other classes. Despite this, the main game class is still ...
Mike B's user avatar
  • 12.8k
173 votes
8 answers
515k views

I was wondering what were the differences between those declaration of getters and setters and if there is a preferred method (and why). The first one can be generated automaticly by Visual Studio. ...
WizLiz's user avatar
  • 2,098
85 votes
12 answers
105k views

Possible Duplicate: Why use getters and setters? I have read books on Java, saying that it is good to create setters and getters for variables such as x and y. For example: public int getX(){ ...
Anonymous181's user avatar
  • 1,883
53 votes
13 answers
11k views

Allen Holub wrote the following, You can't have a program without some coupling. Nonetheless, you can minimize coupling considerably by slavishly following OO (object-oriented) precepts (the most ...
James McMahon's user avatar
36 votes
13 answers
24k views

Getters and Setters are bad Briefly reading over the above article I find that getters and setters are bad OO design and should be avoided as they go against Encapsulation and Data Hiding. As this is ...
Julio's user avatar
  • 6,386
76 votes
4 answers
76k views

Possible Duplicate: Why use getters and setters? Is there any advantage to making methods to access private variables in your class instead of making the variable public? For example is the ...
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz's user avatar
31 votes
14 answers
10k views

Please forgive the length, but here are two programs, both the exact same, but one with and one without setters, getters, and constructors. I've taken a basic C++ class before and don't remember any ...
Soully's user avatar
  • 849
38 votes
6 answers
51k views

I have been taught to always use getters and setters. However, I don't know the pros and cons of these methods, as by implementing them we are exposing the data and also hiding it. I am a little ...
School Boy's user avatar
  • 1,183
22 votes
9 answers
17k views

We always say that data will be encapsulated if we simply define variables private and define getters setters to access those variables. My question is if we can access the variables (data) though via ...
Just_another_developer's user avatar
25 votes
9 answers
84k views

I want to know when to use get and set methods(getName,setName ) in my class and when simple classVariable.name = "" instead а = classVariable.getName() Here is example of class using set and get ...
Jovan's user avatar
  • 4,802
10 votes
15 answers
15k views

In object oriented programming, I used to have this question and I still do : What would be the benefit of declaring a class member as private if we will create for it a public getter and a public ...
loulou's user avatar
  • 331
16 votes
5 answers
28k views

Possible Duplicates: Why use getters and setters? C# 3.0 Auto-Properties - useful or not? Is there a difference between defining properties the following way - // private, with getter & ...
kosh's user avatar
  • 561
25 votes
2 answers
27k views

I saw a code where getters and setters methods are declared private. I am trying to figure out the logic behind it, and I am really having hard time to understand why would you declare them as private?...
Vandan Patel's user avatar
15 votes
5 answers
25k views

If I can change the value of private variable through getter-returned reference then isn't it bypassing the setter method? Doesn't it defeat the purpose of getter-setter and private variables public ...
genonymous's user avatar
  • 1,780
8 votes
8 answers
8k views

I've always been told to encapsulate ANY and ALL properties from a class... This is right: private string propertyName; public string PropertyName { get { return propertyName; } set { ...
Gabriel Marcondes de Oliveira's user avatar

15 30 50 per page
1
2 3 4 5
26