Object Oriented Design – Lines Per Day https://www.linesperday.com Lines Per Day Mon, 04 Dec 2017 12:59:04 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 Object Oriented Programming Concepts for Professionals https://www.linesperday.com/object-oriented-programming-concepts-for-professionals/ https://www.linesperday.com/object-oriented-programming-concepts-for-professionals/#comments Fri, 01 Dec 2017 09:43:08 +0000 http://www.linesperday.com/?p=353 Article Outline:

We often start our journey in programming by writing basic flow elements like variable initializations, conditional statements, loops and etc.

Then we move on and learn concepts of functions, passing arguments, global and local variables and so on.

Easy stuff for beginners.

Now if you are using good old ‘C’ language then you will move on to pointers and memory management.

With C programming knowledge you can conquer the world. You can work in embedded systems. You can write a new operating system or invent new programming languages.

But this will take time and you will have to be fluent in pointers and memory management.

For everyone else who is not serious about learning C then you have to be fluent in object-oriented programming.

Because if you are using Java, C#, python then object-oriented is a must. If you are using JavaScript or PHP then object-oriented programming can help you a lot.

And for those who are thinking of changing their careers get into the programming world then you will face object-oriented questions in interviews.

If you are a student then you will face interview questions about object-oriented programming.

Even if you only know about HTML and CSS3 and wanted to work as a front-end designer.

As you can see it is necessary to know about object-oriented programming for everyone(I am a bit conservated here let’s say 90% of developers).

I have seen hiring manager asking questions about object-oriented programming for an interview of the database manager.

So, object-oriented programming concepts are universal!

Who is This Article for? Students, Amateurs or Professionals?

Everyone! I mean everyone who studies computer science or programming studies object-oriented programming. TRUE!

But do we fully grasp the concepts of OOP? Think about it.

Well if you think that you succeeded in interviews where they asked questions related to OOP and now you believe are good in object-oriented programming. Don’t even think about it.

I aced all the question on object-oriented programming and answer all questions in all interviews. When I completed undergrad studies I had 5 appointment letters in my pocket from elite organizations.

The code that I have written at the start of my career and which I thought was a good quality code. Now when I see it today I feel vomit in my stomach and I hide it immediately before anyone can see it-yet I still see the developers making same mistakes that I have made over and over again.

Look getting work done is not enough. You can even exploit the object-oriented programming languages like C# and Java and use them as a procedural language. Getting work done without thinking about the quality of code will not make you a professional software developer.

Yes, I was getting work done but that was NOT according to the principles of object-oriented programming. So if you have good grades in courses related to object-oriented programming or if you have given all answers in an interview then you are still a long away from being a good object-oriented programmer.

Hence this article is for those who are currently writing software for money. Who have completed their studies and have at least 2 years of professional programming experience.

Why 2 years? Well at the start of your first job you are worried about proving yourself and learning the environment. Finding your tables and computer, knowing about the boss, learning the frameworks and tools that you never heard of in your studies.

Once you get it done(which takes around 2- 3 years) now you are looking ahead. Now you are ready to take those steps which will affect your programming career.

A quick test to know if you are good at professional object-oriented programming

Think of any famous framework in any programming language(javascript, Java, C#, PHP, Python). Think about all the constituent in that framework.

If that framework is no brainer to you. If you know why ‘clojure’ is used or why a particular set of classes are used or you know why you have to use so many classes to accomplish a simple task. Then consider yourself good at object-oriented programming.

A word of caution here. Above I am asking about the ‘why’ question, not the ‘how’ question. If you just know how to create a file by using the ‘Stream’ classes. Or just know how to call jQuery methods then you are a consumer of good object-oriented design. You are not the producer yet.

Do you want to be that vast majority of developers who write only glue code and most often tied to a framework for years? When they change their job then they realize that nobody in the universe is using that framework anymore and they have to start all again. I call them the consumers.

To be a producer you have to be on the other side of the wall where there are developers who not only understand why there is more than one class to accomplish a simple task but they are the ones who create libraries and frameworks that are consumed by millions of developers each day.

Are you ready to be the part of that small group of elite developers?

Yes, it is true that at the start your framework or library is not going to hit the life of millions of developers but if you start today it will improve the life of one developer. That one developer is you.

This will help you in two ways.

First of all, it will help your team understand and modify the code. And after 6 months It will also help you when you come back to change/update your code.

Second, it will help you to move up in the career ladder fast. You will become senior developer quickly and ultimately a great architect and system architect(provided that you choose to remain in technology instead of management).

Another benefit is you will not lose whatever you learn. If you learn a particular framework and work on that framework for two, three or even five years you know that the framework will be replaced by a more efficient framework.

Or your next organization is using a different framework than your previous work will not count as much. But if you know object-oriented concepts and have applied them firmly in your work then you have that experience for the lifetime. You can always get leverage out of that object-oriented experience.

Now you know why OOP is important. Let’s start our journey by understanding the context of OOP in the programming world.

Where OOP stands in The Great Scheme of THINGS?

This topic is to remove major confusions. People in development still have confusion about processes, architecture, databases and a lot of other things like frameworks and build process and etc.

All of a sudden one comes to you and ask where is this ‘OOP’ fits in the larger context of software development? Is it a process? Is it an architecture or something else?

For example, if someone asks you: Is OOP good for extreme programming OR SCRUM or let’s say an embedded system? Or ask you this question “does n-tier architecture supports object-oriented programming?”

Well, I am feeling stupid right now by asking these question but there are people who ask these type of questions and they are still confused. Don’t trust me! You can ask any new developer you know the questions stated above and you will find them confused.

Now, what will you say when someone asks you this basic question:“What is object-oriented programming?”

Well if someone asks me then I will say that object-oriented programming is a development methodology. That was easy:) You probably know that.

Development Methodology

So why there is so much confusion out there. Let’s consider a developer named Jack. Jack is a new developer who has studied computer science or a related discipline from a college/university or online institution.

Jack know about object-oriented programming because he studied the course with the exact name:“object-oriented programming”. Jack believe this is the only way people write code. Jack doesn’t know much about assembly language or C programming language.

Jack started his career with JAVA or C# as a programming language. The mishaps that happen with Jack is that he was born into the programming world when everybody is talking about object-oriented programming and it is the only paradigm he sees everywhere.

Jack has no interest in history so he doesn’t know if there are other paradigms for development methodologies. Prior to Jack, there were other development methodologies that were so awesome.

Let’s take the paradigm of procedural programming. COBOL, Fortran, and Pascal were the default choices for any developer and before that assembly language programming was a must for every computer scientist.

Also, Jack doesn’t bother to look around. Jack doesn’t know there other fields where other types of development methodologies suits. For example, LISP a functional programming language and is used in artificial intelligence systems. Although it is not limited to that only and there are other applications where LISP can be used.

Even today the procedural programming language ‘C’ is most suitable for embedded development.

So, let’s say goodbye to Jack for now. I believe that now Jack knows that object-oriented programming is one of many development methodologies. It has nothing to do with development processes or architectural style.

Also, one can use any development methodologies with any development process. Similar is the case with architectural style. One can use any development methodology with any architectural style.

But, there are some methodologies that can best work with some development processes and architectural style. But no one is going to stop you if you try to break the established guidelines. After all, creativity is what a developer should be looking for.

Now, for the sake of completeness let us discuss the development processes, but this time for professionals only. Also, remember that the right process with the right methodology will lead to a good quality software code. Here is an example of how to use both together.

Development Process: Why There is no bad Process

If you have studied software development process as course then I can bet that you hate waterfall model.

Waterfall model has become a kind of punching bag. Everybody who sings for agile methodologies, first show his hate for the waterfall. It goes something like that:

“Look at that waterfall model- it’s all waste. You develop a system without customer feedback and now it is of no use- all the useless documentation and code is going to the bin ” or something along these lines.

I have been like that until one day I realize that there is no software process in the organizations where I worked. I researched and I found out that there are very few organizations that adopt any development processes in its true sense.

For the rest us there is only one process and that is what I called the brute force software development process. Your boss gives you a task or even a complete project and you have to complete the task and report to the boss.

Someone higher in the chain run the build process and someone from QA test the software.

Or there is an amalgamation of good practices from different software development processes. Sometimes there is automated testing in the place. Sometimes there is pair programming borrowed from XP, sometimes there is short release cycle and continuous build borrowed from SCRUM.

What processed you or your organization follow depend upon you and your team. So don’t get offended if someone tells you that we use this sophisticated process model and you don’t. Even the waterfall model is good enough for me if you just remove the documentation because I hate documentation.

Even I have devised my own process model. You may like it (or hate it).

Now let’s move to our core topic and that is the strategy that I will use to describe object-oriented programming.

Inside-Out Strategy: This Will Make it Easy for you to Apply These Concepts

I will start with the internals of the core entity in object-oriented paradigm and that is the ‘Class’ and it’s representation in memory and that is the ‘Object’.

In the ‘inside’ strategy I will discuss only the internal of object and classes. Nothing more. If you do the basics right then everything else will be fine.

I will only discuss internals that is necessary to know for any professional developer. There are chances that you have learned these out of your own curiosity but I will share my experiences.

Once you mastered the internals of the class and objects then we will move to the ‘out’ strategy. This is where one object or class work in conjunction with other object and class.

‘Out strategy’ is a very important part. Because in order to achieve something bigger every object in your software code needs to communicate with each other.

There are a lot of principles and design patterns to achieve this inter-object communication but I will tell you the most important principle that you need to know at this stage.

After that, I will discuss that it is not only how your objects collaborate with one another but how you collaborate with others specifically your teammates and your boss.

This is an important point and many people ignore this but for professional developers who are working in a professional environment and not in a classroom will face these challenges.

Hence the inside strategy comprise of:

