We all have used camel case hash tags!! #MoreReadable
There are so many things that I do because I am a programmer, from using inspect element to see the saved passwords on Chrome (tend to forget my password often), to typing complete spellings while texting(nothing is more annoying than people who use abbreviation for every word), to keeping my house organized.
But these are not the only ways being programmer affects my habits and my way of living. Here are examples of three programming principles and how I use them in my personal life a lot.
Don’t Repeat Yourself or famously known as the DRY principle in programming world was mentioned first in The Pragmatic Programmer. It is defined as following
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
In essence, it means only implement a requirement, a concept, a piece of knowledge in one place, don’t duplicate it. Y2K crisis is the best example of why we should follow this principle.
As profound as it is in software development world, this principle can be extremely useful in real life. This for me means, do not repeat your mistakes. Learn from them and move on. And the better version can be ‘don’t repeat any mistakes – not yours and not others’.
Implementation of this is very obvious. You don’t have to be a programmer to know this. Don’t wash colors with whites because you have done it once and now all your whites are blue (true story), don’t answer mom’s call when you are drunk, don’t put your laptop on the front seat while driving… you get the deal.
Being a programmer only means that I tend to follow this principle more strictly. Duplication is sin in our world, so as repeating our mistakes.
TELL, DON’T ASK
This principle also comes from The Pragmatic Programmer. Tell, Don’t Ask states following
Procedural code gets information then makes decisions. Object-oriented code tells objects to do things.
This simply means tell objects to do what you want them to do, don’t ask about their states, make a decision and then tell to do something.
This principle not only simplifies interactions between objects but can also simplify your interaction with people to a great extent.
How many time have you gotten yourself into the awkward situation while making plans with your friends because you both couldn’t suggest what you should do? How many times have you ended up in an infinite loop of “you tell me where you want to go for dinner – no you tell me” while planning a date? This principle will save you from those situations.
It is simple to implement. When I am planning to hang out with someone, I usually give them a list of places, days and time slots that work for me and they can pick one from it. Telling people what works for you can be useful in many aspects of life – Gifts(Tell people what you want), Bargaining(Tell shopkeeper what is your best offer) and how about when mom asks what to cook for you.
Tell people what you want, don’t ask them to figure it out for you. Make your life and life of people around you easier.
So, next time while planning a date, instead of asking “Where you want to go?”, tell “I know this really good Italian restaurant”. It is much easier this way.
You Aint Gonna Need It or YAGNI is an Extreme Programming(XP) principle which states following
A programmer should not add functionality until deemed necessary.
Usually, we developers tend to think far in future and end up writing code for something that has not been asked for yet. And in our defense, requirements change a lot!! But most of the time that code is never used and mysteriously lies there making support team’s life miserable. YAGNI principle tells us to hold our horses. Don’t write it because chances are you will never need it.
This principle can be a big money saver if applied in personal life. Whenever I go for shopping, either it is grocery or clothing, I always ask myself “do I need this thing today or will need it in near future (near like in two days or at max a week)?”. Unless my answer is straight yes (no may be) with a clearly stated requirement for the particular item, I will not buy it.
If I do realize the need for that item in near future, I go to supper market again and get it. I mean it’s Walmart and Amazon Prime world, how much time can it take. And most of the time I never buy it because I never needed it in the first place. Follow this principle and you will never become a hoarder.
I have only mentioned three principles here but there are so many other OO principles that have quite a significant impact on many areas of my life. There will be more blogs in “Programming and Life” category talking about it.
So the point is, knowing OO principles not only makes you a better programmer but they can also make your life simpler if you commit to them.