Code Reviewart 1

Starts with Comments

I think one of the most controversial and misunderstood aspects of writing code is effective code comments. It helps code review tremendously when good comments exist. The problem is how to write an effective comment. What you are trying to do and hopefully are going to do within the code snippet. this is wrapped up in the rhetoric of the comment. But comments are like song hooks. You have to be a coding genius to make a great comment.

Right off the bat, some will say it's a waste of time to make comments or at least massive comments. Okay, it looks like reason plays a part. Massive amount of comments are probably distractive and counter-productive. What I'm talking about is short clever comments that point you in the right direction and it starts when first writing code.

Most programs of any complexity have to be built up in stages. Posting "TODO comments" and pseudo code statements will go a long way in writing successful code in the shortest time. During the course of writing a program, refactoring or change in scope or approach come into play. The commenting needs to migrate gracefully as well.

The tricky part of commenting is how to make the comment effective. Making it short helps. Don't state the obvious. Point out what's salient about the code block, function, or class. Some variables are good to comment on where they are used since many will be used in several places. The guide would be: if it's obvious, don't comment. It there is a point that not obvious, make a comment. Even a reference to an external document made be important. At a later date, you or a reviewer may appreciate the aide.

The Next Waveart 2

Anybody know the a word for slender and elegant that might describe a coding approach? Many words could fit that description, but the word of the day is svelte. It sounds Germany, but actually originates in Italian. Apparently, the French worked on it a bit, and then it wound up in this English interpretation. Now it has been used to describe the next wave in web API development.

Svelte is a framework concept for writing code used by a client browser that takes a new approach. The shocking news is why hasn't this approach been tried a long time ago? I think it was born out the frustration of the framework wars of Angular, React, and Vue. React has taken the lead with the idea of the virtual DOM that you change the state on, then React replaces the actual DOM for the user to see. Great, but all the code used to generate this virtual DOM run each time state changes, which is slow and unnecessary. Vue has a nice structure, but is limited in scope. Angular is just a mess.

Svelte (pronounced S-velt) actually compiles the source code to include all the HTML, CSS and JS into a JavaScript build. All that happens has to be baked into the compiler. This is similar in concept to C being compiled into machine code. Nothing is going to be faster or more comprehensive, but in JavaScript.

This is a huge responsibility but can it be done? Apparently so. Go to https://svelte.dev to find out the details. Mind blown.