This week in front end architecture

In a react/redux application:

  • add a checkbox
    in jsx

  • capture its state by setting its vDom state with { [name]: !this.state.checked }
    in a switch statement

  • unit tests are jest snapshot diffs
    in typescript

  • className="bootstrap" or className={style.injection}
    incompatible

Making simple things hard in the front end again.

Advertisements

Two object definition refactorings from 2017

Original gist for this post

Earlier this year a colleague was tasked with modifying an application that defined a very large object (i.e., containing 20+ properties). The troubling part was that the object was entirely defined twice, first in an if-block, then in an else-block, all 20+ properties spelled out in each. That made the differences between the definitions difficult to detect just by scanning.

Continue reading

3rd-party code still needs tests

[ original gist 28 March 2013 ]

“If there are no tests, it does not work,” a former colleague said, who could have added, “whether your code or someone else’s.”

I’m not the first to say it but it needs re-stating: 3rd-party libraries are no guarantee that your code continues to behave as expected.

If one of the duties of your work is making sure you’re not introducing bloat or cruft or inefficiencies or bugs or unexpected behavior, then you’re cutting corners if you don’t have tests, whether you use 3rd-party code or not.

Continue reading