Book Review: How to Win Friends and Influence People

Being a good software engineer is primarily about knowing the fundamentals of computer science, being able to model your problem domain and represent it in a succinct computational format. It is also about being able to control growing complexity of the software systems you maintain by following good architectural patterns and breaking down your representational models into well define modules with well defined responsibilities. But, it isn’t any less about communication, about clearly conveying your thoughts, and all-together being able to play good with other people. This latter goal is usually ignored though, and not much focus is given to it during early phases of one’s career or during your academics. But sooner or later, you will realise that to be an effective software developer, it is essential to be able to communicate well, and play well with other people, be it your colleagues, customers, subordinates, managers, or even your friends and family.

Communication isn’t an exact science though. It involves paying careful attention to context and human emotions. As such, there is no guaranteed way of how to effectively communicate in all situations, however, with practice, and with right mindset, you can get very good at it and achieve better results each time. One such helpful resource on getting good with handling people is Dale Carnegie’s classic book “How to Win Friends and Influence People”.


The book is divided into four parts, each focusing on an important part of effective communication.

Part 1: Fundamental Techniques in Handling people

This part talks about three fundamental principles to follow when engaging with people.

  1. Do not criticise, condemn or complain: If you have to bring someone’s attention to their shortcomings, do it in an indirect way, by telling them how they can bring about much improvement in something by changing just a little.
  2. Give honest and sincere appreciation: If you find someone doing a good job, don’t hold back on an honest appreciation. People like to feel important and appreciation goes a long way in feeding that well-deserved emotion. Used effectively, this makes people wanting do do even better.
  3. Arouse in other person an eager want: If you want someone to do something for you, show them how it can benefit them as well. Once they have their own want involved, they would be much more willing to give you what you desire.

Part 2: Six ways to make people like you

  1. Become genuinely interested in other people: Find something about others that you find intriguing, and let them tell you about it, while you listen with genuine interest.
  2. Smile: Being around happy people makes you happy. By smiling more, you give others the same feeling. They would want to be around you more if you give away happy smiles than scary frowns.
  3. Use a person’s name: Each person’s name is the most sweet sound to them. By using a person’s name well, you can give them a feeling of importance, and get their focused attention.
  4. Be a good listener: Communicating isn’t only about talking. In fact, it is less about that. It is more about being an effective listener.
  5. Talk in term’s of other person’s interests: It is ok what you want, but others’ won’t be interested in giving you what you want unless you also mention what they want. Asking for what you want, by talking about others’ interests, works more effectively.
  6. Make the other person feel important: The lesson is re-itereated. Your main goal of effective communication is to make the opponent feel important. If you make them feel important, they will be much more willing to cooperate than otherwise.

Part 3: Win people to your way of thinking

  1. Avoid arguments: If you win an argument, you lose the other person’s interest and possibly respect. So there is no real win in an argument. Best route is to avoid it.
  2. Show respect: Don’t discard others’ opinion even if you think they are wrong.
  3. If you are wrong, admit it: There is no pride in being wrong and being stubborn about it.
  4. Begin in a friendly way: Even if you are genuinely angry at someone, beginning to converse in a friendly way will take you to your desired affect much faster.
  5. Get the other person saying ‘yes yes’ to you quickly: Begin your conversation with questions that the other person won’t disagree with. Starting with agreement will be more helpful in achieving an agreement on the conclusion.
  6. Let the other person do more of the talking: You don’t have to sell your point beyond an agreement. Your goal should be to reach an agreement, not to win in count of words.
  7. Let the other person feel the ideas are his/hers: Instead of pitching the ideas as if they are coming from you and they have to agree with it, pitch it as if the ideas are theirs and you are agreeing to it.
  8. Honestly try to see others’ perspective: Changing the lens can help wonders happen at times.
  9. Be sympathetic: Don’t crush others’ ideas and opinions.
  10. Appeal to nobler motives: Everyone wants to do good. Try appealing to the good in others.
  11. Dramatise your ideas: Underplaying your ideas doesn’t give it any strength. Pitching your ideas in a dramatic way could help harness more attention.
  12. Throw down a challenge: If all else fails, appealing to the taking up a challenge inducing notion of human mind can help.

Part 4: Be an effective leader

  1. Begin with praise and appreciation: Never forget that everyone wants to be important, and feel important.
  2. Call attention to mistakes indirectly: Do not criticise in harsh ways.
  3. Talk about your own mistakes first: Be a human to others, tell them you too have made mistakes. This helps you be more relatable, and helps others see themselves as open for and willing to improve more.
  4. Ask questions instead of giving direct orders: No one likes taking orders, even if they are willing to put up with them. Pitching what you want as questions could make others not only give you what you want, but also make them feel happy about it.
  5. Let the other person save face: Do not shame someone publicly for their mistakes. Give them a chance to save their face.
  6. Praise improvements lavishly: It will induce the want in people to improve even further.
  7. Give others a fine reputation to live up to: If you give them a good reputation, they will try their best to live up to it.
  8. Make the fault seem easy to correct: Because if you make it seem difficult to correct, why would they try?
  9. Make others feel happy about doing what you suggest: Everyone wants importance, happiness, and doing good. Give them that, and they will give you what you want.


