Should I specify the installer or not?

Here is the initial specification for the simple Address class. This is a simplification because it ignores complications such as apartments in the same building, potentially having the same number,
for example 29a, 29b.

 class Address
    {
    private:
    int number;
    string name;
    string postcode;
    public:
    //getters implemented but ommited 
    };

If "Address" should be used as a utility class (possible future use in other projects by other developers):

// QUESTION
1. For each Address attribute specified in the above specification, specify whether it would be advisable to equip the Address class with the setter method for the corresponding instance variable. Give a brief rationale in each case.

Guys, this is a question of my assignment, so please do not ask questions about how the Address class is structured.

+3
4

. , , , , , . , , , , , - , .

+8

, , , getters .

+5

, , . , , .

, "", .

+1
source

Should be an immutable class in my pov, with all fields set at build time, getter for each field.

If you really need to change the address after building, think of an installer for a complete set of fields to avoid modifying one field, which makes the data of objects inconsistent. It depends entirely on the use of the object.

0
source

Source: https://habr.com/ru/post/1758189/


All Articles