Posts

Showing posts from 2019

Leaky Abstractions: The initial sign of tightly coupled systems

Image
Imagine a scenario where you are creating an application for an operating system. while building this app you get an exception saying, “Unable to write memory address 0x08048faf”. That’s amazing, now what are you supposed to do? Find that address and check for the issue? It will be a daunting task to figure out what exactly went wrong. But what about the issue at hand, the problem that your app is supposed to solve. Because the operating system failed to abstract its implementation details, you must investigate the issue which is not your problem. Abstractions are amazing, they are here for hiding the irrelevant to focus on relevant. while building complex systems, developers heavily rely on abstraction. Each level of abstraction tries to hide the underlying level of complexity of the implementation, Letting the developers focus on the actual problem at hand. Memory management in the managed programming environment is a great example of properly implemented abstraction. Developer...

Writing High Quality Functions

Image
Ever wonder how to write clean functions/methods? While searching for the answer you might have come across some metrics, stating your function should not be more than 25 lines of codes or it should not have more than 5 arguments passed to it etc. When it comes to quality, unfortunately such metric are bad indicator to measure the quality of the function. It will just trigger a flag that there is an issue, but it will not tell what the issue is. When writing a high quality function, the first and primary rule is functions should be small, it should only do one thing. Sounds like Single Responsibility Principle? (SRP) yes it is, you can apply SRP not only to class, but to functions as well and this is the only measure you can use to check if the function you have written is of high quality.  FUNCTIONS SHOULD DO ONE THING. THEY SHOULD DO IT WELL. THEY SHOULD DO IT ONLY.                               ...