Vojtech Szocs has posted comments on this change.

Change subject: frontend: Introducing oVirtJS / GWT wrapper projects
......................................................................


Patch Set 9:

(4 comments)

Martin, thanks for the comments!

I'd be happy to see more review comments, don't be shy :-)

https://gerrit.ovirt.org/#/c/33720/9/frontend/ovirtjs/ovirtjs-lib/src/main/services.js
File frontend/ovirtjs/ovirtjs-lib/src/main/services.js:

Line 1: import constants from './constants.js';
Line 2: 
Line 3: // Service that facilitates communication with remote HTTP servers.
Line 4: export class Http {
> I believe this could also be made a singleton object instead of static clas
That's a good point!

I think we can change it to:

 export Http {
     send ({ method, url, headers, body }) {
         ...
     }
 }

Service methods (like "send") are essentially an interface consumed by API 
implementation, which is also a reason for avoiding ES6 class syntax (which 
blurs the line between interface and implementation).
Line 5: 
Line 6:     // Send HTTP request to remote server.
Line 7:     // Return `Promise` that resolves to HTTP response text.
Line 8:     // Implementation is based on `XMLHttpRequest` object.


Line 4: export class Http {
Line 5: 
Line 6:     // Send HTTP request to remote server.
Line 7:     // Return `Promise` that resolves to HTTP response text.
Line 8:     // Implementation is based on `XMLHttpRequest` object.
Martin, do you think we should separate service API from its default (works in 
web browsers) implementation, or just have them both in one place?
Line 9:     // - method: HTTP method to use, defaults to `GET`.
Line 10:     // - url: URL to send request to, defaults to empty string 
(document base URI).
Line 11:     // - headers: HTTP headers, defaults to empty object.
Line 12:     // - body:  Any value supported by `XMLHttpRequest.send` function, 
defaults to null.


Line 8:     // Implementation is based on `XMLHttpRequest` object.
Line 9:     // - method: HTTP method to use, defaults to `GET`.
Line 10:     // - url: URL to send request to, defaults to empty string 
(document base URI).
Line 11:     // - headers: HTTP headers, defaults to empty object.
Line 12:     // - body:  Any value supported by `XMLHttpRequest.send` function, 
defaults to null.
We shouldn't take XMLHttpRequest as reference here.

We should only accept a string here.
Line 13:     static send ({ method, url, headers, body }) {
Line 14:         return new Promise((resolve, reject) => {
Line 15:             var xhr = new XMLHttpRequest();
Line 16: 


https://gerrit.ovirt.org/#/c/33720/9/frontend/ovirtjs/ovirtjs-lib/src/main/utils.js
File frontend/ovirtjs/ovirtjs-lib/src/main/utils.js:

Line 1: // Utility for working with objects.
Line 2: export class ObjectUtil {
> This looks to me very java-like :-) We could simplify this to be a simple s
Yes, ES6 class with only static methods brings the memories of Java :-)

Agreed, we can just do:

 export ObjectUtil {
     computeDiff (original, modified) {
         ...
     },
     ...
 }

Also, just like in services.js - we can utilize ES6 destructuring:

 computeDiff ({ original, modified }) { ... }

and the main goal of that is better readability (method parameters indexed by 
name, instead of their relative position in the argument list).
Line 3: 
Line 4:     // Compute change between `original` and `modified` objects.
Line 5:     // Return diff object containing the difference.
Line 6:     // Diff object will be null if there is no change.


-- 
To view, visit https://gerrit.ovirt.org/33720
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2646646bc880446aa3035dd951e65c9af81933a1
Gerrit-PatchSet: 9
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vojtech Szocs <vsz...@redhat.com>
Gerrit-Reviewer: Alexander Wels <aw...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Einav Cohen <eco...@redhat.com>
Gerrit-Reviewer: Gilad Chaplik <gchap...@redhat.com>
Gerrit-Reviewer: Greg Sheremeta <gsher...@redhat.com>
Gerrit-Reviewer: Jenny Kang <jennykan...@gmail.com>
Gerrit-Reviewer: Kanagaraj M <kmayi...@redhat.com>
Gerrit-Reviewer: Lior Vernia <lver...@redhat.com>
Gerrit-Reviewer: Martin Betak <mbe...@redhat.com>
Gerrit-Reviewer: Tomas Jelinek <tjeli...@redhat.com>
Gerrit-Reviewer: Vojtech Szocs <vsz...@redhat.com>
Gerrit-Reviewer: Zuzana Svetlíková <19svetlan...@gmail.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