The book doesn’t give you a silver bullet to be an effective communicator. But it helps you develop the right framework and mindset to help you see yourself becoming better at handling people. Having the right mindset can go a great deal towards becoming an expert conversationalist and people manager.


Heap implementation in Swift

Hello everyone,

As you can see, I haven’t been blogging for more than three years. That is a long time. But  I had my reasons. A lot has happened in both my personal, and professional life that kept me too busy and sparing little time to focus on blogging. However, I think it is time to start writing again. I like to write about technical topics. So I restart my blogging by kicking it off with this small post, and small snippet of code.

I love the heap data structure. It is a nifty little DS that maintains items in an order, giving you O(1) access to the min/max item, and pops/inserts new items in O(lgN) time. The same structure is used to implement a priority queue, which has uses in many places, e.g. Dijkstra algorithm. So keeping with my habit of implementing a known data structure in short period of free time, I give you a quick implementation of heap written in Swift. Let me know what you think of it, or if you find any problems in it.

Thank you for checking out my blog. I would love to hear from you in the comments section. And lets hope I come up with good content for you to read in the future.

Book Review: Effective Objective-C 2.0 by Matt Galloway

I love reading technical books. They provide you with a broader picture on a topic and go in depth on different issues that online tutorials just simply skim. That’s why each month I pick up a book related to the platforms I work with. My last month’s pick was “Effective Objective-C 2.0” by Matt Galloway. It was an enlightening read, so I thought I would share a review with my blog readers.


If you are like me, you picked Objective-C as a language while learning iOS development. I have over the years picked and improved my know-how of the language that is Objective-C, while being a full time iOS developer. The problem with learning Obj-C as you learn iOS development is that you are for the most part learning only higher level Cocoa (Touch) APIs and hardly get to see the efficient implementation behind these APIs on the language level. Thus I think it is important to set aside sometime, give Cocoa a break, and play with Obj-C language itself and get to know how it works under the hood, many of the new improvements it has to offer since 2.0 version, and some of the new ways the new Apple compiler, LLVM, has improved on it.

“Effective Objective-C 2.0” provides you with a clear path to knowing your programming language. It is divided into 52 items touching different parts of the language, divided into seven chapters.

Chapter 1: Accustoming Yourself to Objective-C

A simple start to the book, introducing you to Objective-C’s roots, how headers import work and how to effectively use it. Also touches on literal syntax, macros, and enumerations.

Chapter 2: Objects, Messaging, and the Runtime

Many newcomers to the language will go a long way working with Cocoa touch without realising that Objective-C has a very powerful runtime whose power can be harnessed to perform many useful tricks. This chapter talks about properties, objects equality, associating custom data to existing classes during runtime, talks about objc_msgSend and how message forwarding works. It also touches upon the very powerful Obj-C runtime feature of method swizzling.

Chapter 3: Interface and API Design

This chapter talks about how to properly implement your classes with clear and useful interfaces.

Chapter 4: Protocols and Categories

Protocols and Categories are prevalent throughout the Cocoa framework. This chapter talks about effectively using categories to provide additional functionality on top of your classes.

Chapter 5: Memory Management

Many people think that after introduction of ARC, studying memory management on iOS is not important. Nothing can be far from the truth. Understanding how memory management works on the platform is essential to understanding how ARC works and to avoid some of the gotchas ARC can have if you don’t understand how to avoid retain cycles even when ARC is enabled.

Chapter 6: Blocks and Grand Central Dispatch

One of the modern features of Obj-C are Blocks. This chapter talks about how to effectively use blocks. It also talks about the C API to handle concurrency on platform namely GCD and compares it to Operation Queues. It talks about how one can use GCD to allow thread synchronisation, instead of the @synthesize construct that most of us are used to.

Chapter 7: The System Frameworks

Last chapter talks about features provided in system frameworks and when should they be preferred. For example using block enumerations to for loops, using toll free bridging for memory management, using NSCache instead of NSDictionary to avail caching etc.


This is a great book to have read. It will certainly make you more aware of what goes under the hood when you use any of the system libraries, and put you in a better position to write better classes of your own and debug like a pro.

UIView bounds vs. frame

New comers to iOS development usually get confused by a UIView having two different properties to represent its position and size. Namely ‘bounds’ and ‘frame’. Surprisingly, many senior iOS devs can’t explain in clear terms the difference between the two either. So I thought I would try to explain in simpler words the difference between the two.

UIView — An infinite sheet:

