I spend a good part of my time training Java developers away from this idea in order to help them make their code more testable and understandable. Queries and Commands are not just pedantic alternate names for Getters and Setters: thinking about objects with respect to what you can ask it to do (Command or Request) and what you can find out from it (Query) significantly improves the code that gets written.
The real question with all features is "Does it make a given task easier, better, or possible Y/N?" Said question is incredibly vague by design and should differ by situation.
1. Are only conventions. Nobody's forcing you to use them.
2. Simplify refactoring.
3. Are a necessary layer of abstraction any time that 'setting' a value requires updating a related value.
#1 and #2 are only a manner of taste and implementation-specific use cases of tooling built on top of a language. #3, however, is absolutely necessary, to avoid entire categories of business logic errors.
Just imagine if updating a string's value required you to also manually update the string's length. How many string-length related bugs do you think that kind of adventure will result in a typical program?
Arguing against setters is like arguing that
String s = "foo";
must also be accompanied with s.length = 3;
The two operations make zero sense to be done separately - doing so is just a minefield of bugs. The purpose of a setter is to combine similar inseparable operations together.A trivial pass-through setter obviously provides ~zero value, but it also carries with it ~zero cost. Any compiler worth its salt will optimize its invocation away.
You should have a constructor/factory for strings that will form/instantiate the string in a valid state, with its value matching its length. That's not the same thing as a setter that mutates the string in-place.
foo.bar = x; // could be normal assignment or a setter.1) different naming convention between members and props
2) dont expose members; use properties from the start for anything public
to assist with two, they introduce the default get/set implementation, like so:
public object Derp { get; set; }
for when you want to expose an interface with the assignment idiom but dont actually have any interesting implementation