Farewell 2017 Welcome 2018 Win the Year by Plan

2017 comes to the end. Regardless of what we have done, we have spent 1 year. It has gone completely. You never ever get back a year called 2017. At this time of the year, people start thinking about vacation, about parties, about salary bonus. And then we welcome 2018 and spend it just like 2017. For many, live goes on in that pattern without their acknowledgement, without their awareness. Each has their own unique way of spending their time. And everyone is right.

What if we try something slightly different? I remember Jim Rohn once said

Do not spend a day until you see it finished

Do not spend a week until you see it finished

Do not spend a month until you see it finished

Do not spend a year until you see it finished

It means that you should plan the year before jumping into it. The highest abstract level is that you should have a plan, you should have goals. And because it is so abstract, it is hard to implement. In a good/bad mood, human being will promise many things. I remember I made so many promises every year in the past. Why? Because I fucked up the year. I had to make something to feel better. Guess what happened? I made the same promises every year. Fortunately I realized that fact and changed.

Have you ever asked yourselves?

  1. What do I want to accomplish?
  2. What do I want to improve?
  3. Hey what are my plans, my goals?

If not yet, I suggest you should start from this year. The process will not take you much time. However, it requires your honesty and courage.

I hope you have some free hours with paper and pencil.

What Have I Done Well?

To plan for the future, you have to reflect the past. Many seem to focus on “not good or bad” things when they reflect the past. I would suggest you do the opposite. Thinking about your accomplishments, even small ones, give you more energy. No matter how bad a year is, there are always something we did good. All you need to do is to bring them back from your memory. When you list them out, you can say

Hey, not bad. Looks what I have done well.

Do not find the bad things. Because you will find many. Everyone does. Everyone has good time and bad time.

Write them down. Write them down. And write them down.

What Do I Want to Improve?

It is time to think about the future. Think about your goals, about your desire. Regardless of how you done in 2017, 2018 comes with the fresh air.

Some choose to take on the bad things in 2017 and improve in 2018. I do not think it is a good idea. You cannot change the past. In stead of dragging the bad things along into a year fresh year, why not start over again? Just list out what the hell you want in life and go for them from the ground up.

Setting goals is an art. There are many articles you can read on the internet. But be careful! Because you might be overwhelmed by the amount of information, the steps, the advices. The result is that you might not know how to start.

I would suggest the goals should be specific. Forget about S.M.A.R.T goals. Let’s say you want to improve your health. It is too general. What if you set this goals, by the end of 2018

  1. Run 10KM in 1 hour
  2. Do 50 pushup.

That’s it! How are you planning to accomplish that? That is for another day of planning. You will figure out the methods when you progress towards the goals.

If you do that, you know how 2018 looks like when it finishes.

 

Is that easy? Yes and No. Because

It is easy to do. It is also easy NOT to do.

When I talked about the idea with some people, they told me.

  • Yeah! you’re right. I will do it when ….
  • You are not in my position.
  • I am fine with my life

All kinds of reactions, they are all right. However, the end results are different. What you get tomorrow depends on what you decide today.

What if my suggestions bring you some good result in 2018? Who knows! Unless you give it a try.

Your time, your life, your decisions!

Thank you for your time reading my blog.

Farewell 2017! Welcome 2018!

Time Management Decode

In a meeting, my team brought up the subject Time Management. People have been talking about time management for years. It is so easy to search on the internet. There are millions of articles. Sometimes many people look for answers, but they tend to forget to ask the right questions. What do you want to manage regarding time? Why do you need to do that?

I do not have neither questions nor answers. I do have my opinions in the topic instead. Hope they will give you some ideas to ponder.

You Cannot Manage Time

Everyone has exactly 24h a day. You cannot ask for more and accept less. No matter what you do, how you do, at the midnight, your day is over. It is just that simple. Time is up, over. You are done with your day.

I wish I had more time” Good luck! It is called naive. The universe laws say that

  1. The day ends at the midnight
  2. The week ends at the Sunday midnight
  3. The month ends when the last day finishes
  4. The life ends at the last breath.

