3 replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
source | link

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. This is also the usual pattern when you want to make an object immutable. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

Further Reading
http://programmers.stackexchange.com/questions/21802/when-are-getters-and-setters-justifiedWhen are Getters and Setters Justified

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. This is also the usual pattern when you want to make an object immutable. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

Further Reading
http://programmers.stackexchange.com/questions/21802/when-are-getters-and-setters-justified

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. This is also the usual pattern when you want to make an object immutable. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

Further Reading
When are Getters and Setters Justified

2 added 77 characters in body
source | link

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. This is also the usual pattern when you want to make an object immutable. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

Further Reading
http://programmers.stackexchange.com/questions/21802/when-are-getters-and-setters-justified

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. This is also the usual pattern when you want to make an object immutable. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.

Further Reading
http://programmers.stackexchange.com/questions/21802/when-are-getters-and-setters-justified

1
source | link

The simplest way to avoid setters is to hand the values to the constructor method when you new up the object. That said, things are not always that clear in the real world.

It is true that methods should be about behavior. However, some objects, like Customer, exist primarily to hold information. Those are the kinds of objects that benefit the most from getters and setters; were there no need at all for such methods, we would simply eliminate them altogether.