2019 Road Map

2018 has almost already been in the book. I have had a wonderful year. Instead of spending time writing about it, I decide to spend time recalling it, and write a road map for 2019. The past is in a good care by the memory. The future must be written.

The road map will drive my time and energy. It also helps me make better decisions. If anything is against the road map, it is easy to say NO.

The road map is for my professional career. For my human career, the road map is always the same: be a good husband, a good dad, and a good self.

Project Management Professional (PMP)

I read about it 6 years ago. I did not understand a single word in the material. After spending 10+ years building software and running teams and the company, It is time to get it right again. I found it much easier this time.

Start with an PMP book from Head First, then a series of courses on the Pluralsight. I always love books from Head First.

Domain Driven Design (DDD), Refactoring, and Performance

The more I write code, the more value DDD I recognize, and the less I know about DDD. The last part, the less I know about DDD, is important. It tells me that I started to understand it.

DDD is not just about code, not just about writing code. A proper understanding of DDD will increase design skill, business analysis skill. When it combines with Event Storming, the power is unlimited.

The second edition Refactoring – Martin Fowler has come out. I read the first edition 10 years ago. It has helped me writing a better code for 10+ years. The second edition is definitely in my studying list this year.

DDD and Refactoring are universal and never obsoleted.

Building a running software is easy. Making it fast and stable is a different story. By paying attention to the performance, it drives me to study careful about threading, memory, performance pattern, scaling pattern, …

Active Sharing

Sharing is learning. Giving is receiving. I will active offer my help in LinkedIn. If I am lucky, I can help someone.

That’s it! I am ready to welcome the year 2019.

Code Readability – Method Parameters Tell The Scope and Dependencies

Writing code is hard. Writing human readable code is much harder. One of the contributing factor is that it depends on who read the code. Each developer has a different background, experiences, coding style, and even how their mind is wired up.

I do not believe there is a code that readable for every developer (because when talking about code, we prefer to developers). However, there is code that improves readability over time for the development team. It is hard for an external developer to understand the code just by looking at some files or pull requests. Context really matters.

This post is purely my point of view in term of code readability. That’s said the code that I consider as readability. There are many factors contributing on the readability. The method parameters is one of them. Let’s walk through some example code.

Let’s build a piece of code that stimulates the job applicant CV verification. The detail does not matter.

When verifying an applicant, there are 2 piece of information: ApplicantCv and Special Notes. Some candidates might get a direct introduction from the top managers.

And the consumer code

The interesting part is at the Verifying method of the SeniorPosition and JuniorPosition. The JuniorPosition passes the execution to a private implementation, whereas the Senior does not. 

Let’s follow the code from the consumer side, the Program class. A list of applicants wrapped in VerificationContext. Each context has 2 important information: SpecialNotes and ApplicantCv.

The next level is the HrDepartment. All it does is simply passing the context to all implementations of IVerifyingByPosition, SeniorPosition and JuniorPosition. The HrDepartment depends on the VerificationContext. That is the information that it is going to use to do the work, the logic of verifying applicants.

The next level is the implementation of IVerifyingByPosition. The JuniorPosition.Verifying method consumes the VerificationContext. However, it delegates the logic to a private method which take only ApplicantCv. The scope is narrowed down from VerificationContext to ApplicantCv. By having that private method, I know for sure that the JuniorPosition depends only on the ApplicantCv, not the entire VerificationContext.

Why is that important? Imagine that later the VerificationContext is expanded with more properties. If there are many code in JuniorPosition, we have to read the code to know what information is using.

It sounds confusing and not obvious. The rule is very simple, a method should take just enough information, all parameters should be used. That is easy to understand. But what we do not pay attention to is the properties in objects passed in the parameter list. In the example that is the JuniorPosition uses VerificationContext in the method signature. But its implementation only uses a property in the context – the ApplicantCv.

When reading code, I usually pay attention to what information it consumes and depends on. Usually they are reflected via constructor or method’s parameters. The code should be refactored to gain that obvious dependencies for free.

Another factor in the code readability is the proper use of instance vs static. If a method can be made static, it should be declared with static. Why? Because by static, we know for sure that it does not depend on any instance fields. The dependency is narrowed to a smaller scope.

What else could we do? Method visibility is an important factor as well. A public method means it is being used by other consumers. A private method is safer to refactor.

Code readability is important and it is hard to get it right. However, with some small tips and care, we can do it better over the time. The readability also takes into account the human factor. The one who write the code and the one who read the code. They are human. They communicate via code.