Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Saturday, February 18, 2017

Tech Humor - A Programmer's Revenge, Deal With Frustration At Work

Hello, this is bit different blog post. Usually I write blogs on very serious stuff like solving coding issues and about technologies and careers and about latest trends on IT industries etc. Now I feel that my blog is becoming very serious so I decided to write some blogs on lighter notes. Now you will read about funny things happened while working on projects some practical jokes on programming and all. I short I am going to add bit humor on my blog. In this first post I am going explain how I took revenge on end users of my projects.



A Programmer's Revenge


A programmer is a person who is working all days long in front of computers. He has to deal with all kind of annoying stuff like funny and impractical demands of customers, anger of his boss, anger of tester, humiliation from boss and team leaders or may be from co workers. A programmer deals everyday with these and more of the other things like.

  • Sudden change in requirements
  • Rewrite entire code again
  • Work rejected by client or team leaders
  • Do extra work without any rewards
  • No credit on successful completion
  • Tight deadlines or change in deadlines
  • No help from co workers of leaders
  • No motivation from boss and team leads
So in short a programmer is always in frustration most of the times and eager to take revenge but can't do that as he is afraid of loosing job or cut pay  etc. So here are some funny ways you can take out your frustration and nobody will notice it and still you will have some kind of satisfaction that you took revenge of all the humiliations, frustrations, disappointments etc.


Add Some Funny Comments and Lines in Code


This is the most hidden way to take out your frustration as no one els is going to look at source code except you and your team. Most of the time client is not going to see the source code so they will not read comments. Here are some example of comments I have used while I was working on projects to take out my frustration.

//Function : Name of Function
//Author : Hiren Dave
//Description : Use it at your own risk. Do not come to me crying if it crashes

Exception exp = new Exception("Some idiot entered wrong data");
throw exp;

if(!isNan(maxSalary)){
      //God has given brain to all human but some idiots still enter wrong data so we have to check.
       alert('Invalid Salary.');
       return;
}

//What's in the name? Yes everything is in name. It is necessary.

//I can't take it anymore I am exhausted, will fix it later.

//I just don't know why I am writing this code. It's unnecessary but it's part of my job so doing it.

So yes these are some comments I used over the time to take out my frustrations and took my revenge. You can also try this, it will surely help you to manage with your anger and frustration.

Play Shooting And Fighting Games


This is the other way I took out my frustration. Whenever I am frustrated and angry I play shooting and fighting games and squash the opponents in games to release anger and took my revenge virtually in games. Games really help in this matter as you are just hurting virtual characters in games. Here are some games I play for sometime to take out my frustration.

Whack Your Boss
Desert Rifle
Street Fights


These ways you can took your revenge and can deal with frustrations. Hope this helps you.

Friday, February 17, 2017

Top 3 Tips of Effective Google Search For Developers

This blog post is for the developers who are stuck in some errors and not able to solve it and looking for solutions on Google but not able to find it because they are not searching it properly. So here in this blog I am going to explain some tips which I have been using over the period of time and most of the time I am able to get solution through Google and solve my problem.



Tip 1 : Use Error Codes to Search


Most of the time whenever there is exception or errors, there is an error code displayed in the error stack trace. Use that error code to search on Google and use the ClassName or component name which is throwing this error with type of error. For example Android MediaRecorder. When you are using media recorder there are error codes attached with each action and each stage of MediaRecorder. For example

Android MediaRecorder start failed - 38
Android MediaRecorder start failed - 19

When you search in Google with the error.  Android MediaRecorder start failed - 38, you will get following links.


As you can see in above screenshot there is top links of popular website StackOverFlow where others have posted this question and there will be solution here so your problem is solved.

Another example in windows whenever there is problem with drivers of any hardware it gives code 28 errors. So to search in Google use following

Windows error code 28

And you will get number of blog post to solve this error.

Tip 2 : Use Name of Exception To Search, Do not Copy paste whole stack trace


Whenever there is an exception in program, you will get stack trace where it shows all the classes and files and number of line from where exception is thrown. Do not copy paste that stack track in Google Search. Use first line of Stack trace, which is normally type of exception. For example, in android app is some class is not found at runtime it throws ClassNotFound exception. So to solve that error, search in Google 

Android ClassNotFound "ClassName"

And it will give you relevant links where there will be solution for this. So your error can be solved easily.

Tip 3 : Be Specific for What you Want to Search and Use Keywords


Be as specific as possible in your search query so Google can search relevant links for you. For example, if you want to hide element with JavaScript. If you give search

Hide element

It will give you links with hiding element using CSS and JavaScript and jQuery and Angular and all. But if you want specific result with say jQuery or JavaScript, use that key word in your search result.

