Saturday, May 12, 2018

Release 0.2.6: gpf.require.js


This release fixes sporadic Travis issues, improves the modularization helper and finalizes the flavor mechanism to deliver the first reduced version of the library (gpf.require.js).

New version

Here comes the new version:

Release content

Sporadic Travis issues

From time to time, the Travis continuous integration build was failing with a message indicating that the coverage information was missing for the browser. Here is a recent example.

I was first suspecting the concurrent execution of quality checks to be the root cause of the issue. I disabled it but, still, the problem persisted.

So, I took a closer look on how the coverage information was generated while executing tests in the browser.

In the Travis environment, chrome is spawned as a command line with options to disable user interface. When the tests are completed, an AJAX request is triggered to save the tests results through the cache middleware. In the meantime a command line, responsible of spawning the browser, waits for the cache to be updated before closing the process.

Also, the test page is responsible of saving the coverage information through another AJAX request that goes to fs middleware.

I realized that the sequence was incorrect: the tests results were sent before the coverage information. The two steps are now executed in the correct order.

Improved gpf.require namespace

The modularization helper was improved following the feedback obtained after the first use:

gpf.require.js

Flavor specification

In the previous version, the dependency wheel was added to the source tile to give a visual representation of the dependencies. Also, each source file has been documented with 'tags' qualifying the feature or the host the source relates to.

Sources without any flavor selection
Sources without any flavor selection

Also, in the previous version, a syntax was initiated to instruct, in a readable way, which sources should be kept for a given flavor. Combining the features list, hosts specification and dependencies, an algorithm - not my proudest one - is capable of generating an array of booleans filtering the list of sources.

Example of flavor syntax
Example of flavor syntax

As a result, the list of sources is reduced to meet the flavor specification.

Sources with a flavor selection
Sources with a flavor selection

Everything was ready to setup the require flavor specification, it contains:

  • The version in which the flavor was introduced: it is required to build the versions table in the readme page
  • The flavor filter string
  • The tests required to validate the flavor
  • A functional description of the flavor: it will be used to document flavors (not yet implemented)
  • A technical description of the exposed API: the goal is to narrow down the list of namespaces / methods that are exposed by the flavor (not yet implemented)

Reducing flavor size

The very first results were quite disappointing:

  • The same way, Browser implementation of require depends on gpf.http to load the resource content. This namespace offers a mocking helper that is not needed for require. The code had to be drastically changed to successfully unplug this source.

Testing the flavor

There is no way the flavor could be officially released without making sure it works as expected. Luckily, the whole library is already 100% tested. Since the flavor description lists the test files to run, the development framework was altered to support a flavor parameter that:

Mostly, the following files were modified:

Obviously, the grunt make task that schedules all the tasks required to build the version was also modified.

Lessons learned

Creating this first flavor was quite an interesting challenge and it took longer than expected. It forced me to rethink the way the code is articulated, especially with regards to host specific implementations.

The original pattern consisted in dictionaries containing operations indexed by host name. However, this had a major drawback: every time it was accessed, it was uselessly impacting the performances and producing complex code.

Now, when appropriate, a new helper is introduced to define the proper implementation depending on the host.

Here is the gpf.http use case:

Regarding gpf.http.mock, I decided to plug it in the gpf.http implementation only when loaded, improving its modularity.

All this work paid, the maintainability ratio increased to 82.22.

One last thing, the require flavor supports only 'modern' browsers meaning the ones where the compatibility layer is not required. However, as of now, the development framework does not distinguish the configured browsers.

A configuration will be defined.

Next release

The next release content is not yet clearly defined. Since I will participate to UICon'18 as a presenter, I will first focus on delivering a good presentation.

I expect to work again on the library after June.