Class, fields, functions, constructors and static fields. I will explain an important concept of how objects are represented in memory. I will also discuss how to create the class that looks like created by a professional.

The out strategy consists of two concepts. The first concept is about how your classes interact with each other and the ideas that are essential for professionals. Second and the most important concept in ‘out’ strategy is how you communicate with every other human around you.

This means how to communicate your design ideas with your teammates. How to take your teammates onboard with your ideas and most importantly how to convey your ideas to your boss.

The last part is important because when you talk about improving the quality of your work or introduced methods that will improve the efficiency not in the short term but in the long term then everybody– I mean everybody– will resist it.

Nobody wants a quality code initially. They need the job gets done. In their heads, they think job to get done equals to quality code. This looks good initially but in the long term that code will grow and become rotten and then everybody in your team will feel the smell of that rotten code.

There are tools to deal with that situation but for now–let’s assume that you want to know how to start software development with the right mindset.

Inside the ‘Class’ Concepts

Class: Your Tool for Capturing ideas

A class represents your ideas about ‘anything’. Textbook definition is that the class is ‘blueprint’.

A class can represent a physical object like chair, screen, humans, animals.

A class can represent a role: Student, Employee and etc.

A class can represent an abstract concept like maths concepts: Circle, Kalman filter, and other. A class is your idea of ‘anything’ and how do you want to represent your idea in the computer memory.

Object-oriented programming gives you tools to define your class. These tools are the class name, data, and behavior.

You can represent the data of your ‘concept’ in a class. That data is called attributes. It can be of any primitives data types in the programming language you are using. For example, it can be, int, double, float, long, byte, short, boolean or char.

A class also represent the behavior of your idea. The way you want your ‘idea’ or ‘thing’ want to behave you can model in your class.

It is not necessary for you to create the behavior or data. It all depends on your idea. It is your choice if you want to create a class with behavior only or a class with data only or a mix of both.

You have made your choice and now let’s move on to the real thing that will transform your idea into a reality(in a computer memory)- the object

Object: The Real Thing

The only thing that exists in memory is an object. An object is created from the definition of class and here is the example of how the object is created:

MyClass theObject = new MyClass();

Objects are the real thing because they exist in memory. Let’s explore more on this and consider the following class:

public class Automobile
{
int NumberOfWheels = 4;

int Weight = 200;

double fuelEfficiency = 1.2;
}

Now calculate how much memory the object of this class will take?

int is 4 bytes and double will take 8 bytes if you are using C# or Java. Therefore one object of this class will take 16 bytes.

If you create 2 objects of this Automobile Class it will take 32 bytes.

What if a naive developer fetches records from a huge database and created the objects for each record of ‘Automobile’. When will it run out of 4GB of memory?

No of Records that your memory can hold = 4GB/16

Hence after 67108864 records, the system memory will be filled up. In a professional environment, databases are usually way more size than this. I have seen a junior developer doing this kind of mistakes when they are new to object-oriented technology.

The solution for a junior developer is that you should use ORM framework for that and that will handle these issues for you by managing the memory.

Let’s consider another example of object:

public class Automobile
{
int NumberOfWheels = 4;

int Weight = 200;

double fuelEfficiency = 1.2;

static int countVehicles =33;

}

Now, what will be the size of one object? 20 bytes. What will be the size of 5 objects?

The answer is 84 bytes. 16*5+4 = 84. There will be only one copy of the static variable in memory. It does not matter how many objects you create there will be only 1 copy of the static variable that will exist in memory.

In addition to that, that single copy of the static variable is accessible to all the objects. It’s kind of a global variable. Yes, the bad-old global variable.

One thing that I learned from painful experiences is to avoid the use of global variables. As a program grow older, it is difficult to track that who is modifying the value of global variables. So always be careful when using static members in a class.

Class: Member Variables

Member variables hold the current state of an object. These are the data variables and they are also called instance variables. If they are declared with the static keyword then they are called Class variables. Well, you know all this–Don’t you?

The key to using member variables is how will you use them in your code. If you intend to use a member variable within a class then there are very few problems.

But if you want –maybe someday– to expose your member variables outside the scope of your class then you should follow certain guidelines. Outside the scope means writing a class to disk in JSON format or a representing a database record or communication with another class.

For these outside reasons, people have developed getter and setter methods in Java and property type in C#. They are also called accessors. These accessors play an important role in frameworks and they are extremely useful concepts.

Consider C# as the programming language for the following example:

public class Automobile
{

int _weight = 200;
public int Weight


Get
{
   return _weight;
}

Set
{

   _weight = val;

}
}

Now what you are seeing is how most people use these accessor methods(get and set). There are a lot of things that you can do here. You can do any validation before setting any value, you can update or calculate any other value or you can store/retrieve a value from storage devices directly from here.

The most important thing that these accessors do is that they signal outside world (especially frameworks) that we exist. Through accessors, the outside world knows how many getters and setters are there and they will behave accordingly.

Here is an example of how an outside class can use accessors:

public void methodInAnotherClass()

{

Automobile theAutomobile = new Automobile();

theAutomobile.Weight = 300;

// retrieve

int currentAutoWeight = theAutomobile.Weight;

}

 

Class Behavior: Methods, Overloading, and Constructors

Methods define the behavior of your class provided–if your class has any.

You can define a class with methods in it or you can create a class with data only. There is no shame in this. You know how to define a method or how to write a signature. The only problem here is what behavior your class should have?. I will address this problem in the second part of this article.

Method overloading is when you define two methods with the same name but with different parameters.

e.g

int GetVehicleEfficiency(int weight) //ok

int GetVehicleEfficiency(int weight, string engineType)//ok

int GetVehcileEfficiency(float weight)// Great

float GetVehicleEfficiency(int weight) // Not OK you cannot change return type. This will confuses the compiler

This sounds like a great feature to have but should you use it. I would say that you should avoid it–Why?

It always confuses me if I declare two methods with a different number of parameters but if you keep the no of parameters same and change the type of parameter then method overloading is of great use.

Hence always avoid confusion while programming because it will make you drag you.

Let’s talk about constructors:

A constructor is a specialized method with the same name as the class and every class that you create has one default constructor with no parameters.

Class MotorVehicle{

String engineType;

// rest of the class code..
}

// The default contstructor
MotorVehicle aVehicle = new MotorVehicle();

You can create an object in many ways by overloading the constructor:

Class MotorVehicle{

String engineType;

MotorVehicle(){

engineType =default;
}

MotorVehicle(String anEngineType)

{

this.engineType= anEngineType;

}

}

// creating objects

MotorVehicle aVehicle = new MotorVehicle();

MotorVehicle aVehicle = new MotorVehicle(“Diesel Engine”);

 

Also, avoid using many constructors approach because this will also create the confusion and ultimately drag you.

You can see that there are features that are available to you but there are people who are ahead of the game like uncle Bob and Martin Fowler. They teach us some principles and patterns which tells not to use some features and use other features in a certain manner.

Why?

These patterns and principles given by seniors are a great way to avoid mistakes. You have to learn them if you want to be in the league of elite developers.

Another such suggestion (which also restrict you to use some features ) is to avoid setters methods or avoid changing the state of an object and this leads to another advanced level concept for professional and that is immutable objects.

Immutable Objects: Advance Tool for Professionals

An immutable object is an object whose state cannot be changed after it is created. With immutable objects, if you want an object with the different state then you will have to destroy the old object and create the new object with the desired state.

How can you create an immutable object?

Don’t let anyone change the state of an object and one way to this is: don’t provide any setter method for the object.

Making all data member private i.e only accessible within the class.

There are other sophisticated methods to create immutable objects such as factory method to create objects but for now, keep it simple.

Example of immutable object:

One example of an immutable object is String object in C#.

String data="Work";

data.toUpper();

Console.Writeline(data); // This will print: "Work"

String anotherData = data.toUpper();
Console.Writeline(anotherData);  //  This will print:"WORK"
Console.Writeline(data); // This will print the original: "Work"

As you can see that when method ToUpperCase() is called, it does not change the underlying string. But it creates another object with the modified string as shown in the second line. Therefore strings in C# (even in Java) are immutable objects.

But why use the immutable object?

Why I choose the discussion of immutable objects here. I can easily flash around a few definitions of objects and classes and move on but this article is written for people who are ahead of college kids and have a certain level of programming experience and they want to move ahead.

When you are in the league of elite developers you have to faced the challenges of multi-threaded programming and I have seen so many experienced developers failing on the battleground of multithreading.

Therefore, the immutable object is a tool that you can use in multi-threaded programming. Because immutable objects are thread-safe. How to use them in multi-threading is out of the scope of this article but add this tool in your toolbox so that when you work on a multi-threaded application then you can pick that tool and use it.

Encapsulation

People called it information hiding even some people go ahead and called that it is good for security. But both of these terms as I recall from my experience are misleading.

From information hiding, it seems like an object is not going to share data with other objects but this is not the case. An object should share data and/or responsibilities and without sharing there is no use of an object. Let me share a personal story.

If you have worked in a software developer where demos and trade shows are important for marketing you know that demos are important.

On such demo day, there was an urgent requirement to change the display of a software and I was asked to make the change. There were other engineers involved in that product.

The change was small. I have to add two fields to the display panel. I create another class and since both of these parameters were related therefore I put them in a single class and use the object of that class.

I did this to make the user interface code to look cleaner. Because in such a stressed situation (the night before the demo) you cannot afford to make tiny mistakes.

The code worked and one of the engineers praises me in such a way that I still remember that after so many years. He told me that “Wow you created a new variable and use that!”

See, he is telling that an object equals variable. First of all, I don’t want my readers to be like that i.e treating an object like a variable. Beside that this story depicts the concept of encapsulation.

