Wednesday, May 14, 2014

High-falutin code #3 Deliberately leaking the abstraction

Even in modern times, there still are developers who would deliberately leak the abstraction even when there's no compelling reason to do so

<div id='blah'>Meh</div>

.
.
.

var e = document.getElementById('blah');
e.style.color='red';
e.innerHTML = "bleh";


Most who would do that would use efficiency as an excuse. Those showboating attitude are akin to what snotty attitude C developers exhibit towards C++ when C++ first came out, saying C++ is inefficient as under-the-hood C++ always pushes an extra parameter (class instance reference) to a function; likewise when C language first came out, assembly language developers see the C language inefficient in generating machine code as compared to their handcrafted assembly language code. We should let the API do the heavy lifting and not leak the abstraction when there's no reason to do so


It's lamentable there are still some developers who would handcraft their DOM manipulation using pure javascript, i.e., sans the framework, and proudly saying they don't know scant (or doesn't want to know) about jQuery, AngularJS, react and whatnot, that's a thinly veiled humblebragging, to them just because old school === hardcore. If someone got to maintain a code mess from developers bringing-their-20th-century-skills-to-the-21st-century who wrote javascript code sans a framework, you can't blame the new developer who knows where they live


Worser yet, those abstraction leakers put down new technology and blatantly claim that old approaches are more efficient and new technology are inferior

No comments:

Post a Comment