Lately i have been making mistakes during my job and lot of them are logical, silly and easily detectable. But what is that happening? I don’t have ADD/ADHD(Attention deficit/hyperactivity disorder). Contrast is, i didn’t had these mistakes earlier.So I started slacking off on competitive websites during weekends.

Benefits

Performance started to improve as if I specifically don’t need to think about silly mistakes. In order words brain muscles got weak since I left my brain gym and now it’s pumped up. And it’s also true that overworking is good habit. Being in practice of finding all the test-cases for a problem let us think more profoundly.

Another benefit observed from this fallback is about procrastination. Now I procrastinate lot less, it’s because during competitive programming contest you just can’t stand because you aren’t in mood. It’s simple GET YOUR SHIT DONE attitude. Another benefit is to think fast through the problem. Thinking process becomes lag free, better concentration and got more work done is less time.

Brain gyms

There are lot of platforms like Topcoder, ICPC, Codeforce, HackerRank etc. But I personally prefer “HackerRank”(not sponsored). HackerRank got a good list of well curated problem. Problem language is mature and doesn’t look like total sci-fi. Site generates good amount of discussion on problem and is active for most part of the month and year. They have problem from different domains and not just algorithms and time complexity. It’s over all comp-sci problem which helps in over all development.

“So keep calm and code-on”.

Cheers

Good-bye i,j,k … variables. Good-bye soul-less variable names. There are lot of code conventions on the web but all their focus is formatting of the program which helps avoiding bugs. There is another aspect of code convention, that is having pragmatic variable names in your program/code.

My focus is to avoid bugs in code through a sane approach of naming variables. Variable can be the common confusion point of your program, especially if you want it to be read by your colleagues and maintainers. One’s program must be like a story and variables must be the characters of the story. One definitely doesn’t want characters to have non-sense names, right? Every program must a unique story and avoid plagiarism whenever needed.

BLAME GAME

Competitive programming gave us a habit of short & funny variable names. Everyone cared about time complexity. That’s not all I never got evaluated for beauty of my program at my academia too. Code must run and produce desired effect, isn’t that the deal?

TRUTH

Blame game is shame, period.

More reasons, pragmatic variables makes code maintainable and doesn’t let bleed my(or others) eyes. Though it may take some time to arrive at thumb rule but it’s worth the pain. Your co-workers will really appreciate these variables, also they enhance your vocabulary(pun intended).

Thumb Rules

  • Function - [Adverb] + Verb
  • variable - [Adjective] + Noun
  • Global variables - ALL CAPS NOUN
  • Avoid borrowed/duplicate variables

So next time you go for generic names like (var_a, var_b, bad_var, i, j,…) for variables, do yourself a favor, pinch yourself or take cold showers.

Always follow good practices.

Writing code can be scary especially in a collaborative environment and when you have to avoid techical debts.

But first what is technical debt?

Have a look at gif below and imagine you are coding instead of driving

In simple words : code you wrote isn’t maintable, hard to understand and does not follow code conventions of others.

So the first rule for writing code is understanding who is going to maintain it, who is going to add further code to it. And even that doesn’t matter, writing good code should be a habit and shouldn’t be broken at any cost.

Solution to bad code

  • Follow code conventions.
  • For eg. while writing python follow pep8 conventions and while writing js code follow jslint conventions

  • How granular or modular code should be?
  • For eg. There should be separate function for separate task. It may depend on number lines of code for that function.

  • How often comments should appear and on what severity?

THE TRUTH

One can’t write perfect code in one go. Refactoring, pruning is the key. May be you need to burn all your sphagetti code and it would definitely pay off.

More concrete steps

  • Bad habits doesn’t go easily. So there is pair programming for that. Pair programming reduces effort on new learning and makes new learning easy and fast. Key to good coding is good discussion. Look at the code written already and discuss about it and rewrite if needed.

  • DESIGN : Technical debts can also be attributed to wrong code designs. Design is not just about visual art, it is also the architecture of code. Fitting code is no joke.
    • Agility comes from good code design.
  • REFACTOR : Refactoring code brings new features to the application in current development, so refactor more and often.

