Clean Code

Posted on Leave a comment

There’s a bunch of technical books sitting in my Amazon wishlist for quite some time. Poor books! They could not end up in my shopping cart for a myriad of reasons, laziness to read being chief amongst them.

The importance of reading technical books simply cannot be overstated. Or reading articles, for that matter. Reading is what helps you to improve your craft, keeps you up to speed with the topics you care about, makes you a better version of yourself in your desired skill. Personally, I’ve found books to be more useful than online courses. I have nothing against online learning, I’m all for it. I have end-to-end finished a tonne of courses on Udemy, Pluralsight, Coursera, etc. The things that go for me with books are that I can take them anywhere (even where there’s no Internet), highlight important parts, scribble my own thoughts and most importantly learn without distractions. The thing about books being little portable time machines is true.

Recently when I was casually digging my Twitter timeline, I came across this book called “Clean Code”. Someone had written life-changing praises about it. Out of nowhere, I decided to order. Out I went to, found the book, read a few reviews, noticed that there was no discount, and hit the Buy Now button.

Clean Code is a book about software craftsmanship. It’s a must-read for anyone who cares about their craft.

I am a little more than halfway through the book, and boy, it is life-changing. It’s written in an authoritative tone by a bunch of regarded software engineers with decades of development experience. The experience clearly shows! Chief among the authors of the book is Robert C. Martin, who is one of the founders and foremost popularizers of SOLID principles and Agile methodology. I have thoroughly enjoyed the book so far, and am looking forward to finishing it. It’s safe to say that this book has reignited my craving for technical books. Next up I’ll probably pick up a Martin Fowler.

Using the learned clean code principles, I was able to transform this ugly chunk of code at work in a beautiful verse below it. The code is customization on top of Sitecore‘s JSS Node Proxy open source program.

Which code snippet is easier to read?

Object.keys(tenants).forEach((key) => {
  const tenantName = tenants[key];
  const proxyConfig = config.initConfig(tenantName);
    (req, res) => {
        paymentData: req.body,
        path: req.params.paymentRoute,
        lang: req.params.lang || DEFAULT_LANG,
      }).then((svcData) => {
          (param, html) => {
          { userAgent: req.headers['user-agent'] }

    `/:lang((${routesLangs}))/${tenantName}([/].*)?`, // eg. /((en|ar))/yasisland/wishlist
    (req, res, next) => {
      if (req.originalUrl.indexOf('/-/media') === -1) {
        let originalUrl = req.originalUrl.replace(tenantName, '');
        originalUrl = originalUrl.replace('//', '/');
        req.originalUrl = originalUrl;
  (req, res, next) => {
    setPaymentRoutePreReqs(req, res, next);
  (req, res, next) => {
    const envType = getEnvironmentType(req);
    const tenantName = getTenantName(envType, req);

    const paymentRoute = req.paymentRoute;
    if (paymentRoute) {
      handlePaymentRoute(req, res, tenantName, paymentRoute);
    } else {
      handleApplicationRoute(req, res, next, envType, tenantName);

The joy of creating in Flutter

Posted on 1 Comment

I am now officially in love with Flutter. What started as a crush has turned into something palpable. For the past 2 weeks, I have been heavily invested in learning Flutter from App Brewery’s bootcamp-style course. If there’s one takeaway from the course, it is this: Flutter+Dart is a lethal combination. I have now come to truly appreciate the ‘promised’ language for frontend and the frontend itself.

I must confess, though. I did not hold the same feelings for Flutter in the beginning. At a couple of meetups, I have called Flutter all sorts of blasphemous things — difficult to learn, highly inconsistent, and a confused approach — all without closely working with it. I, however, assure you that Flutter is none of the above. On the contrary:

  • its composition-over-inheritance approach makes it easy for beginners,
  • its Widget-oriented design makes it consistent, and
  • Dart’s succinct and familiar (JavaScript-like) syntax makes things less confusing

The App Brewery course I mentioned before has been an eye-opener. The course itself is pretty long and exhaustive, but rewarding. Since it’s geared toward absolute beginner programmers, I was able to go through it at 1.5x playback speed and even skipped a few sections. I am currently at 64%, hoping to complete it by the next weekend.

During this time, I customized my VS Code quite a bit to my liking (this post’s featured image), so much so that creating Flutter apps in Code is a far more pleasant experience as compared to officially recommended Android Studio. This, of course, is made possible by the awesome Flutter team who does not want to tie developers to Google’s ecosystem.

If you are curious about the source code of the app seen in this post’s featured image, here’s the GitHub link. It’s an app called BMI Calculator that I created as part of the course. Go ahead and explore my commit history to see how easy Flutter makes creating beautiful-looking mobile apps.

Some C++ programs

Posted on 51 Comments

As requested by Sajith Karingat (comment #29), I worked on a Phone Billing System in C++, as per his requirements. You can download it here.

I have entered my final year in my B.Tech course, and with it, it’s placement time. Companies for the computer science stream (my stream) will start visiting my college beginning from 11th August. The first to come will be TCS (Tata Consultancy Services) which is considered as a good IT firm in India with global fame.

As part of my prep for the placements, obviously, I am revising my concepts (technical ones). Today, as it was raining heavily in the college, we sat in our central canteen, waiting for the rain to stop. During that time, we held a heated discussion on C++ programs that were most likely to be asked in interviews for placements.

Amongst those programs, one was to swap the values of two variables “a” and “b” without using the “temp” variable. Another interested one we discussed was that would generate a pattern like:

2 3
4 5 6
7 8 9 10
11 12 13 14
…… and so on.

When I got back home, I decided to have a go on these programs. And so, here are my answers to above problems.

Continue reading Some C++ programs