-
Notifications
You must be signed in to change notification settings - Fork 28
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
Code cleanup proposal #70
base: master
Are you sure you want to change the base?
Conversation
@remcohaszing all good ideas. I believe there is already work on-going to move to ES6 Promises and drop Q. |
I agree! Time to dump jshint for ESLint! Cordova-lib is due for a refactor. I really hate that addproperty code. Not sure why we went that way in the beginning. Maybe @purplecabbage knows? |
When our tests are run, unfortunately we have a much different case where lots of modules are loaded, then lots of methods are called. Switching to actual unit tests gets rid of this difference. The prototype bullshit that you see is mostly un-needed, I would rather make it more functional with unit tests than apply OOP principles that aren't needed. A more clearly defined contract between cordova-lib and cli consumers of it would make this much cleaner. I am a 'no' typically on most new shiny ES features. I am fine with 'const', and 'let', but would like to hold off on adding ticks, and arrow functions ( for a bit ) Q() being replaced with plain old Promise! I love it, I just removed Q from the cordova-browser! ESLint sounds great! |
+9001
For the record, the original PR that implemented the lazy loading is here: apache/cordova-lib#434. That PR description references a magical number claiming a 300ms load improvement. I'm wondering if 300ms is worth the obfuscation and difficulty in testing that is what I see as the downsides to that implementation. My ideal best-case in terms of easy of testing would be modules that are objects with functions exposed on the object. Then spying/stubbing/mocking becomes dead simple, and I'm sure we can remove a bunch of the integration tests and re-implement as unit tests. |
Let's reverse that test, and see what the difference is with changes that have been committed since then. This should be quick to compare ... |
K, I'll see what I can whip up today. |
First I will post results just looking at the changes to cordova-common. I will post cordova-lib results in a follow-up comment. Latest master of cordova-common, which includes lazy loading, on my Macbook Pro 2016 running node 6 has the following (rough) results: Just requiring the top-level cordova-common module (so not including anything, since none of the sub-properties are being accessed):
Next, requiring and accessing the
Finally, requiring and accessing one of
I have a branch of cordova-common with lazy loading removed on my fork here. Requiring the module, which should pull in everything, has the following results:
|
Alright, and some comparisons now for the cordova-lib code. The code for removal of all lazy-loading from both cordova-common and cordova-lib is on my no-lazy-load branch of my fork. First, latest master (includes lazy load) results, referencing just the top level module - very similar to cordova-common:
Accessing cordova-lib's lazy-loaded
And accessing the lazy-loaded
And with lazy loading completely removed:
Would still need to massage my no-lazy-load branch a bit - there are some So it looks like indeed, it is still a ~300ms load time without lazy loading, and in the best case you are saving a few ms less than that if we leave lazy loading in. |
I feel like you have proven we should revert addProperty bs :) |
Created an issue to replace jshint with eslint. https://issues.apache.org/jira/browse/CB-12895 |
Should I file an issue for axing lazy-load? |
Just out of curiousity, did you time the difference in running the tests?
`time npm run jasmine`
@purplecabbage
risingj.com
…On Wed, Jun 7, 2017 at 11:53 AM, Fil Maj ***@***.***> wrote:
Should I file an issue for axing lazy-load?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC0NvbEPMM7K9hgjX3_c-7ZSBU6yCX-ks5sBvG2gaJpZM4Nv5JH>
.
|
@purplecabbage in the process of doing those right now. Just updating my repos/forks since some of the sub-projects from cordova-lib were broken out. Here's the comparison for cordova-common: Master branch:
And my
Funny that the spec execution itself is slightly faster, but the overall execution of Going to now set up a proper |
Alright, and comparison for the latest cordova-lib follows. Master:
And off my
So it looks like this affects test run times as well. However, worth noting that by removing the lazy loading code, I am confident we can rewrite a lot of the integration tests as unit tests, making them much faster. So, I don't think the decision on whether to keep or remove lazy loading should be based on test times at this point in time. |
P.S. I would happily volunteer to work on reviewing the current test coverage of the I/O-heavy tests, seeing if we double-up on test coverage anywhere, and simplifying/migrating to faster unit tests. |
We have already started moving integration tests into the integration-tests folder in cordova-lib |
I'd like to bring up an issue related to two points in the proposal: support for callback-as-last-argument async handling. This is related to both "use ES6 promises" as well as "remove Currently, all of the main Can someone point me to instances where this particular invocation method is used, either internally or externally? I'm wondering how useful providing this mechanism is. If we are OK with removing it, and changing the library API such that we require promises to be used, then we can remove |
I'm pretty sure it's not used. |
Sweet. I'll update my branch later today. Do you think we'd need to do a major version bump? |
Related to removal of the callback-as-last-argument wrapping, I believe we could then also remove the |
These sound like api changes to cordova-lib right? cordova.raw.* is how people currently interact with cordova-lib. We should be careful about breaking our API |
If we remove lazy loading and callback-wrapping-for-promise-compatibility, then there would be now difference between I am in favour of doing that removal and bumping the major version. |
I mean, I suppose for API compatibility we could leave the |
Wouldn't every library that relies on cordova-lib break? I'm against the removal without a proper deprecation notice. It would be better to make cordova.raw an alias if there is no difference between the two. |
We could deprecate the .raw interfaces, and just leave them pointed to the
same things.
Our API is NOT published, which to me is another huge issue, as we have no
idea what little tricks others are using to pull functionality out of us.
We should solidify the contract for anyone who wants to use cordova-lib in
their projects, my expectation is that other clis probably start by looking
at what and how cordova-cli does things, but over time they may browse the
lib code and hook their dependencies deeper.
|
OK I'll leave the I will, however, update all internal code + tests to stop using them. |
My fork+branch is updated: https://github.com/filmaj/cordova-lib/tree/no-lazy-load Here's what it would look like in practice:
Note that the deprecation message will change based on which module's |
looking good! |
I've issued a pull request that addresses at least the 'no lazy loading' part of this proposal (among other things) here in apache/cordova-lib#562 |
No description provided.