I just want to paint a rough picture for the kid who is going to leave college, about the afterlife which awaits and while doing so — I am going to make some vague generalisations based on my experience, despite knowing that generalisation is a bad thing to do. But I also strongly believe that even the wrong generalisations help the thought process of a young mind and teaches it an important lesson sooner or later…

Image for post
Image for post

You might not want to continue reading if you are like me — who believed that my experience should be pure, good or bad didn’t matter to me, all I wanted was to have a real experience, feel life first hand as it comes and not be influenced by the perspective of a stranger or a close senior; I also stayed away from nice people whose intention was just to help — they were trying to give good advice, but I was one of those fools who liked to make his own mistakes. …


The last time I wrote about Fear of Mediocrity (back in 2013) I was naive and ignorant, just like current me will seem five years from now. I used to think a lot then, which I still do, but back then, my thoughts were dominated by my emotions; and it took me a few good years to strike a decent balance between the two pillars: Emotion and Reason. I’m still not there yet, but I think I’m getting there and the balance is sort of stabilising.

Image for post
Image for post

The major misconception I had was — I mixed up being in the middle with being a mediocre.


The usual Friday evening, I was swimming and enjoying the skill I developed last year. Simple doggy style makes me feel good, while the freestyle makes me pant in one length — I don’t know butterfly, breast stroke or any other advanced style, and so I stick to the elementary way; it takes away most of my unwanted thoughts, forces me to be in the present and allows me to charge up for the weekend.

Kids on my right are floating on their backs, I know I can’t do that, but I don’t feel bad, I know I will learn to do that someday, I’m not in any hurry. Laura, the instructor, is walking back and forth, giving them a nudge when they need it. Other swimmers on my left are doing butterfly, and I don’t see any familiar face. Beyond the pool, towards the right, I see the bald old man, sitting casually in the Jacuzzi — arms spread out and relaxed, making small talk with everyone near him. I don’t know his name, but we have spoken a few times. …


I am waiting for the bus 192 holding my closed grey umbrella; it has been a long time since I’ve waited for a bus.

It’s a lazy Sunday and I’m not in a hurry, but I do miss my cycle.

It’s cold, my hands are freezing and the roads are wet.

The bus arrives and I enter last. I hand over my plastic card and ask the driver for a weekly mega rider. I give him a twenty, the ticket receipt comes out, I collect it along with my card and leave after saying Thank You. …


A family of three is sitting diagonal to me.

Mom asks the kid,“You all right, love?”

Then mom shows dad the picture which their son took last night. The tone of her voice says she is proud of the picture her son had captured.

They are having full breakfast just like me.

I have stopped midway to write. The moment which compelled me to do so was…when mom started Monday with her index finger, looked at her son to imitate her…he did; he opened the tiny index finger while the rest of his little hand remained closed: Monday, then on the next finger: Tuesday and then with each finger he recited all the days till Saturday. Then mom asked what comes after Saturday, the boy paused and then said Sunshine…and everyone laughed. …


Note: Aimed to guide inexperienced programmers and provide common sense for experienced programmers. Code Snippets and Data Types will be in Scala, but the concepts would be applicable to other languages as well.

In Typesafety 101, we discussed the basics of typesafety using the Option[T] Type, which can either be something (Some[T](value: T)) or nothing (None). We used the get(key) function of Map data structure, which modeled the problem perfectly. `None` could only mean that the key doesn’t exist and we didn’t need any more information, for example a message describing its absence.

If more than one causes are possible, and we need to return the cause (say the message wrapped in an Exception), then in Scala we can use Try[T] which can be either be Success[+T](value: T) or Failure[+T](exception: Throwable) (Ignore the + for…


Note: I will try to keep the articles conceptual, language agnostic* and unbiased, but as Code Quality is subjective, there will not be any clean conclusions or clear recommendations. The goal is to help a beginner (or a less experienced type-safe programmer) to have a better understanding of Types and Typesafety

The concepts noted here would make sense only for statically typed languages (Scala, Haskell, Rust), which take help of a compiler to catch errors as early as possible (At compile time). I’d recommend knowing the basic difference between statically typed and dynamic typed before reading any further.

Also note that statically typed languages might seem like dynamic languages because of their type inference capabilities, but they aren’t. You should understand that being dynamic isn’t just about lack of type annotations, but more about type checking happening on run time instead of compile time.

*snippets will be in Scala but that the points I wish to convey can be applied to any language. I will provide a brief explanation of the langauge specifc types which should be sufficient to understand the concept.

Context

Before we dive into the grey area and nested types, let’s get on the same page to achieve a better understanding of the problem. I’m going to go slow so please be patient (side note: during the start, you will need a lot of patience while writing type-safe programs). …


Swagger is a fancy tool (combination of libraries), which generates beautiful documentation for your REST APIs. All you need to do is add some annotations to your code, okay, more than some, in fact, many at times if you want the documentation to be perfect and self-explanatory!

I prefer to use Swagger over Postman collections because once you invest some time into adding annotations, you don’t need to worry about the inconsistency between code and documentation because documentation is generated from the current code. More importantly, you don’t need another tool installed (as in the case of Postman or Terminal/Console to use curl Command Line Utility), all you need is a browser and to go to ServiceURL/docs/. …


Problem: What can you infer from looking at this function signature?

/**
* performs a get
*/

def get(): Future[WSResponse]

I would infer that it makes an asynchronous GET request to some URL, with or without some query params, and returns a result of type Future[WSResponse].

Assumptions which I make before writing the handler:

  1. It will always return a Future
  2. It won’t throw exceptions, because it’s a Scala library
  3. If it wants/needs to throw exceptions, it will instead return them via Future.failed(ex)
  4. It will be implemented in a way that matches one of the following patterns:
def get: Future[WSResponse] = Future { . . . }def get: Future[WSResponse] = if (cond) Future.sucessful() else


“So what I intend to do is describe my whole life as a way of presenting my thoughts and make it an independent autobiography standing on its own feet. I won’t go into the kind of detail I went into in the first two volumes. What I intend to do is to break the book into numerous sections, each dealing with some different phase of my life or some different person who affected me, and follow it as far as necessary — to the very present, if need be. I trust and hope that, in this way, you will get to know me really well, and, who knows, you may even get to like me. …

About

Saheb Motiani

A writer in progress | A programmer for a living | And a self-proclaimed philosopher

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store