Updating component twice in a method

Say, I have some system and a method in it declared as such:

protected cmpA doSmthg(cmpA a)
  cmpA newA = a;
  newA = a.setFieldA(...);  // constructor 1 of cmpA
  newA = a.setFieldB(...);  // constructor 2 of cmpA
  return newA;

then is update():

cmpA myA = doSmthg( ed.getComponent(e.getId(), cmpA.class) );
ed.setComponent(e.getId(), myA);

will it work this way?

Probably a dumb question, but well… 12 hours of coding today :tired_face:

Sure… I don’t see any reason it won’t work.

A couple style issues:

  1. for my own stuff, I adopt the changeA(), changeB() style conventions because they don’t get confused with classic setters.
  2. if you find that you set A and B a lot together then you can save a little garbage by having a changeAB(A, B) method… since you avoid the extra unnecessary temp object that way.

Ok, thanks! I’ll be sleeping better knowing at least I’ll start seeking elsewhere n code tomorrow :slight_smile:

Are you actually seeing an issue? Perhaps that’s a better place to start.

disregard this, I believe I know what the issue is.