|
|
how natural selection adds features to organisms Wednesday, June 12 2019
The new project I'm working on in my day job involves adding some functionality to an existing (and complicated) web app. The frontend for that app was written in Angular (using a somewhat older version than the version I'd used in the Electron app I'd been working on all winter). You'd think I'd know Angular after all that time spent working with it, but in many respects I don't. Much of what I'd done in the Electron app was copy snippets of code found on SlackOverflow and then build out the functionality in what was essentially classic Javascript (that's where my competency shines; I can make it do anything). True, I did make use of Angular's templating system for rendering all the HTML, and I took advantage of the latest features to make all my calls to the Node.js backend. But through all of that, the Angular-specific syntax amounted to mysterious incantations that, if not entered perfectly, failed utterly. I mostly regarded it with equal parts befuddlement and disgust. Why did it have to be so hard? As for TypeScript, the language everything in Angular is supposed to be written in, I mostly ignored all the features it brought, writing in whatever form of Javascript the Typescript compiler would accept.
As I mentioned last week, my approach for adding the a feature to the unfamiliar app has been to clone an existing feature and the make modifications to the clone. (Interestingly, this is pretty much how natural selection adds features to organisms.) That's good in theory, but it's forcing me to actually understand some of Angular's many infuriating incantations.
Yesterday, even with the help of 90 mg of pseudoephedrine, this hadn't gone well. Part of the problem had been self-inflicted, because as my eyes swam in a sea of pointlessly complicated framework code, I was listening to the Dirty John podcast (it told the tale of a womanizing con-man drug addict who presented himself as an anæsthesiologist). I left work that day feeling like an an impostor. Yes, it still happens even after over 20 years of experience.
Today, things went much better, mostly because I forced myself to listen to more music and less informational content. It also made some great progress with my Angular knowledge by going through the Angular code in my Electron app and reworking a few of the many decidedly anti-Angular maneuvers. For example, my app contained a fair number of DOM (document-object model) manipulations that began by tracking down an element with document.getElementById, That's how things are done in old-school Javascript, and I'm completely comfortable doing things that way. Additionally, it just works, even in the context of an Angular app. But in the world of Angular, the DOM is abstracted away and one is supposed to manipulate it through an Angular-approved technique, which getElementById simply bypasses. I'm not a fan of the Angular-approved technique (it involves a property decorator called @ViewChild), which requires more code, is much less flexible, and harder to maintain (all of this is why I kind of hate Angular). But implementing it forced me to understand a bit more of the baroque Angular syntax. I was particularly happy to get EventEmitter to work, which is how a child component can fire a method in a parent, a goal that has mostly been elusive (so elusive, in fact, that I put nearly all the logic of the Electron app's frontend into a single sprawling three thousand line component).
This evening at home, I again took a laptop into the basement to test the solar controller's serial port. This time I used a TTL-level-serial-port-to-USB adapter, which I clipped directly to the main Atmege328 microcontroller's serial pins. This time, I was able to get mostly-coherent serial data at 19200 baud. It turned out that the Max323 RS-232 chip was the problem, and it had been the second one I'd tried. That was a first: replacing one bad part with another bad part. Next time the logical basis of the Universe seems to have broken down, I should consider the possibility that I have replaced a broken part with another broken part as part of my testing. Unfortunately, though, I couldn't get serial working on a Raspberry Pi Zero W, so I still cannot control the solar controller from anywhere on Planet Earth.
For linking purposes this article's URL is: http://asecular.com/blog.php?190612 feedback previous | next |