Developers Give “If Condition” a Name

Hey, you have been writing software for 10+ years. Can you give me advice, tips to improve my skills?

What if someone asks me that question?

I can go on and on with many things. And finally, they will be confused and lost. What if I have to give only one advice?

I will say

Improve your naming

I once wrote the naming matters. Today, I give another small tip on naming

Give your “if condition” a name

Let take a very simple code

public int CalculateFee(Customer customer)
{
    if (DateTime.Now.Subtract(customer.RegisterAt) > TimeSpan.FromDays(30))
    {
        return 100;
    }
    return 200;
}

The condition is, “If a customer has registered for more than 30 days, charge 100 (assume it is USD). Otherwise, it costs 200.

What is the big problem with that code? The problem arises when other developers read the code. He does not speak the same language as when you wrote it. He will, mostly, read the code with the C# language syntax and try to figure out the logic.

An “if condition” is a business logic. Therefore, it should be named properly.

Now, let refactor code and give it a name.

        public int CalculateFee(Customer customer)
        {
            if (CustomerRegisteredFor30Days(customer))
            {
                return 100;
            }
            return 200;
        }

        private static bool CustomerRegisteredFor30Days(Customer customer)
        {
            return DateTime.Now.Subtract(customer.RegisterAt) > TimeSpan.FromDays(30);
        }

Think about multiple operators condition. You will see a big benefit.

 

There is a huge number of conditions in every codebase. If you write a new “if condition” or you see them in your current codebase, give them a favor

An “if” is a business logic, give it a name. If you cannot name it, you do not understand it.

Other developers will thank you for that.

A small action but big impact.

Developers How To Be More Valuable

Developers love challenges, technologies, cool stuff. They are very creative. I heard people ask

  1. How to become a better developer?
  2. What technologies should I learn?
  3. What languages should I learn?
  4. ….

The questions go on and on. But, Yes. Always there is a “but”.

Are they the right questions to ask?

Everything only makes sense in its own context. So the post: Developers who are hired by companies to develop business software.

Broken Light Story

Mary has a broken light in her house. She calls a John come to fix the light. John fixes the broken light quickly. The job is done. He gets paid. However, Mary is not really satisfied. Because, John, while fixing the light, dropped dust on the floor. Mary has to clean it up.

Oops, again, the another light is broke. However, this time, she decides to try to reach Steve. Steve comes and fixes the light. Before claiming the job done, Steve cleans up the floor, he also does some check up on the other lights in Mary’s house. It costs Mary the same price as using John’s service.

Can you guess who will get more clients? Of course, that is Steve. Steve is more valuable than John.

So, what is the difference?

The same task, different delivery quality.

Oh! A nice story! But I am a developer. What is in it for me?

Yes. My friends, we can apply the same philosophy to increase our value. Remember this?

You get paid for the value you bring to the marketplace.

Our value is determined by

The quality of our deliveries define our value, not the tasks.

Developers’ Clients

Have you ever thought of who are developer’s clients? What? Do they have clients?

Yes. Yes. And Yes. There are.

Whoever use their deliveries are their clients.

QA/Tester

At daily basis, developers implement user stories, fix bugs. QA/Tester will verify their deliveries.

Code Reviewer

Given that a company has a code review process. Code reviewer is developer direct client.

Leader/Manager

Of course, they are your clients.

Other Developers

You are not alone in a project. Some other developers will use your code. They consume your API.

There might be more clients. You get the point.

A Better Question

What should I do to increase my value to my colleagues, my company?

Some might think of solving challenging tasks, implementing cool stuff. Yes. They are true. However, there are not so many challenging tasks in a company. Let’s take the “80/20” rule. There are 20% of challenging tasks.

You have to find ways to take advantages of 80% left to increase your value.

Increase Your Value

Here are some tips that can help you, developers, increase your value.

Comment Your Deliveries

These days we all use tools (Jira, Targetprocess, Trello, …) to manage projects. Your tasks are presented as Cards (User Story Card, Bug Card, Task Card). Each card has a powerful feature for communication: Comment.

You should take advantages of the comment feature.

User Story/Task

Usually, you should write

  1. Question: To communicate with the card owner or other developers in the team. There is another skill you need to learn here: How to write a good question?
  2. Technical Design: Write whatever you think they are valuable.
  3. Solution: So other can know what you have done to finish the job.

Bug

Usually, you should write

  1. Question: To clarify the bug.
  2. Done result: This is a crucial part. When you fix a bug, you should write in detail

How to write a “bug fixed” comment? There are at least 3 parts.

  1. Root Cause: What is the root cause of the bug.
  2. Solution: How you solve the problem. The more detail the better.
  3. Test result: Prove that you have tested your fix.

Think Before Code

I am serious. Here is what had happened to me many times.

  1. I got a bug to fix.
  2. I located the place that bug occurred.
  3. I added my code to the existing code.
  4. Compiled and tested just my scenario.
  5. QA claimed my bug passed. And congratulated me that there was a new bug. Guess what? Most of the time, it was me creating a regression bug.

The dangerous thing is fixing a small bug causes a critical bug.

Ask these questions before code

  1. How can I fix the bug without modifying existing code?
  2. If I have to modify, what are side effects? How many affected places I can think of?
  3. Do I understand the logic of the code I touch? At least at the method level, you should understand its logic.