You merge two or more data and/or functions into a single entity(the variable). This is called encapsulation.

Hence the concept of encapsulation is more towards modularity then security or hiding something. It is more towards making an object/class represent a single modular concept. Hence use it in that way.

Naming: So that you can Read Your Code after 6 Months

It is a good place to talk about naming when we are discussing the internals of the class and objects. As a professional developer how you should properly name your class, member variables, and member functions.

As a rule, you should name your function and variables in such a manner that there are no needs for comments. How?

As a professional you know that most of your time is spent maintaining the code that you have written. This includes fixing bugs, making improvements, adding features and using your code written for one project to other projects.

Therefore it is important for you to write code that is easy to understand for you or for any other developer. One way to achieve this is through comments. You can write comments to elaborate your code.

Another better approach is to name your variables and function in such a way that there is no need for comment.

For variables use elaborative names. Never use short names e.g. You can only use short names(i,j,k) in the loops e.g.

In order to do that you will have to make your function shorter.

If you have a large function currently then divide it into multiple small functions. Each function can contain only 3-5 lines. It looks like an exaggeration but you get the idea. Small enough functions whose purpose can be defined in their name.

Example:

// Descriptive and meaningful methods and variable and class names 

int GetProcessedData();
void TransformAllPositions();


int endingFrameLocation;
int firstPositionInDatabase;

class BodySearcher {}
class FileParser {}

In this way your class name, variable names and function names will convey the reader of your code about the minute detail and will help him understand the code better.

For now, this is enough for inside the class concepts. Now let’s move to concepts outside the boundaries of class.

Outside the ‘Class’ Concepts

If you are writing a professional code then one class or one type of objects will not be sufficient. You need more than one classes and these classes have to interact with each other to accomplish a common goal.

The Primary Goal Outside

Consider classes and their objects as the first-class citizen in the object-oriented paradigm. Each citizen has different responsibilities. Each citizen will interact with each other to achieve a primary goal.

As an object-oriented developer, your job is to share the responsibilities among the citizens and design the interaction channel among the citizens in such a way that it is simple and effective.

There are many tools to share responsibilities between objects. A famous technique is ‘inheritance’. Responsibilities are shared between children and parents. There is a better approach than inheritance and I suggest you as a professional developer you should use that approach.

Extremely important concepts like interfaces and abstract classes are basic for understanding any framework an even designing your own framework.

Next concept is polymorphism and how you can leverage polymorphism to write code that is easy to change and maintain.

Finally, all of this discussion will lead to a very important principle of communication between objects. This is the source principle for many object-oriented design patterns. This is also the base principle for concepts like interfaces and polymorphism. It is called the protected variation.

Therefore you will know why any design pattern exists or even concepts like polymorphism and interfaces are there to support protected variation.

So, let’s move on with our most important tool outside the scope of ‘class’.

Association: How it is Better Than Inheritance

The citizens of our object-oriented paradigm can develop a relationship using the ‘association’. In very simpler words it’s like having a reference to another object.

e.g

public class Member{


}

public Class Community{
Member aMember;

}

By having reference to another object your object has the ability to call the referenced object methods. You can say that both of these citizens have joined hands to accomplish a goal.

There are certain nuances to association namely aggregation and composition.

The differences are easy to understand if you consider the life of an object. For example, consider two objects A and B. If A holds a reference to B and both can live independently then it is called the good old association. This also means if object A is destroyed(and garbage collected) then there is no effect on object B.

The relation is called aggregation if object A holds more than 1 references to object B or there is a part-whole relationship.

The composition is when the referenced object’s life depends upon the referencing object’s life. For example, if object A creates the object B. Therefore when object A is destroyed then object B also go into the valley of dooms.

But don’t worry about all these differences because when programming you will not be worried about the type of association. When you are doing real-world programming you are worried about how the responsibilities among the classes should be distributed.

You will be worried about how your objects communicate with each other with minimal discomfort. How can you optimize the communication between objects?

Association is a tool that you can use to make objects share their responsibilities with each other and another such tool is inheritance.

Inheritance

Inheritance is about distributing responsibilities between two classes: parent and child. One benefit is that the child class inherit all the qualities of the parent. This feature alone makes inheritance a lucrative choice and the foundation of that is reuse.

Let’s see some lame examples of inheritance:

Inheritance example

As you can see that I have modeled the Vehicle class and it’s children so that the common features for both vehicles namely ‘car’ and ‘boat’ are combined in one parent class namely ‘vehicle’.

Now if I want another specialized car like a sports car I can extend the ‘car’ class and implement the logic specific to a sports car.

Inheritance Examplee

It sounds logical and one cannot stand without cheering and clapping for the above design. This is how you read in other blogs and books. This is good for a beginner. But the problem is that real life problems are hardly like that.

Real world problems are complex. Real life problems evolve. Therefore if you are using inheritance to model real problems these hierarchies will also evolve.

I have seen systems where developers life is consumed in managing large hierarchies of inheritance. Managing inheritance hierarchies is a cumbersome task. If you don’t believe me then try using inheritance for next 6 months in your current project and you will know why it is a rigid approach. On the other hand, composition is more flexible in adopting changes.

I am not saying that inheritance is altogether bad and you should not be doing it. But as a beginner, the inheritance look charming as you can see the above vehicle and car example. This leads to misuse or overuse of inheritance.

There are some great uses of inheritance and there are some drawbacks to the composition. But for beginners and for a clean code you should focus more on composition instead of inheritance.

Method Overriding

Before moving on let me introduce another important topic that is important for sharing responsibilities between objects and that is very necessary to understand some advanced concepts.

Method or behavior overriding is that when child class re-implement the parent class behavior in its own way.

Method Overriding

There is a car which has the ability to drive. Then there is a specific car which is the sports car. It can drive but it’s driving feature is a bit specialized that it has more engine power. Hence method overriding let the child demonstrate relatively same behavior but in a more specialized way.

Abstraction: The Tool That Helps you Develop Mega Software Systems

In outside strategy, we have discussed methods to distribute responsibilities to different classes. But sharing responsibilities between objects blindly will lead to a complex design.

As a professional programmer, one of the major goals is to reduce the complexity of the system. This single skill will separate you from those who write spaghetti code.

Let’s understand abstraction with my personal story. Once my boss asked me to update one of my software. This update requires that software should be able to receive data from a network device. Previously it was able to receive data from serial port only.

There are going to be a lot of details to take care of. For example, I will have to include some conditional statement to determine the kind of operation (either serial or network) and I will also have to include/change low-level I/O methods since there are different methods for receiving data from serial and network devices.

These tiny details are good enough to drown me and resist my ability to think horizontally. For example what we can do if the software can acquire data from a network device. What we can do with this new data rate and so on.

By using abstraction I have designed my software in such a way that supports horizontal thinking.

So, as soon as my boss asked me for new changes I don’t’ think about the tiny details. I know my code can talk to any device. This gives me the power of horizontal thinking.

This horizontal thinking allowed you to solve problems and come up with creative solutions without getting involved in petty details and I consider abstraction as a tool of object-oriented programming that helps you achieve precisely that.

Let’s talk about the tool itself:

Interface: First Tool of Abstraction

The first tool that I will describe is the ‘interface’. This is how you define it:

Interface IStream{

byte[] getData();

}

You cannot instantiate an interface. Every class that implements an interface must define methods of the interface.

NetworkStream :IStream{

public byte[] getData()
{

byte[] data = NetworkCard.GetData();// read data from network

return data;

}

}

Easy? I believe you know this. Simple syntax stuff. The good part is where I told you that you cannot create the instance of an interface. There is no way your interface will ever see the life of its own that is it will never exist in computer memory. Only the implementing class’ object is going to see the light of life. Only the object can exist in memory.

Here an interface acts as an abstraction layer. It does not define the behavior or implement the behavior but give the hint or overall picture of what should a behavior look like(i.e the signature of the methods). It gives the responsibility for defining the behavior towards the implementer.

For the above example, every class that wants to act like a Stream should implement the methods in the IStream interface.

In this way, any of your code that wants to work with network stream will talk to the interface that of the implementing class. Here is the example

void CoreClassMethod()

{

IStream aDataStream =new NetworkStream(); // using the interface hold the / //reference

Byte[] data = aDataStream.getData();

Display(data);

}

Therefore if my boss asked me to extend the capability of CoreClassMethod to handle PCI data. I will not worry about the implementation of CoreClassMethod. I will just write a new class that will implement the IStream interface and then creates the instance of that class in CoreClassMethod:

PCIStream:IStream{

Public byte[] getData(){

// read data here using low leve I/O libraries and return it.

}

}

/////////////////////////////////////////
void CoreClassMethod()
{

IStream aDataStream =new PCIStream();
Byte[] data = aDataStream.getData();
Display(data);

}

In this way, I can extend the capabilities of the existing code. Another good use of Interface is demonstrated in this article.

Closer Look at Interfaces

Let’s take the example of.Net library’s interfaces ISerializable or IDispoable. If any of your class implement any of the above interfaces then it should define the methods of the interface.

Any Other part of the .net library that works with Serializable objects (e.g .net JSON library) will work seamlessly with your objects as well. Because now you have implemented the required serialization in your own manner in your own class.

The beauty is that the code was written years before can work with your code that you have written recently.

Let’s explore more on this concept in the next tool of OOP for abstraction.

Abstract Class

An abstract class is something in between a full-fledged class and an Interface. You can define some behaviors(methods) and leave some behavior to be defined by its children.

For example:

abstract class GeometricalObject{

void showOnScreen(){

// implementation of ..

}
abstract void draw();
}

/////////////////////////////////////
class rectangle: GeometricalObject{
void Draw()
{

//specifics of drawing a rectangle

}
}

