Moti Asayag has posted comments on this change.

Change subject: core: introduce context pattern
......................................................................


Patch Set 34:

(1 comment)

http://gerrit.ovirt.org/#/c/28829/34/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/context/CommandContext.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/context/CommandContext.java:

Line 48:     }
Line 49: 
Line 50:     public CommandContext setCompensationContext(CompensationContext 
compensationContext) {
Line 51:         this.compensationContext = compensationContext;
Line 52:         return this;
> this is very nice notation to allow:
i specified the list of my concerns regarding this in the message on patch 
level.

while it makes code easier to write, it makes it less clear to read (as i 
noticed while reviewing)

we tend to think of methods as responsible for a single action, while here a 
setter does 2 operations.

By looking at the setter signature one might wonder if this is a new instance 
or the existing instance modified.

this is more a matter of style.

I'd like to see other approach rather than using the setter to return the 
instance, i.e. 

  VdcQueryParametersBase.withoutRefresh() 

which the same sesmantics could be expanded to CommandContext:

  public class CommandContext ... {
  ...
     public void setCompensationContext (CompensationContext ctx) {
          this.ctx = ctx;
     }

     public CommandContext withCompensationContext (CompensationContext ctx) {
        setCompensationContext(ctx);
        return this;
     }

     public CommandContext withoutCompensationContext () {
        setCompensationContext(null);
        return this;
     }
...
}

and using it from CommandBase as:
    runInternalAction(..., dupContext().withoutCompensationContext ())

I find the separation between the setters to "withXXX" or "withoutXXX" clearer.

thoughts ?
Line 53:     }
Line 54: 
Line 55:     public CommandContext resetCompensationContext() {
Line 56:         return setCompensationContext(new 
DefaultCompensationContext());


-- 
To view, visit http://gerrit.ovirt.org/28829
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I310f5f77fff78b3232ee77fe63791425fd521516
Gerrit-PatchSet: 34
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Arik Hadas <aha...@redhat.com>
Gerrit-Reviewer: Moti Asayag <masa...@redhat.com>
Gerrit-Reviewer: Omer Frenkel <ofren...@redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourf...@redhat.com>
Gerrit-Reviewer: Ravi Nori <rn...@redhat.com>
Gerrit-Reviewer: Roy Golan <rgo...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to