Comrades, tell me how in a decent society it is customary to solve such a problem:
We have, for example, such a class hierarchy
class A_Base { int x; int y; public A_Base(int x, int y) { this.x = x; this.y = y; } } class A_First : A_Base { string name; public A_First(int x, int y, string name):base(x,y) { this.name = name; } } class A_Second : A_First { string surname; public A_Second(int x, int y, string name, string surname):base(x,y,name) { this.surname = surname; } } Now we need to add another property in A_Base (and accordingly, initialize it in the constructor)
class A_Base { int x; int y; int z; public A_Base(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } } This means that it is necessary to change the definition of the constructor in the entire class hierarchy, adding a new parameter z there, although we do not change these constructors themselves - we only change the call of the parent. And somehow this is not very good.
class A_First : A_Base { string name; public A_First(int x, int y, int z, string name):base(x,y,z) { this.name = name; } } How are advanced PLO partners to act in such cases? To get a separate class / structure that will be a parameter for the constructor?
class A_Init { int x; int y; int z; } class A_Base { int x; int y; int z; public A_Base(A_Init init) { this.x = init.x; this.y = init.y; this.z = init.z; } } or is there another tricky pattern?