Active-CSS / active-css

The epic event-driven browser language for UI with functionality in one-liner CSS. Over 100 incredible CSS commands for DOM manipulation, ajax, reactive variables, single-page application routing, and lots more. Could CSS be the JavaScript framework of the future?
https://activecss.org
Other
42 stars 7 forks source link

Convert core to employ a purer functional paradigm #157

Closed bob2517 closed 3 years ago

bob2517 commented 3 years ago

The core is currently composed of both procedural and pure functions. I want to move it over into a true functional paradigm, to reap the benefits that will bring.

Recently I've completed a course in functional programming, which I think was the easiest course I've ever done, as I instinctively already code in that direction and already employ the techniques sometimes (but now I know the terms and the exact rules, and have new tips I can use, hooray!) and I think I can make the core maybe, even significantly, smaller by splitting up the procedures into pure functions and removing side-effects.

Do this will also make it easier to employ unit tests - currently there are only integration tests. But that's a bit like putting quality control only on the cake and ignoring quality control on the ingredients.

I'm going to start putting in header comments too, lodash style. Not for me so much, but for anyone else reading the code.

I'll also do a re-org of the file structure to match this evolution, as the general function library is getting a bit large.

This will happen after 2.6.0. The pause functionality is too cool to delay a release for.

bob2517 commented 3 years ago

Closing this - I'm going to do the conversion gradually per release. It would be more of an issue if the core was hard to maintain, but it isn't even vaguely difficult to maintain so there isn't very much point going crazy about it. I don't see any memory leaks either. The concern I have is that in applying a paradigm wholesale we could lose evolution flexibility and actually make things harder to maintain, upgrade and harder to read. The areas to focus on are getting the documentation documented and making the helper functions pure. Then applying upgrades gradually, introducing currying, etc. gradually and during isolated refactoring actions which happen naturally as the core evolves. So this target isn't getting completed any time soon.