Lesson Learned

You cannot grow if you cannot learn anything after each task. There is no silver bullet for learning. Each must find their own way. What you can do is to set your mindset.

After each task, you can ask yourself this question:

Hey! What do I learn from completing this task?

And you must be serious.

 

In conclusion, with the context of a company, being a software developer looking for ways to increase income (oh yeah cash, money), you should ask a better question.

As a software developer for 10+ years, I would like to offer you a new question

What should I do to increase my value to my colleagues, my company?

And 3 tips to increase your value

  1. Comment your deliveries
  2. Think before code
  3. Lesson learned

It is Lunar New Year. If you are looking for improvements, changes, those tips might be a good start.

Happy Lunar New Year! and Have Fun!

Oh New Year, Again! Let’s Make Wishes

New year alway comes. I guarantee you. Welcome to another Lunar New Year. Everyone makes wishes. They wish for themselves, for their family, for their relatives. Everyone has good intention.

Yes! I do. I make wishes every new year. Actually, some years ago, I had made vows. Kind of

  1. I vowed I will quite smoking
  2. I vowed I will drink less
  3. I vowed I will save money
  4. I vowed
  5. …….

I just forgot one important vow:

I vow I will make the same vows again, next new year

I am not saying that process is good or bad. I just wonder why I did that again and again. I know some people do the same thing.

So, let’s explore some theories behind this question

Why do people make vows every new year?

No Cost

You do not have to pay anything for your wishes/vows. And if you do not say it out loud, you are safe. No one knows.

Feel Better

Oh God, It is TET (our Vietnamese name for Lunar New Year). TET is the time for parties with beer, food, hanging around with friends. I might feel better if I make some promises to myself. Kind of, Well, it is ok to relax. I will be a better person after TET.

Make up for a Bad Year

Sometimes, I screw up with the current year. And there is a feeling of “nothing can be done this year”. I just let it go and make a promise for the next.

Screw up and Wish for a better one without taking any action. That’s kind of thing!

High Emotion

People are happy when TET (except some special circumstances). Happy people make promises. They believe in a bright future.

Think about your childhood, if you want to ask parents for money, you know when to ask. Of course, when they are happy 🙂

What happens after TET?

—————–>

Nothing happens! Period.

People come back to their real life. Fight for a living. Have some more parties. … And then finally they realize:

Oh Shit! TET is coming. There is no time for me in this year.

The cycle begins.

Ok. Enough talking! What should we do instead?

This year (2017), I decided to do

  1. Have a list of small things to do.
  2. Make a small plan for them
  3. Start them immediately (Write this post is a part of the actions). Take action!
  4. Have a good time in TET with beer, food, visit parents, relatives, friends, …
  5. Back to work immediately after TET.

My friends, maybe it is the time for you to reconsider what you have been doing for years. No matter what actions you take, they are yours. And you are always right with your decisions.

Everything has its cost.

The cost of a wish is the time.

Happy Lunar New Year! Beer Up.

Welcome to the That Fundamentals

Recently I have created website: That Fundamentals that I will focus most of my writing. Currently the site is under construction. It is more of experience of trying new thing. And it will become the main portal of mine.

what happens to this blog? Well, nothing, It will be running as it is since it is free. Later on I might category the content that should post in this blog or That Fundamentals Blog. The main purpose of my writing is to experience and improve my skill. Therefore, i will not limit myself to anything.

I have a busy period at work the last couple of months. Stay tuned, More will come 🙂

Value and output

For the past of 1-2 years, my life philosophy has changed. Let’s forget about the past of how i was. I will  focus on the present and the future I want to be:

VALUE and OUTPUT

Let’s talk about VALUE. It came from this valuable statement of Jim Rohn:

We get paid for bringing value to the market place

Jim Rohn quote

Everyone has his/her own value. And that value is evaluated by the market you are in. In my field, it is IT industry. Why do I talk about value here and now? Well, there are some:

  1. Because, I want to remind myself about “VALUE”. Therefore I am always aware of improving my value if I want to get more.
  2. Because, VALUE is the only thing you should put in the table when discussing your opportunity and your price.
  3. Because, you should give your price base on your VALUE.
  4. Because, you should NOT give your price base on your age. You are not get paid for your age or for your being old. NO NO, it does not work like that
  5. Because, I want to help people around me aware of the term “VALUE” and help them improve their VALUES.

For more, I suggest you listen to this life changing video

How about “OUTPUT”? What is it about? It is about your delivery:

Deliver result

I usually tell people that about my theory of this:

  1. You think you know 100 things
  2. When ask you to TALK about them, you can express using your speaking language 60-70 things out of 100
  3. When ask you to WRITE about them, you can write just about 30-40 out of 100
  4. When ask you to DO, you can do around 10 out of 100
  5. And you might DELIVER 1-3 out of 10 done

And many people I know (just the one i know, i do not speak in general) stop at step #1 and they think they have that value. Here is the phase:

I think I am good and I deserve better

And here is what I (will) reply:

OK. Wonderful, can you show me your delivery (output)?

Well, most of the cases, you know the result of the conversation.

So, my friends, if you are in such a conversation, make sure next time you will: Hey wait a minute, here are my deliveries 🙂 And you have a strong evidences on the table for the deal/discussion.

Have a nice weekend 🙂