Technical debt is like karma, gonna kick you soon or later.

That’s enough of water-cooler side talk. Keep avoiding technical debts.

Notes

Thanks Shyam Sundar for reading the draft.

Have you wondered what it is one thing that separate human from rest of the diversity ?

It is the ability to communicate and preserve that communication, spread that communication. Infact the nature follows the law, if you know something you can’t keep it to yourself, you have to apply it and spread it. That’s why universe is expanding and time flies by. Nothing is still and is at rest, so must be your thoughts.

There are no stupid thoughts and ideas !

Though i could have given example of Gallileo and Leonardo da vinci. But it is the shear imagination of humans that have given birth to miracles and technology. One must live for creativity and its implementation. So what if you failed n times, n+1 time you will succeed provided you don’t repeat the mistakes.

Write like it’s worth, think like it will be implemented.

The mere fact that idea will communicated makes it serious thought. One care and try to polish that idea. Ideas need not to be unique, but progressive

Imagine a scenario where you would prefer to type instead of clicking. That day would be epic. As a developer, it’s our job to use and spend time on command interface it can be shell, bash, or it can be a editor like vim, emacs etc. Lot of optimization has been made since the beginning of these things. Today i will specifically talking about shell/bash prompt.

We generally use 20% of the features available there, to attain maximum efficiency in long term it learning rest 80% will help tremendously. So let’s get down to business.

I. Using search in prompt

One can search through the commands one has previously typed. Just use

 Ctrl + R

, this would enable backward search such that one can search through logged commands.

II. Using alias for long commands or shortcuts

For this one needs to use .bashrc or .zshrc(more about this later) file in the

   ~/

directory which is

 /home/username

. There you have to add a alias <alias_name>=<your long command> for eg. for using p for python use

 'alias p='python'

now you can just use p python_script.py to run the python script, or you can add your ssh command to server ip,which are pretty long. Isn’t that handy!

III. Configuring rsa key for auto pushing to github/git network.

You might be typing username and password every time you want to push to github. There is an easy way to do this automatic. One need to paste the key from ~/.ssh/ directory, keep in mind the key ends in .rsa . If you have one already generated and configured with ssh-agent then paste the key in github profile settings under SSH realted area.

If you haven’t done it yet, do it by using key-gen utility

 key-gen -t rsa -C "your_email_id"

-t is for defining the type of key which rsa in this case -C is to providing commenting so that you can identify different keys for what we are using email id. then add generated keys to ssh-agent using

 eval "$(ssh-agent -s)"
ssh-add ~/.ssh/<key_id.rsa> '''

And then follow the procedure to add it on github profile Additonal link: github-ssh

IV. Using zsh instead of bash

zsh is an shell designed for interactive use, most of its features are from bash, so one can easily use as bash replacement.

  • One of most fruitful feature is one don’t need to type cd for changing the directory. Just type directory and enter & you are in directory.

  • Other feature is intelligent autocorrection, supposedly you made some type in case, zsh would auto correct it. For modifying the configuration use file at ~/.zshrc like adding alias or export or path. Additional link:zsh-link

V. Using oh-my-zsh framework for zsh

oh-my-zsh is most popular command line utility framework on github. It has premade zsh configuration which you would have to write otherwise in bashrc/zshrc files. you can use lot of themes from lot of community themes.

A screenshot of my terminal using oh-my-zsh is given below oh-my-zsh-screenshot Some useful mentions

  • I can see full path of my working directory

  • I can see git repository branch, i am working upon

  • I can see time stamp for each command

  • also if my git repos has been modified and there are uncommitment changes, i see all that on one terminal.

Isn’t that wonderful! Additional link:oh-my-zsh

VI. Mutliple tabs instead of mulitple windows

Lot of people bring a new command window for different task. Using tabs is recommended since you can switch easily and also see what is running on different tab.

Just use Alt + T for new tab and Alt + <tab_number for eg.1,2 > for switching the tab.

That’s all for now. For more detailed information follow the links provided in the post

Next time it will be productive while being python developer.