There is nothing we can do. We should, well, just accept and embrace the facts. Once I realized that I stopped fighting internally about my lack of time. Instead, I focus my energy to find better ways of using time. Time is my own asset. Here they are, my views in the time topic.

Awareness

I spent a day without a single thought. Sometimes when it was over, I said “Thanks God! It is over.” I spent my most invaluable asset and I wished It was over. That was so stupid.

For the last couple of years, I have changed my mindset. Everyday I wake up, usually at 5:00 except I am hung over, the first thing I do is saying “Thank you, I have another day to spend. I will make the most out of it“. However, It was not easy, but I managed to follow. The more I speak to myself, the more awareness of the time I enforce.

We all have good days and bad days. When we have a bad day, we wish it is over. Please stop wishing that. We all have bad days. Some have more. Other have less. Raising the awareness will give us a better look at your day. You might look at your bad days differently. Why? Because you know that you have spent your most valuable asset. Therefore it is a good idea to reflect the result.

Respect

Respect time means a minute is valuable as a hour or a day. I often heard people saying

  • Let’s wait for 15 minutes. I will do it after 15 minutes.
  • Just 10 minutes left, I cannot do anything. Usually, it is 8:50 and you have to go out or do other task at 9:00. You have 10 minutes in between. And you just wish it slice.

During a day, there are so many time blocks, they can be 5 minutes, 10 minutes, even 30 minutes. Have we ever paid attention to them? Have we ever wondered how to use them, how to utilize them? No. Many people might not even know they exist. Tim Urban has excellent post about time block. You can define your own block in the way that makes sense to you.

Thinking in term of time block, we can explain why people feel lacking of time and struggle to find ways to manage it. The feel of lacking time comes from the fact that end the end of a day, you feel that nothing has been done. You accomplish nothing. And that when you blame for the lack of time.

When I asked someone what they have accomplished in the last 6 months. They said they wanted to learn/do many things. But they have not had enough time. That excuse has been used by millions of people over centuries. Please stop using it. Let’s someone else use it but not you.

Everyday we are often interrupted by unplanned things, by unexpected people. It is the reality. Let’s face it. Which means there are many small time blocks created. Look another way, that also means that you have many time blocks available at your disposal. On this view, you have more power on your time. Instead of struggling with time, you simply look for ways to make the best out of your available time blocks.

 

What should one do with their time blocks? I do not know. It depends on their interests, their purposes. But I can tell you what I have done with my available time blocks. I am writing this post in my available time blocks. I do not have a full block of hours to write the post. But I do have many small blocks of 10 or 20 minutes.

Here are things I usually do with my time blocks

Reading

I have work, have family. I cannot request a full day just to read books. I do not have any planned time to read books. Instead, I buy a Kindle, paper books. I always bring my Kindle, sometimes including some paper books. I read them when I am waiting in the car, when I am on taxi, when I am on Uber. I read whenever I have a block of 10 minutes. If I do not know how long I have to wait, I just read.

Learning

I prepared for PSM1 exam mostly in those time blocks. I made sure the materials are ready and easy to reach. Within 10 minutes you have learned a lot. It is much harder to learn in hours, but it is rather easy to learn something in 10 or 30 minutes.

I wrote this post in many small time blocks. Writing and blogging are good ways to learn.

Meditation

This subject is rather new to me. Sometimes, I spend 5-minute block to breath, or simply a quite moment to think.

The other time, I do yoga or Tai-Chi. I just need to learn some movements that allow me to perform within 5 to 10 minutes.

 

There are hundreds of things we can do with our time blocks. What you will do with your time is more important than how much time you have. Instead of waiting for the right time, or asking for more time, try to look at time in this way

  1. Time is your most valuable asset.
  2. View a day as blocks of minutes. Either 5, 10 or 30 minutes is up to you.
  3. Be aware that you have those blocks available at your disposal. No one can take it from you.
  4. Respect those time blocks.
  5. And design a plan to use them best.

So, instead of asking how to manage time, maybe better to ask what do I want to do in a block of 10 minutes? Or what can I do in a block of 10 minutes? By the end of the day, you realize that you have done many things. And you will feel good.

Have a good weekend!

PSM1 My First Certification Since University

At 5:30 AM December 13th, 2017 I decided to take the PSM1 exam. I passed with 95% corrected answers. Such a big moment! Thái Anh Đức at Scrum.org. And there is a story behind my decision.

The Story

I was introduced to Agile/Scrum back in 2009. And I hated it, especially the Daily Scrum (sometimes called Daily Standup Meeting) with the 3 questions being asked every day. I even called them the three stupid questions. I still hold that opinion to now. Since then I read from here and there about Scrum. There are some notion of Scrum-Like in the organizations I’ve worked with. I also attended some Agile events. I still have not felt better about Scrum. I thought Scrum is just a theory and it does not work. I hold that bias for years and that bias blocks me from learning.

Recently, I realized that I had not studied enough into the subject. I was not serious about it. There are good reasons for Scrum to be popular as it is today. Why don’t I figure it out? Why do I block myself from that? Once I made that decision, the next challenge was how. How do I hold that idea seriously? I know the normal trap that people have when they need to do something. Usually, we tend to make a big promise to ourselves. However, just a few days later we come up with excuses for not doing it. That was when I decided to take the exam.

Taking exam is a way to ensure that I am not joking with myself, that I am serious.

 

Before taking the exam, I heard people saying that those exams have no value. They are just a matter of remembering questions, practicing the answers, … and you get the certification. Really? “Is that simple?” I thought. By now, I confirm that it is not easy. Here is my journey.

The Journey

I started with downloading the official Scrum Guide. I printed it and carefully studied it 3 times. I did not just read over it. I studied it with my pencil at hand, took notes, picked out the important information. Do not fall in the trap of skimming it and think you understand it. Some might be able to do that. Many of us do not. Be realistic! After studying the Scrum Guide, I read some books suggested by the Scrum Org. At the same time, I checked out some courses on the Pluralsight. Once I felt a bit confident with my knowledge, I went to the next step.

Then I have to find a way to test my knowledge and get feedbacks. I found these links

http://mlapshin.com/index.php/psm-quiz/learning-mode/

https://www.thescrummaster.co.uk/professional-scrum-master-i-psm-i-practice-assessment

https://www.scrum.org/open-assessments/scrum-open

I took one and did the test. I failed miserably 🙁 That was the moment of truth. The test result put you exactly where you should be. Embrace it. I came back to the Scrum Guide and continued my study.

The nice thing about those tests are they give you answers with an explanation. Mostly they pick out the part in the Scrum Guide to backup the answer.

If you take the tests from all the above links, you will notice that they have different formats. Which means that you cannot remember the questions and answers. And the fact that there are too many to put into our short term brain memory.

After a few days of studying and practicing, I started to understand the Scrum. My testing scores were improving. And soon I completed 100% with half of the time. I kept studying and practicing for another week. I do not just want the certification. I want knowledge. And I was afraid of failing the test.

The Day

The day has come. I had to make a decision – Take the exam. PSM1 is about the basic knowledge of Scrum. I cannot keep learning the basic forever. The only way to verify my knowledge and get feedback is taking the exam. Either pass or fail, I will know where I am standing. Took a deep breath, I did 2 important steps

  1. Order the exam from Scrum.org.
  2. Create an item in my TODO list to take the exam tomorrow at 5:30 AM.

They are very important. Otherwise, I will find a good excuse to delay. As planned, with a bit of nervous, a bit of thrill, I checked the network connection to make sure I had a good stable one, I started doing my test. Once I click the button, there is no way back. The clock starts counting.

Even I did well in my open tests, the real test was a challenge.

  1. Most of the questions are not the same as you did in the open tests. Some might have the same idea with different expressions. That requires you to read and understand the questions and answers carefully.
  2. Time moves so fast. Make sure to keep a good balance between the time left and the questions. You should soon hit the speed of 1 question per minute. When I finished all 80 questions, there was 7 minutes left. I had very little time to
  3. Review all bookmarked questions. If you are unsure about a question, you can bookmark it.
  4. The test takes 60 minutes. Focus is also a challenge. That’s why I chose to start at 5:30 AM.

Mission Accomplished! I finally got it done!

Oh Congratulations! where am I standing in the Agile/Scrum buzzword? Basic, sirs! I know the basic of Scrum and have a good starting point for the next level.

That’s it!

Small Victory But Important

I cannot remember when. But recently I often say “You can do it does not mean you should do it.” Yet it is much easier to say than do. And life has its unique way to challenge your principles.

I have read some programming books for the past 10 years. None of them were paid. It is so easy to get a free download of them on the internet. If you need any book, you can search for a free downloadable PDF version. Boom! you have it. I do not judge it is right or wrong. However, I know it was wrong. I should have ordered them properly.

I have started my personal development journey for the past 3 years. I have been reading books on that subject. I have made some a progress overall. I ordered services instead of finding hacked versions. Until recently, I want to read the book Microservices Sam Newman. The old habit kicked off. In less than 5 minutes, I found a free downloadable version. And I downloaded. I started to read it. I have the book.

But! Hey, something was wrong. I should buy the book and enjoy the reading. Hmm, I already had it. And no-one knows that I got it for free. The internal fight began. I kept reading some more pages. The more I read the worse I felt.

Damn it! It was wrong Đức. Respect your own principles. And with the courage, I did what I was supposed to do. I went to Amazon and ordered it immediately. I won the fight.

This small victory is essential. It makes me smile and pride.

You can do it does not mean you should do it.” Check again with your integrity, your principles.

Leaky Abstraction – Linq Usage

I am not sure how many percents of developers are thinking about Leaky Abstraction when coding, especially coding in OOP umbrella. Me? Not much since recently. I do not know why. I just simply did not think about it. Common trends are that we, as developers, focus on the new technologies, design pattern, best practices, … all those cool and fancy stuff. Many developers build great things without knowing that concept. I understood that. However, what if we know it, we might build a better product with fewer bugs and easy to maintain. When I actually understand it, I feel smarter. Let’s see what I am talking about.

First, check it out from these trusted resources. If you are a developer, there is a high chance that you know those sources.

Wikipedia

Joel on Software

Coding Horror

Recent years, I improved my skill via Pluralsight The courses from Zoran Horvat have changed the way I think about programming, the way I think about OOP. At the same time, I have many code base that I have been working on for years. When I looked at the code and compared to what I have learned, there is a big gap. The problem was that I did not know how to close that gap. I was kind of stuck in my own thinking.

With time, I started to understand them deeply. And then I started to make small changes in a stable, safe way. Let’s start the journey.

 

Let’s assume that we have a School and many Teachers. And at the end of an education year, the school has to give statistic about

  1. How many teachers does it have?
  2. How many mathematics teachers?
  3. How many of them have been in the school for more than 10 years?

They are very basic requirements. Without any hesitation, one can come up with this code. It works perfectly as required.

   public class School
    {
        public string Name { get; set; }
        public IList<Teacher> Teachers { get; set; }
    }

    public class Teacher
    {
        public string Name { get; set; }
        public string Specialty { get; set; }
        public DateTime StartedOn { get; set; }
        public bool IsStillAtWork { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var school = new School
            {
                Name = "Gotham City"
            };
            school.Teachers.Add(new Teacher
            {
                Name = "Batman",
                Specialty = "Mathematics",
                StartedOn = DateTime.Now.AddYears(-11),
                IsStillAtWork = true
            });
            school.Teachers.Add(new Teacher
            {
                Name = "Joker",
                Specialty = "Chemical",
                StartedOn = DateTime.Now.AddYears(-6),
                IsStillAtWork = false
            });
            Console.WriteLine("Total teachers: {0}", school.Teachers.Count(x => x.IsStillAtWork));
            Console.WriteLine("Mathematics teachers are: {0}", 
                string.Join("; ", school.Teachers
                                        .Where(x => x.Specialty== "Mathematics")
                                        .Select(x => x.Name)));
            Console.WriteLine("> 10 years teachers are: {0}",
                string.Join("; ", school.Teachers
                                        .Where(x => DateTime.Now >= x.StartedOn.AddYears(10))
                                        .Select(x => x.Name)));
        }
    }

How many issues can you find in the above code? The total teacher count only counts the IsStillAtWork. However, the next 2 statements do not. Once identified, a developer can go in and fix the code easily: by adding one more condition for each where statement. A short-revised version

            Console.WriteLine("Total teachers: {0}", school.Teachers.Count(x => x.IsStillAtWork));
            Console.WriteLine("Mathematics teachers are: {0}", 
                string.Join("; ", school.Teachers
                                        .Where(x => x.Specialty== "Mathematics" && x.IsStillAtWork)
                                        .Select(x => x.Name)));
            Console.WriteLine("> 10 years teachers are: {0}",
                string.Join("; ", school.Teachers
                                        .Where(x => DateTime.Now >= x.StartedOn.AddYears(10) && x.IsStillAtWork)
                                        .Select(x => x.Name)));

So far so good! Where is the problem? where is the “Leaky Abstraction”?

 

Let’s distinguish the consumer and the domain. The “Program” class is the consumer. The School and Teacher are the domain. For those simple requirements, the consumer has to know too much about the domain knowledge which should be captured by the domain itself.

  • The consumer has to know how to filter teachers that are at work.
  • The consumer has to know how to decide a teacher is a mathematics.
  • The consumer has to know how to decide a teacher is at work for a long time.

What if we have many consumers over the School class? Then each consumer has to know that knowledge and makes its own implementation. Here we have a real problem of Leaky Abstraction at the simplest level of using Linq to filter data. We also have the duplication issue. The logic is duplicated. If the domain has only one consumer, that code is fine. It does what it is expected to do. In many applications, it is not the case, unfortunately.

It is really hard to have a code without leaky abstraction. It is kind of an impossible mission. What we should do is to aware of the situation, weigh the pros and cons of fixing them.

 

So what are possible solutions? The goal is to capture the logic inside the domain.

Solution 1: We could move the logic into the School class as below

   public class School
    {
        public string Name { get; set; }
        public IList<Teacher> Teachers { get; set; }

        public int CountTeacherAtWork()
        {
            return Teachers.Count(x => x.IsStillAtWork);
        }

        public IEnumerable<Teacher> MathematicsTeachers()
        {
            return Teachers.Where(x => x.Specialty == "Mathematics" && x.IsStillAtWork);
        }

        public IEnumerable<Teacher> ExperiencedTeachers()
        {
           return Teachers.Where(x => DateTime.Now >= x.StartedOn.AddYears(10) && x.IsStillAtWork);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var school = new School
            {
                Name = "Gotham City"
            };
            school.Teachers.Add(new Teacher
            {
                Name = "Batman",
                Specialty = "Mathematics",
                StartedOn = DateTime.Now.AddYears(-11),
                IsStillAtWork = true
            });
            school.Teachers.Add(new Teacher
            {
                Name = "Joker",
                Specialty = "Chemical",
                StartedOn = DateTime.Now.AddYears(-6),
                IsStillAtWork = false
            });
            Console.WriteLine("Total teachers: {0}", school.CountTeacherAtWork());
            Console.WriteLine("Mathematics teachers are: {0}", 
                string.Join("; ", school.MathematicsTeachers()
                                        .Select(x => x.Name)));
            Console.WriteLine("> 10 years teachers are: {0}",
                string.Join("; ", school.ExperiencedTeachers()
                                        .Select(x => x.Name)));
        }
    }

The logic is captured in 3 methods: CountTeacherAtWork, MathematicsTeachers, and ExperiencedTeachers. So far so good! Any consumer can consume the API without worrying the logic. And we also solve the duplication issue.

But that solution has some issues

  1. The number of methods in School class will explode.
  2. Do we forget to check if Teachers list is null? Are we sure that we have a valid Teacher list?
  3. When adding new methods operating on the Teacher list, some might forget the add the IsStillAtWork condition.

Just name a few. In my opinion, the second issue is the worst.

Solution 2: Capture logic in a Collection class

It is a better solution. Instead of thinking about school and teacher, what if we think of “Collection of Teachers“? So at any point in time, instead of working with a single Teacher, we work with a collection of teachers. Sometimes, the collection might be empty or 1 item.

In OOP, when there is logic, they should be captured inside objects. Let’s another version, where the logic is captured in an object.

    public class TeacherCollection
    {
        private readonly IList<Teacher> _teachers = new List<Teacher>();

        public TeacherCollection(IEnumerable<Teacher> teachers)
        {
            if (teachers != null)
                _teachers = teachers.Where(x => x.IsStillAtWork).ToList();
        }

        public TeacherCollection WhereTeachMathematics()
        {
            return new TeacherCollection(_teachers.Where(x => x.Specialty == "Mathematics"));
        }

        public TeacherCollection WhereExperienced()
        {
            return new TeacherCollection(_teachers.Where(x => DateTime.Now >= x.StartedOn.AddYears(10)));
        }

        public int Count
        {
            get { return _teachers.Count; }
        }

        public IEnumerable<Teacher> AsEnumerable
        {
            get { return _teachers.AsEnumerable(); }
        }
    }

    public class School
    {
     
        public string Name { get; set; }
        public IList<Teacher> Teachers { get; set; }

        public TeacherCollection TeacherCollection
        {
            get
            {
                return new TeacherCollection(Teachers);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var school = new School
            {
                Name = "Gotham City"
            };
            school.Teachers.Add(new Teacher
            {
                Name = "Batman",
                Specialty = "Mathematics",
                StartedOn = DateTime.Now.AddYears(-11),
                IsStillAtWork = true
            });
            school.Teachers.Add(new Teacher
            {
                Name = "Joker",
                Specialty = "Chemical",
                StartedOn = DateTime.Now.AddYears(-6),
                IsStillAtWork = false
            });
            Console.WriteLine("Total teachers: {0}", school.TeacherCollection.Count);
            Console.WriteLine("Mathematics teachers are: {0}", 
                string.Join("; ", school.TeacherCollection
                                        .WhereTeachMathematics()
                                        .AsEnumerable
                                        .Select(x => x.Name)));
            Console.WriteLine("> 10 years teachers are: {0}",
                string.Join("; ", school.TeacherCollection
                                        .WhereExperienced()
                                        .AsEnumerable
                                        .Select(x => x.Name)));
        }
    }

By introducing the TeacherCollection object, we can handle the query side of the object. As the requirement arises, the number of “Where” clauses also increase. That is a challenge and we must keep an eye on the design and modify when necessary. Regardless of the problems might arise with the new design, we gain these benefits

  1. The collection object is completed. We do not have to check for the state of the object. The inner collection is always not null.
  2. This is a perfect example of the “Map-Reduce” pattern. Where the “Where” is the reduce. By introducing a number of proper “Where”, we can capture the logic and chain the condition to the final collection that we want. It is also easy to create a Map function which allows us to transform to the collection object.
  3. Immutable. Each “Where” will result in a new collection object. Because the collection object is designed to support the query side of the operation, it is crucial to keep in mind that you must not add methods that will change the internal state of the collection object.
  4. Improve readability. The better naming the better readability!

Hmm, where is the command side? How to modify the teachers? The command operations should belong to the main domain object. That is the School class. I still keep the Teachers property for that purpose. I know it is not a good design when exposing the Teachers property for that purpose. But it is there to demonstrate the point. In production code, I would design a better solution to deal with command operations. It is out of the scope of this post.

 

Wow, that is cool! We should go in and fix all the places in our current codebase. No! No! and No! Blindly apply anything will cause more damages than benefits. Linq is a powerful tool and we use it everywhere in the code. Our main problem is that we have not asked the right question. “Is it the right place to use Linq? Should we wrap the logic somewhere?” those are wonderful questions to ask whenever we code.

Ok, then what do I take from here? what should I do? I have a few suggestions

  1. Take a moment and understand the leaky abstraction. Try to map it with a real-life example. The textbook is hard to understand.
  2. Look at your current codebase. Find a place where you think there is a possibility of the leaky abstraction. Hints: Find the Linq usage, or properties of type List, Collection or Enumerable.
  3. To find out if your classes have Leaky Abstraction issue, try to see from the Consumer point of view.
  4. Evaluate the pros and cons. Simply consider is It worth the effort or not?
  5. Make one small change at a time.

It is a journey. Good things take time. Using the same approach, we can find more leaky abstraction in other areas of our code.

Thank you for your time. I hope you can take some and apply to your daily job.