Coding and Life...

During the past several months I have been on a journey to learn web development, at Flatiron School’s wonderful online program. It mostly involves learning the syntax/semantics of computer languages like Ruby, Javascript etc. and applying them to solve problems/labs or create my own web applications.

The journey itself has been very satisfying and stimulating. I never knew that solving a tough coding lab and getting through a million errors (maybe less) could incite such joy in life.

Talking of life, learning programming I have come to realise how much it is related to life and everything around us.

Objects and Classes

class-objects

First and foremost learning coding and living life - are about the journeys and there is always so much more to learn in life and coding. The most joy is attained in the process of learning or doing things.

One of the key concepts of any modern programming language is Object oriented programming. Where you break down a problem into distinct classes or blueprints with common attributes and behaviours. For example when building a blogging application one might create a ‘Post’ class, which would have properties like a title, description. Once a post class or blueprint is defined one can easily create several instances of the post class or post objects using the class definition.

Well, what do you know when you look at objects in real life you see they can all be grouped into classes with common properties and behaviour. Example looking at the bookcase I see various books which all have certain common properties like a title and content. The title and content might be different but they are all books or all belong to the book class.

Even more important is when learning to solve coding problems using this technique of breaking down problems into smaller objects with commonality, one gets into the same mindset when faced with challenges in real life. Christmas shopping is broken down into different shopping lists with due dates ( ok maybe not a big challenge, but you get the idea).

Relationships

alt text

When building any web application one of the key factors of success is setting up the data model properly. Which involves defining the relationships among the different data models. For instance using activerecord in rails we define associations(relationships) among the data models like belongs_to: which is a one to one relationship between the models on which it is defined or has_many: which indicates a one to many relationship. And in life, I see the same, where relationships are one of the key to a happy life. Establishing that proper relationship with your friend, child etc early on, generally leads to better life.

Efficiency

alt text

Also in programming, we are always learning to be efficient with our solutions, as computer resources are limited be it memory, processing power etc. More often than not, there is a solution and then there is an efficient solution. Applying this principle to general life by being efficient with resources whether its time, money or anything really has helped.

Write the Code/Life you wish

alt text

Another technique that I learnt in my coding journey was that sometimes one can write the lines of code that you wish worked or had. Example I might write a line of code which calls for a method to execute in order to produce the desired results and go from there, but I do not have that method defined yet in the program. This really helps in making the solution elegant and code more readable as one is not caught up in the details of the solution and helps to move the ball along.

Clearly see that parallel in life, I remember many times being caught up reflecting on things in the past, which is a huge time sink. Instead using this technique I can clearly move the ball along in the direction that I want.

I Understand that most of the time coding resembles life, because we are trying to solve real life problems and hence modelling real world objects using code, but getting into that mindset while trying to solve a problem using code, is a good reminder of how I can use the same techniques in solving any problem in general.

Written on October 20, 2016