Hide element jQuery
Hide element JavaScript

Then it will give you relevant links with exactly what you are looking for. Same way for anything else use key words. For example if you are looking for tutorials to start with. Use search like

Laravel Getting Started
Android quick start
Angular quick start etc. Because most of the bloggers who write blogs on Getting started, they use titles like Getting started, quick start etc. You will get what you want on the first page of Google.

Hope this helps you.

Thursday, January 12, 2017

Don't get Trapped In Code Refactoring

This blog is coming out of discussion with one of my old client. I worked with him for almost 5 months in year 2010, that is 6 years ago. We build a nice hybrid mobile app. Recently we had a talk about a new product. During our conversation I came to know that for one of his other product he hired a developer and it took almost year to build a product which was originally estimated for 3 months.  That was bit surprising for me so we discussed more about it. Client said, the developer took most of the time in changing the code so many times, however output was the same and there was no functionalities changes . So immediately I understand, developer refactored code so many times Client asked me is it necessary to change the for the things so many times which are already working?  Well yes that's the important question, at what level refactoring is good?

For the readers who are not aware of refactoring, here is some information about code refactoring. 

"Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behaviour. Refactoring improves nonfunctional attributes of the software. Advantages include improved code readability and reduced complexity; these can improve source-code maintainability and create a more expressive internal architecture or object model to improve extensibility. Typically, refactoring applies a series of standardised basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that either preserves the behaviour of the software, or at least does not modify its conformance to functional requirements. Many development environments provide automated support for performing the mechanical aspects of these basic refactorings. If done extremely well, code refactoring may also resolve hidden, dormant, or undiscovered computer bugs or vulnerabilities in the system by simplifying the underlying logic and eliminating unnecessary levels of complexity. If done poorly it may fail the requirement that external functionality not be changed, introduce new bugs, or both."

Since I started working as a software developer, code refactoring always confuses me. Every time I refactor a code, I am not sure if I am doing it right or wrong. 


In my frank opinion I also believe in refactoring in code and make it more simpler to amend future changes easily and to make it more understandable by others. Code refactoring is good, but my confusion is at what level and how many times? 

I still remember my team lead when I was working as a software engineer, My team lead always come to me and there is always one instruction, "Hiren, reactor your code" and I do reactor code by all means and make it more reusable.  But at certain point I think it's useless, the code is already in good condition, why should I make it more complicated? Is it really necessary? 

There are two output of code refactoring, either it will make code better or it will make it worse. Worse to the level that it will introduce many bugs and only option then you will have is to rewrite code. And why shall we make such complex code that nobody can understand and it's not necessary when things are working fine. Code refactoring is not going to change output, yes it may improve performance, but it will be at some level, beyond that no matter what you do, performance will remain same. So it does not make any sense to refactor the code. Its waste of time and money. Yes unless you want no one to understand your code, you can make it complex by refactoring it many times. This way you will have patent of your code and nobody will be able to change it. But this does not make any sense when you are working in team. Code refactoring is sometime end less, you just keep on refactoring the code and you will never finish the project.

So in my opinion, code refactoring is good at certain level, not beyond that. Don't get trapped in refactoring. 

Tuesday, June 3, 2014

Introduction to Swift - the latest programming language from Apple

So Apple stunned all the developers around the globe by introducing new language instead of new iPhones, iPhones or iWatches. Let's see what exactly is the Swift.



Apple says the following about the release of Swift:

"Swift is a powerful new programming language for iOS and OS X® that makes it easier than ever for developers to create incredible apps. Designed for Cocoa® and Cocoa Touch®, Swift combines the performance and efficiency of compiled languages with the simplicity and interactivity of popular scripting languages. By design, Swift helps developers write safer and more reliable code by eliminating entire categories of common programming errors, and coexists with Objective-C® code, so developers can easily integrate Swift into their existing apps. Xcode® Playgrounds make writing Swift code incredibly interactive by instantly displaying the output of Swift code."

Swift code can live right besides C and Objective-C code in the same app. The syntax is quite similar to JavaScript. Here are some of the features of it.


  • Closures (similar to blocks in C and Objective-C) unified with function pointers
  • Tuples and multiple return values
  • Generics
  • Fast and concise iteration over a range or collection
  • Structs that support methods, extensions, protocols.
  • Functional programming patterns, e.g.: map and filter

Here is the first lesson of Swift. How to define a variable and a constant. Constants and variables must be defined before they are used. You can define constants with let keyword and variable with var keyword. For example

let maximumLoginAttemptsAllowed = 10
var currentLoginAttempt = 0

So here is a constant maximumLoginAttemptsAllowed which has a value 10 and a variable currentLoginAttempt which has value 0.