//////////////////////////////////
class cricle:GeometricalObject{

void Draw()
{
//specifics of drawing a circle
}

}

Some code that is shared among all the children(implementers) is the code written in the method showOnScreen in the parent class.

Difference Between Generalization and Abstraction

The concept of sharing common behavior of children in the parent class is the essence of inheritance or generalization. The primary tool to accomplish this is inheritance.

The concept of delegating the responsibilities to the implementing children or classes is called Abstraction (and sometimes specialization).  The primary tool for accomplishing this feature is ‘interface’.

The abstract class stands in between these two extremes. This tool allows some behavior to be shared among all classes and delegate some behavior to the children classes. There are great applications of ‘abstract class’ in developing frameworks. I have discussed this in detail in this article.

Difference Between Generalization and Composition

In generalization(and inheritance) common behavior between two children is defined in the parent class. Therefore anyone who is using the children will have access to all the methods of parents. You have reused the code means you don’t have to write the code twice. But the drawback is that you have to deal with strict hierarchies of inheritance. Hence it is not flexible.

Now with composition, you can achieve the same. You can combine a behavior in a class and then give the reference to every other class who need that behavior. This is more flexible. You can change the reference at run-time while in inheritance you can not change the hierarchies at run-time.

Therefore it is recommended that you should achieve reusability through composition rather than inheritance.

Polymorphism

In simpler words polymorphism is the ability of the parent reference to hold the reference to any of its children. A parent can be an interface, an abstract class or a full-fledged class(a.k.a base class).

So when you call from parent reference the desired method gets called on the appropriate children.

Interface IStream{

byte[] getData();

}

/////////////////////////////////
NetworkStream :IStream{

public byte[] getData()
{

byte[] data = NetworkCard.GetData();// read data from network

return data;

}
}
////////////////////////////////
SerialStream :IStream{

public byte[] getData()

{

byte[] data = SerialPort.GetData();// read data

return data;

}
}

// Now if I have the reference of the parent class which in this case is IStream

// I can call the method of any child class

// e.g.

IStream anObject = new NetworkStream();

data= anObject.getData();

//Change this in the run-time

anObject = new SeriaStream();

data=anObject.getData();



Polymorphism not specific to inheritance or to interface or abstract class. It’s a generic tool that can be applied to inheritance, abstract class, and interfaces via method overriding.

Another generic concept which is influence many concepts of object-oriented programming is protected variation.

Protected Variation: Ulitmate Goal

Many concepts of object-oriented programming that we discussed above are techniques for achieving protected variation.

Recall the example from the discussion above when my boss asked me for receiving data from a network stream.

It does not bother me much to make the change because I protected the variation in the data receiving method using the abstraction and polymorphism.

This is because I anticipated this kind of change. In a similar manner, I used polymorphism and abstraction where I anticipate a change in the future. Therefore when the change is requested it is easier to implement the change.

Hence you can keep in mind the variations that your software may face and then use interfaces and polymorphism to protect it from changes and variations.

A word of caution–don’t overdo it. It is a design principle and that is in your hand to abuse it or use it consciously. Don’t assume that every aspect of your code will change. Because protecting the variation incur cost in terms of more code or classes and ultimately complexity.

Therefore if you over do it then you will have to manage a lot of code without any good reason. So when you are protecting the variation then make sure that there is some merit to your decision.

Finally, in the outside strategy, you learned tools for assigning responsibilities to your first class citizens.

 

]]>
https://www.linesperday.com/object-oriented-programming-concepts-for-professionals/feed/ 3
Why People are Successful in Their Jobs When They Failed as Students https://www.linesperday.com/why-people-are-successful-in-their-jobs-when-they-failed-as-students/ Thu, 10 Aug 2017 06:42:31 +0000 http://www.linesperday.com/?p=294 We all have tried something before and it did not work out. Like trying to cliff jumping into the ocean.

Once I decided to take the steepest and a long water slide. The moment I reach the top and look down- I was scared. Everybody was looking so small on the ground.

The water was flowing with speed at the edge of the slide.

The air was breezing through and I believe the sun was shining with additional power. I just sit there and think about it and then I aborted.

Months later I tried again and did it– finally. But you know, the experience was thrilling. The ride was worth the pain.

Similarly, I tried learning a course during my undergrad studies and I failed.

It could be possible that the instructor was not good enough. Or the course was boring or that particular subject was not my thing.

For example, I tried learning two courses numerical computing and object oriented design. And let’s say I didn’t grasp the concepts.

But, I successfully learned these two courses after graduation and during my job. Recently I was reflecting why this happens?

There are some courses that we all have tried in our college/university life but we failed there and now we know a lot better about them.

So, in this post, I will analyze why I was failed in university and succeeded afterward in real life and what steps you can take to rejuvenate your desire to learn old subject again.

1) Action is Louder Than Words

There are subjects which we don’t understand because we can’t see them in action. For example, one of my classmates once said to me during undergrad studies:

“I want to go into civil engineering, where we can see things like buildings, bridges and other huge things. Something that you can touch and feel. In software development, you just cannot do that”.

You can see that. A software or code is more of an abstract thing. Like mathematics. But once you are in the field you know how the code is written by you to solve real problems.

It brings in profit. Your code can move some hardware (if you are embedded software developer).

These real life results show the importance of the work that you do. And you like results. Due to this, your mind starts to grasp ideas and gives you an edge in learning. Hence once you see things in action you learn faster.

Therefore, the subject of numerical computing was very helpful when I solved a real world problem which involves curve fitting. It raises the importance of the subject and makes it easier for me to learn the subject.

2) You are not Under Stress, Right now

Ok everybody is under stress, mostly at our jobs. But during studies, you have a lot of things to care about. Like other subjects to cover during the semester. You are worried about assignments, exam, labs and other projects.

Our goal is different during undergrad studies. We want to appease our teachers :). We want to score well in the exams. That’s it. That’s our problem.

During studies, we don’t have to solve a real world problem. We have to get marks in our exam and if you didn’t perform no one is going to be affected except ‘YOU’.

But as a professional, there is no exam date. No multiple courses, no exams, and no teachers. Here your core goal is to solve the problem and until you don’t solve the problem the project will not be completed. So all of your time will be consumed on solving the problem.

Once you solve that problem, you will move to the next problem.

Hence you will be working on one problem a.k.a “the project”(ideally). Therefore you will have time and mental resources(since you are not distracted by 4 other subjects) to learn that subject which you tried before.

3) You had sub-par Resources

In universities, I believe you have subpar resources. I am not talking about you if you are from elite universities.

In colleges/universities, computers were slow. There were shared resources and labs. Schedules and timings that you had to follow.

Whereas as a developer in any organization you get super awesome resources. (this was not true for me– but it is true for the majority)

Second, an awful resource was the BOOKS recommended by our teachers. I am a big fan of books. They are ultimate resources- if you want to grow.

But there are bad books too.

Although there were some great books recommended by my teachers. But 80% of the books were very limited. Those were the books I believed written for academics only. The text was written in a super dull and boring way.

When I tried searching those books on the Amazon. Guess what I found “0” reviews. Bad comments and lower rating.

Hence I know that Amazon book rating system is authentic.

Here is a little tip for finding great books: A simple search “top books on XYZ subject” can yield the names of the best book on that subject and then there is the Amazon best selling category where you can search the books on the subject that you like.

Anyway, when I read great books on the subjects of programming, design or anything else that subject become fun to learn.

I wish that I knew about great books during my undergrad studies.

4) Experience is the Greatest Teacher

In real life experience teaches you a lot. For example, bit manipulation looked like a simple concept to the newbie Umair.

But when you really dive into the inner workings of understanding signed/unsigned numbers, 32-bit representation of integer, XOR and AND operation, and how the float is represented by IEEE 754 standard. Then you realize that bit-manipulation is an advanced topic and a lot of things can be done with that.

In real life, you commit mistakes. You see your software failing while saying to everybody that last time it worked fine and you don’t know what’s happening to it now. You are introduced to the term ‘intermittent error’.

So, your mistakes are your most valuable experience. You see things differently than your younger self and you know what is important in programming.

If you are experienced, watching your code organized properly will bring you the joy of your life.

If you are experienced, your code is written delicately with comments which are easier to read like a novel. Your code is beautifully divided into separate files and classes.

If you are experienced, it’s a pleasure to watch your web application adopting its layout across all platform and browsers.

These are the perks of having experience in the programming world.

So, if you tried learning before and it didn’t work out then one of the reason is that you didn’t experience an implementation headache, failures and hardship.

So do you really want to learn something go and implement that–now.

5) Now You Have Mentors

Mentors are very important if you want to learn. A mentor is different than a teacher. In my definition mentor is someone who has reached a certain point which is your destination.

You can have many mentors for different areas of your life.

In the programming world, a mentor is someone who has ahead of you in that field. Who has gone through the pain of being a newbie.

Where can you find a mentor? One thing is sure you will hardly find them in your college campus.

But you will find them in your workplace. Someone with experience in your technology. They can solve your problems in hours and can save you weeks.

So, if you want to improve your learning ask senior developers. Ask them via forums and online. Read their books and they will guide you in your journey.

Therefore, if you tried learning something before and failed then this time give your hands in the hands of your mentor and I believe this time you will be successful.

Your Ideas

So, what were your challenges when you tried learning something before and succeeded later in 2nd or 3rd attempt. Share your stories and ideas in the comments.

]]>
Estimation and Management for new Software Engineers https://www.linesperday.com/estimation-and-management-for-new-software-engineers/ https://www.linesperday.com/estimation-and-management-for-new-software-engineers/#comments Fri, 04 Aug 2017 04:46:30 +0000 http://www.linesperday.com/?p=281 We all have faces bosses in our life. For programmers, a boss is a real pain in the ass. And do you know why?

