mardi 2 février 2021

What is a nice pattern/ implementation for a class mainly holding variables?

Say I had a class that had:

static ThingA getThingA() {
   return thingA.Builder
          .withXC()
          .withCX()
}

static ThingB getThingB() {
   return thingB.Builder
          .withXC(A)
          .withCX()
}

static ThingC getThingC() {
   return thingB.Builder
          .withXC()
          .withCX()
}

static ThingC getThingD() {
   return thingB.Builder
          .withZZ(B)
          .withCC()
          .withDD(C)
}

Is there a better way of doing this than each having their own method? I was hoping there's a nice pattern or means of refactoring this but I dont know... Especially if it's used for a test class util

Aucun commentaire:

Enregistrer un commentaire