Saturday, 12 July 2014

Solid Code

Solid Tank

How do you write code?

No, I’m not talking about how you name your variables/functions. Or if you put your braces on the same line as the if statement or below it. I am asking about the thought process you have when you write a class or implement a feature in your software. Do you,

  1. Write code to meet the current requirements exactly, maybe even hard-coding values that you are sure won’t change in the current implementation and then throwing out everything you just did to accommodate changes in the requirements?
  2. Strive to follow standards but still end up having to make a lot of changes to your code-base when requirements change?
  3. Only make a few minor changes to meet the changed requirements?

I’m sure everyone wants to be in the third group and this post is aimed at them. If you already fall into the third group, this post may not offer anything more for you but do read along and offer your comments about it.

So, eliminating code change, is that even possible? Well, you can’t really eliminate the need to make code changes, what you can do is to minimize the impact a change request can have on your code base.
How can we minimize code change? Let me introduce you to the answer to this problem, the SOLID Principles.
The SOLID principles were established in the 2000s in the field of software engineering as a way of writing code that can stand the test of time and the winds of change. They are currently well established and is a proven way of structuring your code. The name is an acronym of the 5 principles that form its base they are

--
Single ResponsibilityA class or function should do one thing and do it well
Open/ClosedA class should be open for extension but closed for modification
Liskov SubstitutionAny subclass should be able to replace to the instances of its parent class in a program
Interface SegregationDifferent behavior should be separated into different interfaces
Dependency InversionHigher level classes should be ignorant of the implementation details of the lower level classes and instead rely on abstractions

I encourage you to read the Wikipedia entries I have linked above. A word of warning though, it can get complicated. At least it was for me when I started off, but don’t worry I am here to help. I’ll be running a series of posts here, on the SOLID principles. We can tackle those principles together, with code samples too. If you have anything to add, sound off in the comments. Now subscribe to this blog and check back as the posts become available.

Written with StackEdit

Saturday, 28 June 2014

Excellent Time to be an Android Developer



So, Google I/O just ended and here are the things Google announced
  1. Android L for your phones and tablets (some OEMs will also put it in laptop and hybrid form factors)
  2. Android Wear for your smartwatch
  3. Android TV for your TVs or set-top boxes
  4. Android Auto for your car
  5. Android apps on Chrome OS
They even showed a roadmap for the evolution of their platform at around 47 minutes and 43 seconds in the Google IO 2014 Keynote

It shows everything mentioned above plus one more: home. Yes, Android@Home is still alive and kicking. Here is a recent interview of Sundar Pichai from WIRED in which Pichai said Google is committed to supporting a smart connected home from an Android standpoint and he will have more to talk about their efforts later this year.

I believe you can see where I am going with this. Android is going to be everywhere, Android development is going to be huge and good Android developers are going to be in great demand. More great news included the fact that Android now has 1 billion active users per 30 days, 1 BILLION!!! thats 1/7th of the people in the world. Android based tablets accounted for 64% of the total global shipments and 46% of YouTube views in the past 30 days. When you consider the Android One that was announced, a line of phones with standardised hardware along with software direct from Google costing less than $100 for the developing markets and bringing the rest of the world online, you can tell that the market of Android is going to explode.

So if you are an Android developer or have ideas for an app for phones, tablets, smart-watches, TVs or cars, start developing. You have a huge market to exploit.