They need the work on their whim and they need it now. They think writing a code is a mechanical task – you put two things together and it should work. And you, a software developer, know that it will not work.

Your boss can give you any task which is out of your job description. When you ask for training –your boss will happily deny you. Or you are afraid to ask for a personal free time so that you develop new skills.

But your boss always expects an out of the box performance from you. And there is a long list of expectation out of you. Interacting with your boss is a painful experience and:

It is more painful if you are a junior!

If you are a junior then it is more difficult to convince your boss. You have not won the battles for your boss. You have not stayed nights for completing a project whose completion date is long past.

In short, you have not saved your boss. You don’t know about the culture of your workplace. You have no experience. So it is more painful for you than a senior developer to bear an unbearable boss.

So, the question arrives that what you can do to do better and enjoy your life?

First of all, you cannot disrespect them-even if you wanted to! Because you know that they are everywhere. If you quit–there is a possibility that you will find a worse boss.

Secondly, you wanted to protect yourself.

Not because they have the authority to fire us. But because you wanted to master the skill of handling bad boss so that anywhere in the world with any kind of boss you can live your life the way you want it.

Following are more reason to conquer your boss:

a) We want to show-off. We want to gain the respect of our boss. We want to be someone whom our boss depends on.

b) We want a promotion or raise. We want it now so that we can get luxuries.

In this article, I will share how can you manage your boss by solving his or her two main problems(out of many).

The first problem: have you ever encountered your boss asking for the estimates on the fly. Giving you a task and then immediately ask you for how much time will it take to complete it. I bet you have faced such situation.

Second problem: I will tell you how can you manage a boss who is on your tail and interfering at each step i.e. “a micromanaging boss”.

Solution for First Problem: Use Estimation Techniques

I always encounter this situation when you have finalized the discussion of a major change in the software code. You and your boss are both agrees upon a common set of problems. You are looking at each other with confidence and agreement and then suddenly your boss asked:

“How much time will it take to complete this task?”

This sound like a genuine question from every perspective. There is a project for which your boss is responsible and he or she has to know about the amount of time it will take to complete the task so that your boss can predict the timelines for product delivery.

And it is not possible that you are assigned a task and your boss can forget about it-until later you told your boss about the success story.

Hence giving estimates seems logical. But there is a little problem–

They need the estimates now!

They are asking the estimates on the fly!

In my software development career, I always pondered that how can I solve this problem. How can I as a software engineer give my boss the estimate that is undebatable?

Estimation is itself a complex field and has failed scientists in a simple looking and straightforward businesses like civil construction.

In software development, estimation is more difficult due to unseen complexity or uncertainty in the requirements at the initial stages of the development. l have covered the basics of estimation and two great examples of software development here.

But here I will discuss three principles that you can use now to give estimates to your boss:

1)Never Give Estimates on the fly

Never guess the time to complete the task. It does not matter how hard or pressing the situation for you is. Always ask for the time to do the estimation work.

When task discussion is ended and you are asked to give an estimate you can say “let me look into this and I will be back to you within _____ minutes via phone or email”.

Even 5 minutes of estimation will beat your best guesses. Hence never guess and always ask for the time. It will look scary at the start but eventually, your boss will understand.

Also, don’t forget to reply your boss with the estimates.

2)Divide and Conquer Count

The easiest way to give an estimate is to divide the task into subtasks. This sub-task can be the steps that you need to perform in order to complete the task. Or modules that can be developed independently.

For example, If you have to develop three web pages then try to compute the time required to complete 1 web page. That is trying to divide the work in modules.

After that, write two values. One value for the minimum time that one sub-task or one module will take and one for the maximum time. It is easier to estimate small task or module.

Add the minimum values separately then add the maximum values separately. Now report these values to your boss.

Estimation Pcitures

Here you have done two things: First you gave your boss the range. That is the minimum time and maximum it will take to complete the task. Never give the point estimate always give your boss the range.

Secondly, you distributed the estimation error across many tasks/modules. This will reduce your overall error in the final estimation. Hence divide and then count is one of the best techniques that you can use to give software estimates.

3)Use your own historical data

One of my bosses used to ask for the amount of time for each task assigned to me. I happily gave him the estimate. My boss noted it down and I know that the boss never follow-up.

Whenever my boss assigned me next task, the boss never checked the amount of time that I estimated for the previous task. So, it is easier for me to give nonsense estimates.

But you should never do it. Keeping track of your past estimates is a very good habit for two reasons. First one is obvious, you will know how much time you have estimated for a particular type of task and how much time it actually takes.

A second reason is you can use your own past estimates(i.e your own historical data) to calibrate some advanced techniques of estimation. Hence using your own historical data will improve the accuracy of your estimates.

So, by now you know that I write about good programming and design good practices and how can you up your game at your workplace or in your team. This is all by sharing my experiences and hard learned lesson by myself.

Talking of hard core lessons. Another important area where you may have struggled is the micro-managing boss.

Solution for Second Problem: Management for Micromanaging Boss

Nothing is more painful than a work wasted on your boss whim. Your boss may tell you to do things which he knows nothing about. He will tell you exact steps.

I have been in the same pit. I have faced the micromanaging -self-satisfying boss. I always think “I m the developer and please let me do my job”.

Boss for young Engineers

I don’t want my boss to sit with me and tell me everything. While everything my boss has is just an idea and the underlying needs to show off.

And in your heart, you will be telling yourself- “What!. This is not possible. This will not solve the problem but only delay the solution.”

I have done three things to minimize the negative effects of the boss who is always on your tail:

1) Use the one minute manager solution

In the book the one minute manager the author discusses the one-minute goals. Getting very clear on the objective and the end result is the core thesis of the one-minute goal. But since your boss is not delegating the objective to you properly so you have to work to change his attitude.

Most effective way is always ask your boss to discuss what your boss “wants”. Try to find out what are your boss priorities by either directly asking your boss or any other senior person.

Once you identified(by any means) your boss priorities then you should over-deliver. This is needed to win his or her trust.

At first, your boss will be adamant. He or she will hesitate but once you gain his trust you can have the flexibility to work out on your goals and then deliver them.

Remember trust is important and the hardest to achieve. So work on that, once you have your boss trust, your boss will believe that you are working on his or her priorities and will let you do the tasks your way.

2)Define your own time of reporting

You should define your own time of reporting. If your boss calls you up every minute then it is so hard to focus on your programming tasks.

You know programming is mostly a thinking job and if you are getting disturbed every minute you will lose the concentration and hours of work.

Ideally, reporting time should be once per week. But if you cannot achieve this (it means frequent calls or emails) then it must be once in a day. In that time(15-30 minutes) you can write emails or make calls about the status of your work.

3)Shrink the meeting size to 15 minutes

A meeting is a tool used by our bosses to tell us their stories. They tell you the fine details of your work in meetings. Hence if you want to get rid of micromanaging boss then I suggest you should avoid meetings.

Try to find out the excuses to get out of meetings. Make a list and see what works. The most helpful excuse that worked for me is:

After 15 minutes of the meeting, I said: “I am in the middle of something on project X- can I go now?”.

Or at many occasions, if I know that meeting is going to take more than 15 minutes because there are 5+ people in the meeting then I try to join the meeting late. This is with the intention that if they need me they will call me.

Guess what, when they really need me they call me. And that happens 10% of the time.

When I was a junior I was very fond of attending meetings. It feels important. You get to know what is going on around and you think you will get the picture.

After a few years, I found out that meetings are usually are a waste of time. There are guidelines for conducting good meetings. Like setting agendas, taking minutes and others. But nobody follows them.

As a junior developer, you don’t have the authority to set the meetings template. But you can follow avoidance techniques mentioned above to avoid meetings.

Hence avoiding meetings is one way you can get rid of your boss telling you minute details of your job in an infinite loop.

Your Stories

So, these are the techniques I used to perform better in my office. You may find them helpful. Your problems may be different. More painful or less painful.

So, what are your problems as a programmer that you face in your work environment? What are you doing to solve them? Reply me via email or comment here.

I read every comment.

]]>
https://www.linesperday.com/estimation-and-management-for-new-software-engineers/feed/ 2
Object Oriented Design for Life https://www.linesperday.com/object-oriented-design-for-life/ https://www.linesperday.com/object-oriented-design-for-life/#comments Sun, 04 Jun 2017 09:48:08 +0000 http://www.linesperday.com/?p=239 One day I started running with my friend. No prior planning. No management. We just arrived from office and my friend ask “do you want to go for exercise?” I said yes. Then my friend says come on let’s run.

Without any second thought, I changed dress and started running with him. We were desperate and we push our limits on the first day. We were breathing heavily. We ran about 4 miles.

There was severe pain in my legs but we were motivated so we did not care.

Object Oriented Design

Next day the motivation was gone and It’s gone for long. We never went for exercise even after months.

Do you have this kind of experience? You have started something out of desperation and then after some time leave it.

For example:

You started reading books and leave it after 1 or 2 weeks!

Or

You started dieting and didn’t bother to think about it again after one party with friends!

So why we do it- why we start something and then leave it?

This is because somewhere in our conscious mind we are thinking about our health. All of us know that exercise is good for health and we should do this. But we don’t have the time (put any other excuse here).

We learned about these healthy habits from the news or from articles. We thought in our mind that we should try these. But we never do. So these things all add up and one day they outbreak.

Psychologists called that emotional wave. We were on an emotional ride when we started running. One problem with the emotional ride is that they declined after some time. And we fall back to our old routines.

You can feel other emotional waves as well. For example, eating healthy food, wake up early, not waste your time on social media, TV, movies and etc.

As a programmer, you may experience emotional waves. For example, you want to gain experience in another technology and therefore you started a personal learning project and never finish that.

Another emotional wave for programmers is that they want to make good object oriented designs. Often I had these emotional waves but like running I could not keep up.

So in this post, I will discuss what you can do to keep up using object-oriented design(OOD) methodology and not fall victim to emotional wave.

What is stopping you?

OOD is an important skill to learn. Once you are good at it, learning frameworks will be easier. Writing maintainable code will be easy. You will feel proud of yourself.

Learning OOD as a skill will certainly lead you to the club of elite software developers.

You want to recognize yourself as someone who knows about object oriented designs. You want to see yourself in the design role.

Ok. Ok. Ok. We all know the benefits of OOD then what is stopping us? There are two kinds of factors: internal and external.

External Resisting Factors

The first external factor is your boss. Your boss does not understand OOAD. Especially if your boss is non-technical.

Your boss thinks that you are wasting resources. Because applying OOAD process will not produce a single line of code.

Most of the benefits of using OOAD are not immediate. Benefits like reusability, modularity, and testability are visible when there are changes in the code. Changes happen in future. Hence why invest in something that is not important now?

Believe me, your boss is thinking there will be no change in the code — so why extra effort?

Guess what!

You will have to update/upgrade/modify your code. In software development, the only thing that is constant is ‘CHANGE’.

Hence convincing your boss is one huge external factor.

Another external factor — not enough resources. Sometimes we believe that if we have good tools then we will be able to go for OOD.

For example, UML modeling tool. Some developers believe that if they don’t have the perfect UML designing tool they cannot design.

Internal Resisting Factors

Harder than external factors are internal factors. The first one is that nobody will appreciate you when you start applying OOD process. This is because you don’t have any concrete evidence right now to show the benefits of your code design.

External appreciation is critical to get us moving. Hence if nobody supports us during our journey then we can lose the motivation to design our software properly.

Another internal fear is that you will doubt yourself- i.e you may doubt on your design skills. You yourself don’t know if something will be any helpful in the future– as results are not imminent while you are designing.

This is truer if you are a junior developer. You only have studied about design patterns during your studies. Due to this, you are lacking experience and confidence.

Another fear is the fear of failure. I believe this is more common. I am the victim of this fear. Once I design a software where I use generalization when there was only one line of code was common in two classes. Due to this, I have to manage more classes.

I always thought – what if I failed while making this design choice and due to fear of failure – I never did it. Failing once has made me resistive to good design practices.

Too many factors, what should I do?

Yes up to now I only described the factors that resist us. First, I described that sometimes our emotions are on high point and we want to make something happen like getting fit or making good engineering design.

But the reality of the world sets in and we leave the good things for tomorrow. Which never comes.

The first thing to design better is to create self-awareness. Create awareness of the factors that can limit your ability to do things which are good for your future.

Some factors I already have mentioned above but they are not limited to these. There can be many others. Whatever they are following guideline will always help you.

How to handle external fears?

Now, to deal with external factors(your boss and etc) you have to find small opportunities. Opportunities where you can make your design better.

For example, an opportunity is when you are debugging. While debugging your code you have the opportunity to stretch time. Here you can apply design practices and make your code better.

Another opportunity is when your boss asks you about an estimate for implementing a feature. Here you can add additional time for design activities. Make sure that you only add hours or 1 to 2 days at max. Never allocate weeks for design activities.

Another opportunity is when you are set for review. This can be rare and it varies from places to places. When you are reviewing your code for any unseen problem you can refactor your code for a better OO design.

You might be thinking that how can we make a good design after all the code is written?

Well, you can make your design better at any stage of the development. An OO design is not only a one-time activity.

How to Overcome Internal Resisting factors?

To overcome internal factors the key is confidence. Believe in that whatever you are doing will be helpful. Once you have this firm believe, you will observe the benefits of OOAD over time.

This is extremely necessary if you are a junior developer. Lack of experience will make you doubt the benefits of OOD methodology. Once you have confidence and willing to give in the effort, you will reap benefits.

Once you are confident then don’t worry about what other people are thinking. You will not need external motivation to carry out your work.

Next is fear of failure.

I used to think more about failures than success. What if all the design effort that I am doing will not be helpful. What if all the additional number of classes created due to the design process will be a headache to manage!

And most scary feeling:

My boss and my colleagues will make fun of me!

Yes, I have these fears and how do I tackle them. It’s simple. Just do it. If you failed (which happens rarely) then you know that you have learned something- But if you don’t give it a shot what will you lose?

For example, you will lose:

  • An experience which can get you to higher places.
  • Using object-oriented programming languages in an object oriented way (Not the procedural way).
  • Most importantly trying out new things in your life 🙂

Look, what I am saying is “start small”. Find the small opportunities to apply OOAD skills. Take small risks. These small tests will bring you the wealth of experience and you will be far ahead of your peers in the coming years.

So, what are the obstacles that you face? Are they internal or external.? Reply me via email or write them in the comments.

]]>
https://www.linesperday.com/object-oriented-design-for-life/feed/ 4
A Programming Skill That you can use to Fire Your BOSS https://www.linesperday.com/a-programming-skill-that-you-can-use-to-fire-your-boss/ https://www.linesperday.com/a-programming-skill-that-you-can-use-to-fire-your-boss/#comments Wed, 24 May 2017 05:19:35 +0000 http://www.linesperday.com/?p=216 I was a fresh graduate. Looking for a job. Then one day when I was on a street and waiting to cross a road.

My phone started ringing. I received the call. It was from a software company where I have applied 3 months ago.

They were calling for a recruitment test. I replied positively and confirmed my availability on the test day.

So, I went for the test. A huge crowd was there. My university seniors, developers from other organisations and developers with years of working experience have appeared for the test.

I said, “Oh shit”. How will I ever be selected in this crowd? The competition was going to be fierce because that was the best company in the area and remuneration package was higher than any other company in the market.

At the start, they gave us a 1-hour aptitude test– that contains small maths problem, word problems and etc.

I was not prepared for such a test so I just solved the problems as soon as possible. I tried not to work hard and keep my brain resources for the programming test session.

exam of ooad

In the programming session, there were MCQS. Unfortunately, the questions were related to deep technology.

Deep technology questions are like: “how do you set x parameter in a machine.config file (ASP.net)”. Or “What is the syntax of doing XYZ in Java”.

These type of questions are for those who have invested years in that technology (e.g programming language, frameworks and etc). I was good at concepts but not fluent in the technology.

Also, I have never worked professionally on any technology which was used in that company. So I utilized my guessing power. At that moment, I knew I will be mediocre in the crowd.

Then arrive the last and the hardest session. Each candidate has to read a description from a document and develop a working product. The time limit was 3 hours.

Again, a lot of deep technology experience was required. My hopes for getting hired were doomed.

So, out of desperation, I did two things. First I assumed a lot of things which were ambiguous in the test (Or I did not know about them).

Secondly, I tried not to solve the complete problem but tried to convey my attitude towards programming.

Hence, I tried to make the architecture of the software as good as possible. I applied some of the concepts of object-oriented analysis and design(OOAD) that I knew.

For example, I used the MVC. Although there was no built-in MVC in Asp.net at that time. I write separate classes for models, controllers, and views and created a looooooose implementation of MVC.

In this way, I develop some of the required functionality and submitted the code. Test completed and everybody went home.

FINGERS CROSSED!

A few days later I was called for an interview. I was good enough to be called for an interview. I did not believe that. I thought my guessing power in the test was awesome.

The Interview consists of a panel of 7 people. 5 were from the technical background. And two people were from human resource.

OOAD interview

Everybody was asking me only about the final session of the test.

“Why you did not complete the code?”

I told them I was constrained by the time limit.

Then they ask why I designed the code using object oriented methodology and why I used MVC. That was the longest discussion during the whole interview.

So, I told them about how object oriented analysis design(OOAD) is good for testing, managing code and easy to read.

And so on.

But there were some sceptics in the panel and they did ask some deep technology question but I dodge them by saying “You can find that from the reference documentation/book”.

BINGO.

Later, I received the acceptance letter. They showed me that the accepted ratio was less than 1 percent. Hmmmmmmmm.

I performed poorly in aptitude test and even in programming test but the knowledge of object-oriented design has saved me.

There are skills which are independent of any technology and they are called transferable skills. If you are good at them you can apply them to any technology or programming language. OOAD is one such transferable skill and having that skill got me the highest paying job.

So, If you have transferable skills then you don’t have to memorize the documentation or syntax of some dying technology.

Some programmers are stuck in a job. They think they cannot switch because they don’t have suitable technology experience.

With transferable skills, you don’t have to worry about the experience in specific technology. You can fire your boss at any time if you want to change your job- because you have transferable skills that you can apply in any other technology.

People in interview will love you once they know that you can learn fast and you have transferable skills. Hiring you will make your interviewer proud.

Now it’s time to reveal a SECRET.

A Secret for Getting Successful in Your Programming Interviews!

OOAD skills can save you during interviews. Most of the programming interviews are taken by technical people.

Therefore, they will ask you question in which they themselves want to improve. Something they perceived as of higher value.

Although they don’t have the time to be good at OOAD. They only have a vague idea about how OOAD skills can be applied to gain modularity, reusability, and readability.

Therefore if you are good in OOAD then you have the advantage to shine in an interview.

Also, every good book on programming interviews has a separate section for object oriented design questions.

What are Transferable Skills?

Transferable skills are those skills which can be applied across different domains. There are specific transferable skills in the programming world.

For example, learning algorithms, estimation, problem-solving are transferable skills. These skills are not technology bound. If you are good at these skills, you can cash them out throughout your career.

OOAD is also a transferable skill and very few people focus on that. They have crafted some irrational excuses for not focusing on OOAD.

These are the people who are still using object oriented programming as a procedural/structured programming language.

Following are some excuses that people have about OOAD:

I work mostly with databases, how OOAD can help me out?

Famous databases are relational. Famous programming languages are object-oriented in nature. How can we combine these two?

You can write an additional layer to convert from relational models to object oriented model. This is called object-relational mapping(ORM).

Fortunately, there are many frameworks for all programming languages that can do ORM for you.

And if you are fluent in OOAD you will be able to learn these frameworks quickly. You can analyse the pros and cons of a framework.

You will not like a newbie who thought using frameworks is the default approach. Similar to internet newbie who believes that Facebook is ‘the internet’ 🙂

Moreover, programming languages are converging toward providing support for ORM. For example, Entity framework in .Net/C#.

Next objection:

But I am in Mobile App Development and/Or Web Development and I don’t need OOAD!

Sighhhhhhhhhh !!!!

I work in mobile app development and I don’t need any object oriented design skills!

Or I work in web development and OOAD is not necessary or important!

I use JavaScript or PHP and these are not object oriented languages!

Or I develop applications for SAP- so I don’t need OOAD!

Seriously?

You need OOAD – even if you are using the most famous web development language i.e. javascript.

MVC(model-view-controller) design pattern has brought an explosion in the world of programming and notably web programming. The World has gone crazy. Frameworks after frameworks are invented to support MVC.

Again, if you are in mobile app development – you will be writing mostly in objective C or Java. Both of them are object oriented languages. Hence, you can get an edge over others – if you believe in OOAD.

There are other excuses too. Object-orientation will make my program complex and large and I have to write more code.

One should not listen to them!

So, if you have any other concern or beliefs that OOAD is not helpful- you can share with me in comments and we can discuss that 🙂

 

]]>
https://www.linesperday.com/a-programming-skill-that-you-can-use-to-fire-your-boss/feed/ 1
Becoming a Professional Software Engineer Quickly–Even if You are a Beginner https://www.linesperday.com/becoming-a-professional-software-engineer-quickly-even-if-you-are-a-beginner/ Sun, 14 May 2017 08:00:23 +0000 http://www.linesperday.com/?p=201 I tried to develop a system. I was tired of doing small tasks.

As soon as I know the difference between a task and a project -I started dreaming about completing a project. A project is a collection of tasks resulting in a complete product.

I know that if I own a product in my company I will be able to gain benefits throughout my career. That will be my product. This will be a product attributed to me. And one day I will patent it.

Do you have such dreams?

I started imagining that people are using my product and praising me. What a dream that was!

I had experience of 1.5 years and I was thinking about, for example, building a new commercial airplane.

Naive! Hah.

I just forgot one thing. I was a damned junior with only college level knowledge. I was new. Like a toddler in the professional programming world.

I studied most of my programming knowledge in the classroom and that was of little help. I did not have any practical experience.

Moreover, our professors don’t have much practical experience. This is truer if you are in programming. Here, you will have to implement and go through the pain of being a failure. In programming, you cannot gain excellence by making programs on white board.

The real world is not like writing a 200 lines program. When the size of the software grows the complexity grows exponentially.

I believe experience triumph anything else.

In addition, most of the stuff available for programming and design is written by academics and written for academics only. Not for the people who are working in the professional life. Especially most of the academic stuff available for object oriented design is boring and complex.

Characteristics of a Real Programmer

When I started my programming career. I was impressed by senior programmers. A problem that would take months to solved, a senior can solve that within weeks.

Another thing that I observed, they write code in a way that it is easier to change later. They also employ object-oriented design principles and patterns to cope future changes They even have written their own software design patterns.

So, having characteristics of a real programmer worth it?

Once you go through the heat of being a junior – you will gain respect. You will not only speak about OOD for the sake of impressing others. But you know what you are talking about.

Once you internalize OOD principles through experience, you can apply this knowledge in any battlefield and come out as a winner.

Writing code and then managing code will not be a nightmare. You will not stretch your hairs when you change or update code.

You can easily apply patterns like MVC, decorator, and factory. You can even show your code to juniors and impress them.

Great Professional Software Engineer

Now, you can wait 5 years before writing a code like that. Or you can shortcut your success by learning fast.

It is not necessary to burn your days, weeks and years to become great. With a good strategy from the start, you can become great in 2 years.

For beginners, I asked you to focus on the following three strategies.

1) Understand the Software Development Process(Your process)

There are two situations. First, you are a part of the team. You have been assigned a task. You complete that task and submit it.

Secondly, you have been assigned a project. You have to interact with customers. Or you have to develop a sub-system of a large software product. You are a one man army.

In both cases, you have to understand the software development process.

Understanding software development process does not mean that you have to achieve CMMI level 5. Or learned a sophisticated development process like cleanroom software engineering.

A development process may be like — you just listen to the requirements and start coding. Your only documentation is your code and comments –if there are any. You report to your boss when you have completed a task or a project.

Or your development process can be like extreme programming or SCRUM.

Whatever the process you have. Just follow that. When you understand your process model then try to find out where you are weak.

If you are weak in testing your code. Focus on that. If you are weak in design then focus on that. If you are weak in eliciting requirements then focus on that. Similarly for deployment and delivery.

In this way, you will gain expertise in all areas of software engineering and you will put yourself on a ladder to greatness.

2) Small challenges

Continuously challenge yourself. Stretch yourself in the areas where you think you are weak. Or areas which are interesting to you.

For example, I was weak in socket programming. Therefore, I design a small challenge. That is sending custom data between two PCs using sockets. I complete that and write notes about that in my journal.

Then after a year, an opportunity arrived where I have to work on sockets. I accepted it and completed the task very quickly.

Hene design small challenges and complete them in your free time. You will gain a ton of new knowledge and experience.

3) Performance Review

The act of reflecting and reviewing will improve your learning. Personnel performance reviews are important.

Here I am not discussing team reviews or reviews that are asked by your boss before appraisal.

I am talking about your personal reviews. For example, I review your personal performance quarterly.In these reviews, you should reflect upon the things that you have learned during these three months.

You should be targeting at least one challenging area to be covered during that quarter of the year.During quarter reviews you can reflect upon the challenges and problems that you faced.

Based upon these reflections you can improve your productivity. You can estimate better. You can identify the critical areas in your project and streamline them early in the development.

What do you want to become in next 2 years?

The understanding of software development process, challenging yourself and reviews can help you gain valuable experience quickly.

What do you think is important to be successful as a software engineer? Let’s discuss them in comments or you can contact me.

]]>
Put a Dinosaur in Zoo https://www.linesperday.com/put-a-dinosaur-in-zoo/ https://www.linesperday.com/put-a-dinosaur-in-zoo/#comments Mon, 01 May 2017 14:07:28 +0000 http://www.linesperday.com/?p=178 If you have ever been to a zoo you will definitely want to see one animal and that is Lion. Why? It’s because a lion is the king of the jungle. It’s at the top of the food chain.

I asked questions from my parents like: “can a lion kill an elephant or crocodile or cheetah”.

Then I watch Jurassic park movie. A dinosaur can kill the lion. They were huge. They can destroy buildings as shown in movies.

What if dinosaurs are still alive! We are able to keep the ferocious animal in the zoo, like lions and tigers. We can keep the dinosaur in our control and put them in a zoo. But definitely, if alive, dinosaurs will be at the top of the food chain.

Still, there are dinosaurs in our life. We want to keep them in a zoo. They are at the top. They are our bosses. How can you keep them in your control?

I believe managing and controlling boss is part of your job. Those who knows the pleasure in controlling their boss knows what I am talking about.

It creates benefits like extra vacations. Flexible timings. Fast promotions. Learning new things on the job. And most importantly free time to explore new opportunities.

Everyone hate their bosses. Especially programmers. Your boss telling you do a lot of things in the shortest possible time. Comparing you with others.

Bosses are hard. I realise this during my first interview after graduation. The boss told me in the interview that “We are hiring you but you are a liability for first three months- since it will take three months for you to adjust in the environment learned things that we do here and the way we do things here ”.

In short, he was telling me that you will consume electricity, one PC and internet bandwidth while he was not making any money from me.

This remind me a quote from Bill Gates

“If you think your teacher is tough, wait until you get a boss. He does not have tenure”

Well, this is not brutal. The brutal thing is that your boss telling you things that are not technically possible. For example suppose your boss ask this: ”Why would a particular task takes so much time in C++ whereas the same task can be done quickly in Matlab”. What would you say?

Convincing your boss that Matlab is not equivalent to C++. Explaining that there is a huge difference between a lab work and production work. How Matlab has built-in features and etc etc. It could be a nightmare to explain.

It does not matter if your boss is technical or not

Well, so many times your boss is right if he is a tech savvy person. Or if your boss has programming experience. But it is rare that your boss knows all about your field.

Whether your boss knows about technicalities of your job or not. In all cases, it’s a nightmare to convince your boss to your way of doing things.

You are not alone

If you are thinking that you are the only person in the world who has this maniac boss. Then you are wrong. We all have such bosses. Consider yourself luckiest if your boss likes you from the start.

Now, How can you handle your boss? There are three options.

Option 1

You can confront your boss. Go direct. Deny orders and do the things your way.

In many cases, this will not work. Especially if you are a new hire, e.g less than 2 years, you can get fired.

Confronting strategy works if you are so senior that you makes yourself a requirement for your boss. You have dozens of good projects under your belt. You are invincible. Then you can confront and tell your boss to shut off.

Option 2

You can fire your boss. You can quit. Many people can say you are escaping the bad situation. Well changing the bad situation and not making a compromise is one solution to your problems.

Keep in mind your ultimate goals. Like learning, earning according to the market and free time to live your life.

If you can fulfil all of your goals through another job then there is no shame in firing a bad boss. This will even leave some bad reputation for your ex-boss. Someone who is leaving a job is also a sign of bad management.

Will you find the best boss next door? Not guaranteed. But your next boss could be little better than the previous one. If that does not work then change again-shamelessly.

Option 3

What if you can’t follow the above two options? This is a situation when you are not experienced enough to dictate your own terms or if you are easily replaceable ( it’s easy in programming world). That is your boss can fill your position in no time.

Another reason is you don’t want to get in the hassle of finding a new job. Then in order to put your boss under control, you will have to make few changes in daily routine.

Understand your boss’ needs and wants

First, you will have to understand from your boss’ perspective. Your boss may be stressed out because of his superiors. Your boss may have challenging goals to accomplish. Or your boss wanted the next promotion.

Find out your boss’ goals and priorities and then align your goals accordingly.

Address Your Boss’ Fears

If your boss does not have information about the programming language and frameworks/tools that you use. This could make your boss uncomfortable. Or more accurately fearful. Your boss maybe thinks that you are making a fool out of him or her. What you need to do is address this fear.

What you can do to address this fear: educate your boss about technologies. For example, tell him about the benefits of python over other languages. What you can accomplish with node.js or any other tool or platform that you use.

Secondly, educate him about the way you do things. Like why you choose one strategy that your boss is sceptical about. Share any research paper on that or a book reference on that strategy with your boss.

One important point to note here is that: don’t educate to ridicule your boss. Don’t educate like you are confronting him -especially in front of your colleagues. This can backfire.

Don’t hurt your boss ego because everybody wants to protect their ego in front of others. And someone at a higher level then you (like your boss) is supposed to know everything that you do.

If you highlight that your boss does not know anything about what you do. This will hurt your boss’ ego. Hence you have to educate your boss politely.

Illusion of control

Another thing that you can do to appease your boss is by giving your boss the illusion that they are in control and they are guiding the whole process.

For example, a year ago I was working on a challenging project. There were a few things in my mind that I was thinking of experimenting. One day my boss called me up for the discussion on the problem. In that meeting, he was discussing a technique that was already in my mind. I kept a note of it.

Next, I ran an experiment to test that technique. That was successful and bring me near to my objective. I reported my boss that the technique that he mentioned does help me out. Explaining in detail how that specific technique helped me in solving the problem.

In this way, I make my boss the part of the process and someone who has full control over the project. Afterwards, when I completed the project my boss appreciated me than ever before.

The flipside of the story: In that meeting, my boss also mentioned dozens of other techniques that a sane programmer would laugh to death. But I kept myself in control.

So by making your boss the part of the solution and giving the illusion of control, you can win your boss trust.

In addition to that, giving your boss the education and giving them the illusion of control can work together. When you keep your boss educating, it is possible that your boss gives you ideas in future from the same knowledge that you taught your boss earlier.

What can be wonderful then your boss telling you the things that you told earlier and guiding you the way you want to be. That is the state where you know that you have put your dinosaur in your little zoo.

No doubt that this strategy will take some time. You will have to give it time initially and reap the benefits in future.

So what is your experience? Have you faced a stressful situation with your boss on programming projects? If you are new in the professional programming you will face them.

If you have faced these challenges then tell me in the comments and what you do to get out of that situation.

I read every comment.

]]>
https://www.linesperday.com/put-a-dinosaur-in-zoo/feed/ 1
You Win And They Lose, Even Before the Competition Started https://www.linesperday.com/you-win-and-they-lose-even-before-the-competition-started/ Sun, 23 Apr 2017 10:48:05 +0000 http://www.linesperday.com/?p=170 You can get “100 out of 100 marks in the subject of Mathematics”.  This phrase was marketed to us so many times. That I internalize this term and because of that I always got 90 percent or more marks in maths.

Maths is logical. Similar to programming. You follow certain steps and the right answer is in front of you. Learn few techniques, apply them again and again and you are nearly invincible.

I practice solving maths problem every day. I became so good that I can fly through any problem given to me. These were the days of my college and my university years.

But I was not always that good.

What is deliberate practice?

Practice makes a man perfect. That was the first phrase I have heard about the importance of practice during my school education.

I bought a separate register to practice my maths problems, physics problems and occasionally chemistry problems.

In one exam, problems were different than the problems of our textbook. I was devastated and failed.

So I realized that I have to train myself for alternating situations. For example, when I was solving a problem during my practice- I stopped during a step and think about if the examiner just changes this parameter or that parameter then how would I solve it- and then try to solve it.

In short, I tried to anticipate the problems.

During a preparation for a competition, I anticipate a question from a textbook (After completing all the exercise questions) and that single question made me the winner.

This is called the deliberate practice.

Hence deliberate practice is something that prepares you to win the real exam by anticipating what could go wrong and then preparing for that in advance.

In the next section, I will discuss what are some good practices for deliberate practice in programming.

Why should you practice?

Some people said that real-time situation is more important than practice. They argued, for example, 1 hour in a real situation worth 100 hours of a practice session.

What makes the real situation different than the practice session? I can think of the following. If you come with another parameter then mention that in the comments.

The real situation is time bounded. A soccer game is 120 minutes at max. Exams are time bounded. During practice,  you have unlimited time at your end to solve a given problem.

Another parameter is the reward. You will not get an ‘F’ if you failed to solve a problem during your practice session.

In the real-world situation, people are looking at you. If you failed people will make fun of you. They will not see your efforts but they will focus on your results. Hence real-time situations are public and practice sessions are private.

The real-world situation gives us unknown scenarios. You cannot anticipate each and everything.

Another thing is the opportunity. You get 1 exam every semester. You have one final for becoming a world champion in 4 years.

I believe these are some of the parameters that make a real situation more valuable. Now if you can simulate these parameters you can get best results from your practice sessions.

With advance preparation, you will be calm when you see a diversion or real-life situation. And I believe you will succeed and breeze through any stressful situation.

In the next section, I will discuss how can you simulate these parameters.

Time boundness

In any real situation, you are bounded by time limits. For example, if your boss gives you a task and ask you how much time will it take and you replied: “infinite”. You are fired!

In college years, I choose a set of problem and try to solve them in the 80% of the time available. If the exam is about 1 hour then in my practice session I will 50 minutes.

I hardly achieved these timings but during the exam, they provide me extra time to deal with any emergencies.

Hence, simulating time conditions is easy. And if you practice by deliberately reducing the time to solve a problem you will get better results in the real situation.

Reward

You can give yourself a small reward or punishment to train yourself.

In building habits, reward and punishment have key roles. In real situation reward is clear. During an exam, the reward is the result. During your work, it could be a successful contract, sale, promotion and not be getting fired.

I believe that our brain is wired to feel the sensation of reward in the same place if we are getting a salary raise or eat an ice-cream. Definitely, there is a scale of happiness in different reward. But having a small reward will work the same way as a big reward.

Hence keeping in view this knowledge, you can simulate this carrot and stick mentality in your deliberate practice. You can simulate this situation by giving yourself a small reward after each successful practice session. This can be ice-cream, coffee, a movie or anything else that makes you happy.

Vulnerability

This is the area where I am so weak. But this is an important one. We are a social animal and we need social acceptance. In real-life situations, everybody is watching us. We are like gladiators, fighting for our life during an exam.

The audience is your parents, classmates, relatives, teachers and friends. That’s quite an audience.

How to simulate this? Frankly speaking, I haven’t figured it out yet. Group studies can help if they are designed properly. In a group, you have to prove your worth. You have to play your role otherwise you will be alienated. Hence a group can force you to work hard to meet the group’s higher standards.

I tried group studies but I usually end up in not getting any positive result.

The only benefit that I get from group studies is how to teach others. Hence when choosing people in groups make sure that everybody can perform and few people in the group are above your level.

In programming, you can choose online quizzes. They give rewards which are displayed publicly. There are dedicated arenas for beginners and experienced programmers. You can hone your skills through these competitions.

Unknown situations

If you want to be great in your field you have to swim in uncharted territories. Challenge yourselves regularly. And if you have to do it regularly for years you will be great. According to Gladwell and Cal Newport, you have to spend 10000 hours in your field and you have to continuously stretch yourself to be so good that nobody can ignore you.

Unknown situation and new situations are those where your brain started to feel pain. Like if you are programming using Java for years, you should immediately start using Python or JavaScript or any other programming language.

The major obstacle will be your brain telling you not do this and slowly guiding you into procrastination like watching movies or playing video games. Our brain resists change. It want’s to live in places with minimal discomfort.

Our brain knows that growth lies in change but somehow it tries to avoid the pain associated with growth. Hence watch for this pain and program yourself to accept it.

Opportunity

Can you simulate the opportunity? No, you cannot. That’s what I believe.

Practice and preparation are required to perform well when an opportunity is in front of us. For example, in an exam, if you are a student you have one shot. All of your advance preparation will help you during your exam.

If you are a programmer, then it could be a challenging task in your office that will put you up for promotion. It could be a new job offer with bigger salary or a new client to deal with if you own a business.

A quote that I have learned earlier is: “Luck is when the preparation meets the opportunity”.

So be prepared and wait for the opportunity!

Or expand your outreach to hunt for opportunities. You cannot simulate opportunity but you cannot just wait for the luck to open new doors for you. You can actively look for new opportunities.

What opportunities can you look for? One great opportunity is to work with open source projects where you work for free but on your own terms. For example, you can choose the technology you want to work in. You will get new connections, new experience, better jobs and eventually better opportunities.

Another opportunity is starting a side business. For example, be a freelancer and sell your services at UpWork, Elance and Fiverr. This can also open a new gate of opportunities for you.

NEXT

So, what do you think about deliberate practice? How do you hone your skills in the programming world? Share in comments.

I read every comment.

]]>