A no-code version , from a Tesla fan, to address the dilemma of abstraction vs. encapsulation in an object oriented software design.
Why is object-oriented programming so preferred? Besides being widely accepted and highly demanded for decades, its preferred because it just makes sense to a human brain! It makes sense because it is closer to real life.
Abstraction and Encapsulation are the main tools at the disposal of anyone using OOP to their advantage. Being very similar, both of them are so close in concept yet so apart in intent that confusion is prevalent. The problem only arises when we know how to use them but do not know when & why to use them. …
Building on the previous post about abstraction and encapsulation, this time I am going to write about Iterators & Generators which is where we see abstraction & encapsulation in action, within the Python realms itself.
To start talking about Iterators, we need to know what an Iterable is because that is what an iterator works upon.
Literally, iter-able means anything you can iterate or loop over. Anything that you can use taking out one item at a time. In Python, an iterable is a collection of values that are capable of returning one element at a time. All the sequential as well as non-sequential data structures belonging to the class of collections are iterable. …
This is part II of three parts post about some basic questions that I learnt about by failing the interviews.
In case you find this interesting, please have a look at the first part here.
For a relief, I believe if someone gets this question, that means you are already at level 2.
Decorator, as the name gives it away, is ‘something’ that wraps over the original ‘something’ to make it even better. But of course, this leads you to another question. How do we do it and Why do we need it?
The explanation of this requires a ground understanding of the following facts about Python. …
They say ‘God is in the details’. I clearly was missing this point while preparing for my initial tech interviews. While I spent most of the time in perfecting my data structures and algorithms knowledge, I relied on my practice-on-job to take care of the language related questions in the interviews. Result; I did terrible on three interviews because of a few basic concepts. Retrospection made me realize that I have been doing it all along without knowing the tiniest details of it and hence failed to answer them correctly when asked.
This post is the first part of a two parts write up to explain simply, some very basic concepts of Python. …