An instance of UIView always has a height, and a width. But to clearly understand the difference between bounds and frame, we first need to revisit our visualisation of a UIView instance. Think of a UIView as an infinite sheet, that is divided into four quadrants, just like a cartesian coordinate plane. However, a regular cartesian coordinate plane has its y-axes increasing towards the top. While our UIView plane’s y-axes increases downwards, and has negative values upwards. Just like a regular cartesian plane, our UIView plane has its centre at point (0, 0).

Even though a UIView can be thought of as infinite sheet, and we can add subviews to it anywhere in this infinite space, we only get to see a finite section of this infinite sheet at a given time. And this is where bounds and frame come into play.


Bounds define a finite window into the infinite sheet of UIView. At any given time, we only see the contents of the view that lie within the bounds of this view. Any content that is part of the view, but lying outside the bounds won’t appear (or would appear if it is within the bounds of the superview and view doesn’t have its clipsToBounds set to YES, but won’t receive touches). If we change the position and size of bounds to move to another portion of the infinite sheet of view, content at that location would start to appear.

Thus, bounds is a window into an infinite sheet of content that is UIView.


Frame is the location and size of a UIView instance within its superview. Thus if we don’t change frame, but change bounds, view would show different contents, but at the same location within the superview. If we change frame, and keep bounds the same, view would show the same content but at a different location within the superview.

Remember that frame and bounds have same size values, but their origin values can differ.


Bounds is view’s location and size within its own coordinate system. Frame is views location and size within superview’s coordinate system.


SKHeap; A quick MaxHeap and HeapSort implementation

Heap is an interesting data structure. It is a binary tree, that keeps the maximum (in case of MaxHeap) element at the root, thus providing access to it in O(1) i.e. constant time. You can pop the root element in O(lgN) time, and insert new elements into the heap in O(lgN) time as well. Initial buildup of the heap takes linear time. You can sort a sequence of elements using heap, by first building the heap out of all the elements, and then retrieve the elements back. Since initial build up is linear time, each retrieval of the maximum element is O(lgN) time, and you do N such retrievals, the resulting sorting algorithm is of O(NlgN) complexity and called HeapSort.

It is fun to implement these well known data structures and algorithms. So while I was bored and free for half an hour, I quickly wrote a basic implementation of a Heap and HeapSort in Objective-C and pushed it to Github. Check it out and let me know if you like it or find any issues with it.

Topcoder SRM 584; A late correct solution is better than a quick but wrong one

This was an interesting SRM. I solved both easy and medium lightening fast, and moved on to solve the hard one. I understood the hard problem, but just couldn’t come up with a generic solution. So mid way into the problem, I decided to look back at the medium problem to confirm I didn’t miss any corner case. I tested it with a tricky case that I came up with while I was devising the algorithm, but hadn’t tested my solution on after I passed example test cases. Guess what!? It failed!! Bummer. I quickly looked through my solution to cater for this tricky case and resubmitted. That reduced my score for the problem to half of my first submission. But it did save me from a completely failed solution. ;)

DIV2 Medium; Egalitarianism:

If there are any two people in the kingdom that aren’t connected either directly or through some friends, answer is -1. Reason is, there aren’t any limitations imposed between the difference of these two people, and their difference can be arbitrarily large or small.

In the other case, every citizen is connected to every other citizen either directly or through other friends. In such a case, we need to find the maximum friendship distance between any two people, and multiply that with “d”, as that will be the maximum possible difference between their wealth.

We can use Floyd-Warshall algorithm for finding out minimum distance between any two citizens, and then chose the maximum out of these minimum. If maximum is equal to infinity, it means there are two people not connected, so return -1. Otherwise return maximum*d.

A corner case to check for though is that we must not consider a connection to self. If there is a loop in the graph, this loop can have the maximum distance, but we are looking for maximum wealth difference between two different people. This is the case my first implementation missed. Though I did use it in the challenge phase to get +75 points. :)

DIV2 Easy; TopFox:

We can easily generate all possible handles as the constraints are low, and figure out the count of unique ones.


I am back to division 1. Cool!

Topcoder SRM 583; Depressing

I can safely say I knew correct solutions to all of the three problems in this SRM. I solved easy problem lightening fast. Medium was an implementation problem, with quite a few corner cases, but nothing too tricky. It took me a good amount of time, so that I had little time for hard problem. I knew hard problem was finding maximum cost from each point, to any other point, and returning minimum of it. But I couldn’t implement it in time.

That’s not it though. My medium failed. With one of the most stupidest mistakes ever. I was indexing an array of mine with an input that was 1-indexed, while my array was 0-indexed. All I had to do was to subtract 1 from the input before passing it to array as an index, and my solution passes. :(

DIV2-Easy; SwappingDigits:

All we need to do is swap digits at each pair of indices into the string, and see if it produces minimum integer with no leading 0.

DIV2-Medium; IDNumberVerification:

An implementation problem. Check that each part of the ID is valid, and then return gender of the person.


Sad SRM. But meh! Happens.