Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting superclass #1038

Merged
merged 1 commit into from
May 4, 2016
Merged

Extracting superclass #1038

merged 1 commit into from
May 4, 2016

Conversation

alexVengrovsk
Copy link
Contributor

Signed-off-by: alextrentton@gmail.com

If-check in the getResourceBasedNode() method can be simplified. This change allows to exclude one check and protect method from NullPointerException. But this method still can throw this exception in line
Object o = selection.get(0);
I wasn't shure is it expected behaviour, so, didn't chenge anything there.

In the parseMessage() method it is posible to exclude the last if-check, because method indexOf() will return index or -1 if there is no searching sequence in the String.

One more question - both changed classes have identical methods with identical bodies: getResourceBasedNode(), isResourceAndStorableNode(), parseMessage(). Maybe, it would be better to create some utility class (for example - UploadUtil) with this methods and to use this class for both UploadFilePresenter and UploadFolderFromZipPresenter?
The same story about methods addFile() (from UploadFileViewImpl) and addFileUploadForm() (from UploadFolderFromZipViewImpl).

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@skabashnyuk
Copy link
Contributor

ok. @vparfonov @garagatyi ?

@alexVengrovsk
Copy link
Contributor Author

Commit allows to exclude one more check - fileName.contains("\\") in the UploadFolderFromZipViewImpl and UploadFileViewImpl.

@garagatyi
Copy link

Thank you Alex for the contribution! Generally I'm OK with these fixes, but in my opinion these classes should be refactored instead of using util methods.
We've discussed that with @vparfonov. He is the lead of client-side in Che.
He will explain our thoughts soon.

@alexVengrovsk
Copy link
Contributor Author

Ok. Yes, it is a better idea!

@vparfonov
Copy link
Contributor

Hi thanks for you work. This is good catch form you side. And i totally agree with you that will be better create base class for Upload File views and move basic logic there.

@alexVengrovsk
Copy link
Contributor Author

@vparfonov Do you want it as a superclass for them? If so, I can do this in this PR.

@vparfonov
Copy link
Contributor

@alexVengrovsk superclass

@alexVengrovsk
Copy link
Contributor Author

@vparfonov Ok. Will be done

@alexVengrovsk
Copy link
Contributor Author

@vparfonov It is finished. Please, have a look.

@alexVengrovsk
Copy link
Contributor Author

@vparfonov I resolved all conflicts. Can you check this PR?

@alexVengrovsk
Copy link
Contributor Author

alexVengrovsk commented Apr 20, 2016

@skabashnyuk @garagatyi Sorry for bothering you, but is it something wrong with this PR? If so, tell me please and I will try to improve it.

@garagatyi
Copy link

As for me fact that some presenter extends some util doesn't look good. Utils should be used by composition, not inheritance. But it is up to @vparfonov because his expertise in client-side code is deeper.

@vparfonov
Copy link
Contributor

yep will be better have something like BasicUploadPresenter or AbstractUploadPresenter instead of PresenterUtil

@alexVengrovsk
Copy link
Contributor Author

alexVengrovsk commented Apr 20, 2016

@vparfonov It could be changed. Do you agree with @garagatyi about using composition instead of inheritance? Composition seems preferable for me too.

@alexVengrovsk alexVengrovsk changed the title Reducing qantity of if-checks Extracting superclass Apr 20, 2016
@alexVengrovsk
Copy link
Contributor Author

@vparfonov I have renamed the PresenterUtil to the BasicUploadPresenter. I think, that now this PR is ready.


protected boolean isResourceAndStorableNode(@Nullable Node node) {
return node != null && node instanceof ResourceBasedNode<?> && node instanceof HasStorablePath;
BasicUploadPresenter basicUploadPresenter = new BasicUploadPresenter(projectExplorer);
Copy link
Contributor

@vparfonov vparfonov Apr 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not good use create presenter with constructor try please use injection instead. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Signed-off-by: <alextrentton@gmail.com>
@alexVengrovsk
Copy link
Contributor Author

@vparfonov I have changed instance creation with injection

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@vparfonov vparfonov merged commit 694a297 into eclipse-che:master May 4, 2016
@alexVengrovsk alexVengrovsk deleted the che-ovengr-2 branch May 4, 2016 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants