QueenSvetlana
Beta member
- Messages
- 3
- Location
- Russia
Why is it so hard to agree on certain design patterns? Why are there various opinions? I'll give you an example.
Not too long ago I was doing a hobby project in Java, and the topic of encapsulation came up. If you were to do a search, you'll find several forums/threads that are divided when it comes to this topic. Some say getters/setters are evil and should be avoided, that the object should perform the calculation/behavior, and give you the result. Now, I believe that getters/setter don't break encapsulation, they enforce it. I favor creating immutable classes, so I don't use setters, but I use getters to display my data.
Why is this topic and several others hard to define an answer for? I don't work professionally as a programmer, so forgive me if my questions sounds a little foolish.
Side Note: I didn't place this question in the programming forum because it's about design patterns, and it will have various answers with different opinions. I don't want to take attention away from someone who has a problem with code.
Not too long ago I was doing a hobby project in Java, and the topic of encapsulation came up. If you were to do a search, you'll find several forums/threads that are divided when it comes to this topic. Some say getters/setters are evil and should be avoided, that the object should perform the calculation/behavior, and give you the result. Now, I believe that getters/setter don't break encapsulation, they enforce it. I favor creating immutable classes, so I don't use setters, but I use getters to display my data.
Why is this topic and several others hard to define an answer for? I don't work professionally as a programmer, so forgive me if my questions sounds a little foolish.
Side Note: I didn't place this question in the programming forum because it's about design patterns, and it will have various answers with different opinions. I don't want to take attention away from someone who has a problem with code.
Last edited: