You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- this doesn't seem to offer anything substantial over points made and explained in prior 17 answersgnat– gnat2014-09-08 10:12:44 +00:00Commented Sep 8, 2014 at 10:12
- 3The other answers talk about objects, interfaces and other languages paradigms. Which is fine, but it is not the central issue. Getters and setters are not just bad because they break some coding conventions, but primarily because you hardly ever encounter this behaviour in the actual model you are representing. This point tends to get lost in the discussion about the best coding practices.Cormac Mulhall– Cormac Mulhall2014-09-08 10:42:22 +00:00Commented Sep 8, 2014 at 10:42
- 1On the contrary, many businesses do have the equivalent of get and set payroll processes. Granted, those processes are wrapped within authorization layers but there are getters and setters nonetheless. An employee's manager sets the employee's salary; it's not payroll that does that. Likewise, the manager's manager can get the salary information for all of their reporting employees.user53019– user530192014-09-09 13:48:42 +00:00Commented Sep 9, 2014 at 13:48
- 3If they are wrapped around authorization layers and restricted to certain external entities they are not getters and setters. I'm not saying don't have any method on the payroll department that changes the salary, but that method should align with the internal processes in place in the company itself. For example most companies set salary based on the employees contract, which is authorized by a manager. If the employee's salary changes a new contract is drawn up and a manager has to sign it. Therefore payroll should expect a contract object and some authorisation object to change pay rollCormac Mulhall– Cormac Mulhall2014-09-09 14:17:56 +00:00Commented Sep 9, 2014 at 14:17
- 4Or to put it another way, there is quite a difference between set_salary(new_salary, employee_id) and authorized_salary_update(employee_contract, authorising_manager). The process should model the internal business processCormac Mulhall– Cormac Mulhall2014-09-09 14:23:56 +00:00Commented Sep 9, 2014 at 14:23
| Show 2 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java