It’s a cool UX trick I learned recently makes applications exponentially responsive. Traditionally, when we make an async API call or something similar (to perform a time-taking operation) we show a spinner (or a loading message) to indicate to the user that something is going on in the background and that they should wait a bit before the final results. Although now widely accepted, this approach sometimes creates ‘blocking’ experiences especially when used extensively. You do not want to give an impression to your users that your application is completely dumb on its own and needs to fetch data from the all-knowing server all the time.
Optimistic updates is a strategy where you ‘optimistically’ assume that your time-taking operations will always succeed. So, instead of making users wait or showing a loader, you show the final results (when you can) right away!
Eg. On click of an item’s delete button just instantly remove the item from UI and perform the actual (server-side) delete operation in the background. The same goes for adding a new item, and so on. This will create a slick and snappy user experience that your users will love. If a background operation does fail, perhaps undo the change in UI and show a relevant error message to the user.
Of course, this strategy isn’t perfect. But it’s cool, for sure. I must have seen it at least half a dozen times before but officially learned it in this beautiful Redux course on Pluralsight by the awesome Cory House.
Check my commit to see how optimistic deletion can be implemented in a React-Redux application.
This website uses a theme called Storefront. It’s a minimalistic yet elegant theme from Automattic (the creators of WordPress). I literally browsed hundreds of modern and ‘top’ themes at various sources before falling for this one. It was a good fit in its vanilla form and required only little customizations to suit my needs.
Yesterday I logged into my WP admin after a few days and saw several updates piled up. Storefront was one of them. I didn’t upgrade right away for I knew my customizations would be go away with its previous version. I had committed the cardinal sin of modifying the theme directly.
When I found out about the concept of child themes, I said to myself, “shit, I should have guessed already.” A child theme is one that contains files and assets you want changed in a ‘parent’ theme. So, rather than directly editing style.css or functions.php in a parent theme, one can create a child theme and add their modifications there. That’s what I did then. I created a child theme called Storefront AB, derived from the beautiful Storefront theme.
That was fun. It’s live now!
WordPress is a beautiful, sophisticated software, built to scale to millions of websites globally. A lack of something like the concept of child theme didn’t just feel right. I should have trusted my instincts earlier.
One of my latest obsessions is GraphQL. While reading a tutorial, I found out that GraphQL follows declarative programming paradigm. The video tutorial gave examples to differentiate imperative paradigm that REST technologies use from declarative paradigm that GraphQL uses to make our lives easy. It was not the first time I’d come across these two terms, just that in all previous instances I didn’t care enough to investigate them in detail. When I, however, did dig deeper I was pleasantly surprised.
This stackoverflow thread does a good job in explaining the contrast. So, what some people see as convenience features of C# (when comparing with Java) is actually its declarative style of programming. As a developer obsessed with convention over configuration, it was not hard to fall for this style.
It’s getting serious everyday. It’s not just the internet, a lot of people around me are talking about it. So, it did not come as a surprise when I found that a popular Indian app was built in Flutter. Dream11 is what people are talking about this IPL season. Given the massive fan following of IPL and the craze for safe online betting, one thing is sure — Flutter can damn well handle scalability. I do not use the app myself, but it sure looks pretty on friends’ phones.
I am getting more and more impatient now to build my next mobile app in Flutter. Until that happens and I have stories to tell about my time with Flutter, watch Dream11’s Flutter story:
I’ve been busy watching videos. A lot of them, as part of my learning process for quantum computing. To concretize my learning, I’ve been taking notes. As quantum computing is hardcore math, it’s impossible to not have some sort of equations in notes. I’ve never needed to learn or use LaTeX before: all simple algebraic equations can be written in plain text using some jugaad, say using superscripts for exponentials. But how do you represent column vectors and matrices? That’s where LaTeX comes super-handy. As I’m using it more, the more fun it gets.
Auto-LaTeX Equations is an excellent add-on for Google Docs that makes it super-easy to write LaTeX code and convert it into good-quality images of math stuff and equations.
An example LaTeX render from my notes is this matrix that represents the phase shift quantum gate: