Code coverage in .net core apps

It was good but not great YET cos I aim for 100%

As developer, we are fully responsible to deliver the quality code and a good coverage of the source code is, in my opinion, a good indicator how well the business logic is covered with tests.

Since .net core 1.0, I have been searching for a good nudges package for my MS Tests and xUnit Tests but unfortunately, there was none. The question of how I could ensure the code I wrote is well tested was actually nagging me for a while. Just to clarify, there are actually add-ins for VS2017 from JetBrains that could be a good candidate for the job but I was a bit hesitated to invest on them as it’s not for commercial purpose. I mainly explored on .net core on my own interest and the love of .NET cross platform framework.

Fortunately, since March 2018, the coverlet.msbuild was being released and it did it job well. Shayne Boyer blogged about it here and so did Scott in his own blog. It was pretty a big things and I am feeling lucky being part of the community.

Without further delay, I created a POC repository to illustrate the capability of the coverage. The link to my git hub can be found here.

Just a quick summary on my POC of coverlet.msbuild and a few tricks to get it works on the ‘legacy’ projects

Note 1: the latest version of coverlet (2.6.0) is not compatible .NET.Test.sdk and xUnit, hence it’s tricky to figure out which version is backward compatible. Example of those are working fine:

Stable working versions

Note 2: I enable Coverage Gutters so that I can see the highlighted on the source code with tests coverage. It is VS Code extensions. Coverage Gutters will look for specific file format of lcov hence when running test, the coverage should be outputted into that lcov format. I used following command to achieve it

dotnet test /p:CollectCoverage=true
/p:CoverletOutputFormat=lcov
/p:CoverletOutput= ../my.tests/lcov

Note 3: I use dotnet watch on the test project during the development so that any change on the source code as well as the tests will trigger the test run automatically. It helps on ensure small incremental change is made. I used following command to do the watch

dotnet watch –project .\my_test_project\ test
/p:CollectCoverage=true
/p:CoverletOutputFormat=lcov
/p:CoverletOutput=../my.tests/lcov

Hope it be helpful for those whom love clean quality code.

Until we meet again, happy coding.

Best regards,
Mike Nguyen

What I learned from being a runner

If you have followed my blog posted you may have noticed that I was quite active in running since 2018. In previous years, I was more interested in endurance sports like cycling and swimming, but not running. Why? Because, running was, for me, difficult, hard to enjoy (because initially there will be no rhythm) and sweats the hell lot our of me. So, in such a rare occasion, I ran and usually it was a hard one that made my feet sore for a couple of days.

Fast forward a little bit, after literally being active running for almost a year now, I believe that I have crossed the plateau and it brought me a grateful feelings of whenever I run. Because running now is my rewards for being good. I even make it be more exciting by labeling my runs: morning grateful run, evening reflective run, long-lasting endured run, and so on.

My accomplishments so far:

  1. Sep 18: finished 35K solo birthday run and 20K Leg 3 Kings of The Trails (KOTT)
  2. Oct 18: finished 50K MSIG trail ultra
  3. Nov 18: finished 25K Leg 4 Kings of The Trals (KOTT)
  4. Dec 18: finished first road marathon 42K (5 hr 40′) Standard Charter Marathon Singapore (SCMS)
  5. Jan 19: finished 70K ultra trails Vietnamese Trail Marathon (VTM)

So, how did I overcome the hardship of running you may ask. Alright, I could immediately tell you a secret of mine is that I choose running as one of my identity: I am a runner and running healthy and frequent is what a runner does. It keeps me motivated; pushes me through the sore, the sweat, the fatigue, the boredom, the solitude; and helps me find gratefulness, peace, meaning, hope, and enthusiasm. Once, the identity is set with clarity, I integrate it as part of my daily routine, it means I run every day at a fixed time. Then I turn it into daily habit just like we are brushing teeth before going to bed or watching our face after waking up. It is one of the thousands of atomic habits that make up of my daily routines. Things gets more excited when I could even combine running with other spiritual activity like gratefulness, reflection, thinking of future, reminding myself of who I am and what I am standing for etc.

Just a quick summary of three step process I used :

  1. Make running as one of my identity
  2. Make it to be an atomic habit and integrate into my daily routine
  3. Combine with other activity to get the remarkable compound benefits

In term of learning, it’s reading, doing and experiencing that give me the good perspective of the approach that best suits me. And I would suggest you do the same. Why ? Because only you could know what you are standing for and make up of in term of mental, physical or mind and body. Taking in other suggestions and opinions is great but you need to filter it, rationale it and create your own context surrounding it to make your own sense of it. I used to ask question closely related to other experience: e.g. what do you feel when you enter a race, how do you pace it, what do you used as main food through out, what do you feel and experience when you hit the low points, how do you motivate to by pass it. The answers will give me a deeper understanding of someone experiences that I could use to rationale with his training to formulate my own way of experience it in my mind. Occasionally, you could even prevent fault assumptions of those saying but never doing one.

PS: I know what I am sharing here is a bit abstract, but I would like to create a good framework of doing things for you first rather than jumping directly into the factual that I already rationale and you make not understand the process I used. It is my maxim of teaching a man how to fish rather than giving him one.

If you have read up to this point, thank you and you should be very curious on the factual tips. I promise to give you very useful tips and tricks that I learnt so far. But in this introductory post, I would like to limit to the context of being run well and healthy only. For the race preparation and racing itself, I am still learning and fine-tune my craft hence yet be able to share.

Here you go the tips of running well: strong, long and grateful:

Tips 1: focus on heart rate (HR) training run.

You can use formulate (180 – your_age – 5 (if you don’t run more than 3 times per week)) as max HR for any of your run. For example, I am 35 years old and I ran more than 3 times per week, my HR max for any run will be 145 bpm. Let say you are 30 years old and running 1-2 times per week, your HR max for any training run should be 180 – 30 – 5 = 145 bpm. One of the benefit of HR training is to strengthen and endure the heart. But the effect and benefits could only be realized gradually and slowly by months and even years of active running, therefore it demands a hips of discipline, consistency and persistence. Nevertheless, you could have the same feelings of running easy and relaxing and you could keep doing it more frequently.
The more you do, the better you feel, the better you got. Bingo! You hit a jackpot on setting up a positive loop.

There is another school of thought on this topic that you can run hard on certain pace, initially your HR will be high, but by time it will reduce as your body is getting used to the pace. After doing both, I would say that both takes time, running fast causes body long time to recover, higher risk of getting injured, and less enjoyable. So, I am totally abandon it and just focus on HR training run as it is easy, much lesser risk of injury and very enjoyable as I could see, observe and smell the surrounding. I may write a more details post on this topic in the near future.

Tip 2: You NEED to run slow because you WANT to run fast

It is related to the HR training run that I did. At first, due to cap HR max at 145, my pace is reduced from 6-7 (but HR was 160+) to 9-10 mins per km. Initially, I even sometimes have to walk to let the HR cool-down. I know that it is very frustrated while running in the park you are getting passed by uncle or auntie or even babies. I kept reminding myself and battling my own feeling about all of those: I NEED to run slow now because I WANT to run fast. It is a good metal training for my mind I would say and I start focus on the environment, my own body movement, the breath through the nose, etc. It makes my run getting more enjoying. Fast forward, after first month, I could run at pace 8-9. After 2 months, I could secure pace 7-8 comfortably. Now after doing it for a few months, I am almost running at the same pace I used to run with longer distance, less water, and less tiring.

Tip 3: Running is a good mental training and you should do it every morning

I used to be night owl whom dreaming of beautiful dawn and breathtaking sun rise. I used to wake up early often because I could do a run in the past but I was not a runner at that point. Hence, I used to only do it periodically, e.g. the longest streak was 30+ days then I stopped. Since, I am a runner, I trained myself to wake up daily at 5 am and doing a graceful run. At first, it appeared to be a battle of itself that I always ask what the f*** I am doing to myself now, the muscle and the joints is aching with morning sickness, the whole body is complaining and sweat is hell out of me. At first I calmed them down by listing to an audio book or podcast. But now, I used to run free without any phone or music in my morning run. I have trained my mind to be grateful and to enjoy the run. Still, the morning battle is going on every single day, but it’s just much less effort to pick up. And one thing I know for sure that I already win the day once I walk out of my door, wear the shoes and start running.

A disclaimer: just in case that you might think that I am all about running bullshit. Well, it is certain that I should care less on your comment about my personality as well as my hobby. Rather, I would like you to think though it for yourself and what you could do about it to improve your life, your health and make it be more healthy, lively, grateful, enjoying. For me, running is one of keystone habits that I could do daily. It serves as a strong foundation for my mind, body, attitude and spirit that make other part of my life be more meaningful. I am proud of being a father, a husband, a coder – architect – agilist, a life-long learner, and a runner.

Until we meet again, happy running, coding and living a meaningful life with hips of grateful moments. My deep thank you for reading my post.

Best regards,
Mike Nguyen

Microsoft EntityFrameWork Core 2.2.0 Issue Or Not :)

I found myself encountered this issue lately when trying to upgrade my bootstrap project for Clean lean Architecture via TDD approach (GitHub link here). 

What was the issue ?

  • When adding Microsoft.EntityFrameworkCore via NuGet in VS2018, the default version is 2.2.0 as following
  • The default webapi created from VS2018 or dotnet core cmd uses Microsot.AspNetCore.App version 2.1.1 which is compatible with entity framework version 2.1.x and below. 

How did I resolve it?

Approach 1: manually update the infrastructure project to use Microsoft.EntityFramework version 2.1.0 

  • To do this, we have to manually override the version in the project property file. 
  • Then run dotnet restore from cmd to update the library to expected version


Approach 2: Upgrade the default library of api project to latest version which is compatible with Microsoft.EntityFramework version 2.2.0 

  • Remove Microsoft.AspNetCore v2.1.0
  • Add from Nuget the latest version of 2.2.0 for both AspNetCore and AspNetCore.Mvc

Approach 3: Update DotNet Core to v2.2.0 which should be the easiest approach I would recommend to undertake. 

  • Make sure that you have it updated with latest version of VS2018 as well.

Hope it helps to avoid some wasted time. 

Until we meet again, happy coding. 

2018 reading : 50 books so far and what I learned (Part 2)

My review for the book can be found here: https://goo.gl/NWbYs8

In this post, I promise to go straight to the learning points for those interesting books I read so far in 2018. Please bare in mind that, It only contains my personal opinion, hence it would be better if you take it, read the book and reflect it with your own opinion. And of course share your thought with others to spread the spirit of learning.

I will organize the sharing into three parts.

It is a great journey for me so far and it comes in a long process of trying hard, giving up and repeating until it sticks. Now I would really enjoy a good book while exercising, commuting to work, or just simply waiting in a queue line. For me, reading or listening to audio books has become a great habit. The more I read, the more I learn, the more millage I run, the more humble, patient, and humanity I am. I feel thankful for those books that sharpen my life and my focus.  I am still discovering my true-self and I strongly believe eventually it will come, regardless the form, just keep moving forward and continue to read and open to learn.

Mike Nguyen October 2018

To make it a bit more interesting, I would snapshot a preview of books by my personal categories and kind-of-self-discovery questions. Hope you enjoy it !

List of questions in Part 2 will be: 

  • What books that change the way I look into personal finance and money ?
  • The book enriches my understanding on motivation is …
  • The book helps me to build courage and confidence is …
  • The book gives me another perspective of high performance and talent is …

To continue on Part 1 books on parenting, I mentioned about the title Boys Should Be Boys by Meg Meeker. I managed to finish it before writing the 2nd part and I love it. I would strongly to recommend it to whom has boys because i believe it will help to change your perspective and start building stronger and more meaningful relationship with your sons. 

Boys Should Be Boys

This is awesome book that I could feel connected, emotionally touched and most importantly it is made for better man. 

It is no boring theory and principles. Instead, it is painted with lots of real life examples to illustrate the concepts. I could learn from the story not only a various effective ways to connect with my Son but also be better man myself whom shall develop courage, confidence, empathy, integrity and be more patience to my boy. I learned that my boss will need my help to give him blessing, unconditional love and show him the way to be prepared, courageous and confident young adult. I must be the one myself and take him as the observer along the journey. 

I would definitely recommend this to one one whom has boys and want them to grow to their fullness

Mike Nguyen, October 2018

Books that change the way I look into personal finance and money are Total Money Makeover by Dave Ramsey and Unshakeable by Anthony Robin. Another book I would recommend in this category is The Legacy Journey by Dave Ramsey

Total Money Makeover

“We buy things we don’t need with money we don’t have to impress people we don’t like”

I listen to the audio version and completed in 2 gyms session. It is direct to the points and very motivated. Have learned a couple of good ideas and going to apply it to my life. At the end, it fits right to the purpose I set which I want to train for my financial fitness.

Mike Nguyen, July 2018

Unshakeable

Master only have a few precise techniques while novice need a thick bible to follow. The principle is again proven to be true in accumulation of wealth, as wisdom from ultra rich people. 

Main points I learnt are: 

1. Invest in Index Funds (passive type) 
2. Bear market happens every few years, be ready to buy when people is panicking to sell 
3. Develop a long term plan and stay with it. Never loose money (kind of difficult but it is the prove for your sound plan)
4. Diversification based on your risk appetite (between stocks and bonds). Bonds = you loan money. Stocks = you own the business. 
5. Think of future and put in proper plan. 

In short, to be unshakable financially requires determination, integrity, hardworking, active knowledge and forward thinking. It is certainly applicable to wide range of other areas of our life

Mike Nguyen, August 2018

The Legacy Journey

This is the second book I read from Dave Ramsey. The first one was Total Money Maker Over last couple of months. I was inspired by his authentic approaches to wealth: an enduring processes with strong principle and discipline, and most importantly, it could be done by anyone regardless of income. Key concept is cutting operating / expense cost, reduce debt by all cost, save money for big opportunities (will come when you have spare money for investment). I liked the two account concept: operating and saving (which the saving has no ATM can’t be withdraw) and monthly budgeting which I am still struggling to deal with it. 

This book brought another higher level perspective which is used to justify how we shall manage our wealth. Important concept i learnt was making proportional percentage of wealth in all aspect of live including spending, investing, saving, and giving (not giving back just giving with intention). Be fully responsible with your life, family and the people you love (developed a will regardless of your position). Wealth legacy must be transferable from generation to generation, teach your children and grandchildren to manage them wealth. avoid the lottery concept that may destroy not just wealth but other people life. Even for giving, do it like an investment by selecting the right non-profit organisation with track record of doing the job well and work with them closely. 

There are much more things I learnt but still yet to rationalize it as may be I am not there yet. Hence will definitely I plan to re-read this book for future learning and applying of these principles

Mike Nguyen, August 2018

The book that enrich my understanding on motivation is the Drive: The Surprising Truth About What Motivates Us by Daniel H. Pink

Drive: The Surprising Truth About What Motivates Us

This book draws a line between the assumption of his motivation works again the reality. It proved factual, studies and suggestion on how to motivate yourself and others in order to achieve intangible outcomes in a long term perspective. 

In the nutshell, it is motivation 3.0, one of the classic pioneers in resolving this puzzle of human nature and the real motivation behind our push or action. It invalidates the carrots and sticks or incentives theories in which the only way to get more outcome or outstanding performance is through more incentives. 

The formula is motivation = autonomy + mastery + purpose.

Mike Nguyen, Sep 2018

The book that helps me build confidence and courage is the Ultra Mindset: An Endurance Champion’s 8 core Principles for Success in Business, Sports and Life by Travis Macy, John Hanc

Ultra Mindset

Travis Macy summited glacial peaks in the French Alps, rappelled into vast limestone caves in China, and ran through parched deserts in Utah. Most famously, he won one of the country’s marquee ultra-distance events: Leadman, a high-altitude series of super-long-distance races, culminating with a 100-mile mountain biking race and a 100-mile trail run. Macy accomplished it without exceptional strength, speed, or flexibility, and without high-tech performance labs or performance-enhancing drugs.

His secret? A precise and particular outlook he calls the “Ultra Mindset,” principles for daily life that are neither mysterious nor the sole province of ascetics or elite athletes: embrace fear, rewrite stories we tell ourselves, and master the art of seeking help, among others. By applying the principles such as “It’s All Good Mental Training,” “When you have no choice, anything is possible,” and “Never quit…except when you should quit” to other areas of life, anyone can find success that otherwise would have seemed impossible.

Coauthored with award-winning running writer and journalist John Hanc, The Ultra Mindset blends exciting personal memoir with actionable, research-based advice. Dramatic stories of Macy’s far-flung experiences in the professional endurance-racing world lead into relevant mindset principles, reflective self-assessments, mind- and body-enhancing workouts and activities, and compelling case studies. Macy’s stories keep the pages turning as you forge your own winning outlook for success in business, sports, and life

Travis Macy, John Hanc, Book Cover, April 2015

Finally, the book that gave me another perspective of talent and high performance is The Talent Code: Unlocking the Secret of Skill in Sport, Art, Music, Math and Just About Everything Else by Daniel Coyle

The Talent Code

A New York Times bestselling author explores cutting-edge brain science to learn where talent comes from, how it grows—and how we can make ourselves smarter.

How does a penniless Russian tennis club with one indoor court create more top 20 women players than the entire United States? How did a small town in rural Italy produce the dozens of painters and sculptors who ignited the Italian Renaissance? Why are so many great soccer players from Brazil? 

Where does talent come from, and how does it grow? 

New research has revealed that myelin, once considered an inert form of insulation for brain cells, may be the holy grail of acquiring skill. Journalist Daniel Coyle spent years investigating talent hotbeds, interviewing world-class practitioners (top soccer players, violinists, fighter, pilots, artists, and bank robbers) and neuroscientists. In clear, accessible language, he presents a solid strategy for skill acquisition—in athletics, fine arts, languages, science or math—that can be successfully applied through a person’s entire lifespan

Goodreads Book Cover, April 2009

What a long  article and I was so blessed to get it done. To be honest, it is a constant struggling and self-debate: should I spend time to complete my Prototype on ASP.NET Core API + ReatJS or working on this Part 2. Fortunately, I have started the draft for this article on listing down these questions right away after the Part 1 is published. From that time onward, everyday, I keep remind myself “finish what you have started”. And I started writing one review at a point of time. The last step is to compile them all together. It is easy and cheesy. 

What’s next?

In Part 3 (last one I hope), I will talk about the books that helps me to cultivate mindfulness, different world view and open me to other aspect of life. 

Until we meet again, happy reading and writing. I hope that you find this be useful and please also share what you have learnt so that we all could grow to our better selves, once-not-too-far-away-day. 🙂 

I have a dream: sub 5 hours in the first road marathon

The idea was brought up to me by a friend few days back. He was asking me to pace him to complete a road marathon, in which we both participate, in less than 5 hours. My first replied was “Sure bro”. And then I did some quick math and figured out some now numbers. Eventually I edited my reply “It’s achievable if you maintain pace 7:00 throughout. It means that you must be running comfortably at pace 7:00 with HR of zone 2 or 3 (135 – 145 BPM). And then we could plan pace 6:00 – 6:30 for some part then make pace 7:00 for recovery”. He smiled and said “Together we can do it bro” and I smiled back to him.

This morning, I tested the feasibility via a long run of half marathon distance 21.2 km with constant  pace of 7:07, it took me 2:29 hours to complete. It was a quite comfortable run for me and the most difficult part is to resist the temptation of speeding up in the first 10 km. HR is another subject that it was my weakness. It was super moderate in first 10 km, shooting up in next 5 km and then was high (170) in last 5 km regardless of the easy pace (Refer to table 1 below for the pace and HR in details). My guess is that my body conditioning level is not yet being fit enough to sustain the pace 6:30 – 7:00 pace for such long time. That is why the HR keep jumping up quite high at the end of the run.

Pace and HR for a 21 km long run at pace 7:07

I have a great feeling that I could eventually tame it to be 135-145 bpm with this pace, in one month time. Yeah. The race is at 10 December 2018, and I must be ready for it. So, I decided to make this dream be reality but developing a game plan for it. 

What is the game plan to run a 42.25 km in sub 5 hours, you may be curious ? Not mentioning that it will happen in 6 weeks :D.

Here it is. 

Game plan

  • Fuels
    • Have big breakfast with 2,000 Calories (egg + bread + coffee)
    • Fuel every 1 hour with energy gel and bring 2 bottles: 1 for water and 1 for sport drink
  • Paces
    • Regulate pace based on HR and time. For example, maintain HR at max 160 through out. Except for last 10 km or so it’s acceptable to have HR at 170 but the pace should be moderate. 
    • I could image it will be like 
      • 0 – 10 km: HR 150, pace 6:00 (60 mins)
      • 10 – 20 km: HR 150, pace 6:30 (65 mins)
      • 20 – 30 km: HR 160, pace 7:00 (70 mins)
      • 30 – 36 km: HR 165, pace 7:15 (43 mins)
      • 36 – 42 km: HR 165, pace 7:30 (45 mins)
      • Total: 283 mins or 4 hours 43 mins. 

Training Plan

  • The training focus:
    • Make HR constant at 150 for pace 6:30 then 6:00. 
    • Allow me run at pace 7:00 effortlessly (this will be used as recovery and main pace throughout)
  • Weekly
    • 2 interval runs during weekdays
      • Distance: 12-15 km
      • Part 1 is 5 km interval, named HR Inversion, target HR zone 5, pace: 5:00 
      • Part 2 is 7-10 km, named HR Normalization, target HR zone 3, pace 6:30 – 7:00
    • 1 long runs during weekend 
      • Distance: 21 – 30 km
      • One pacing through out, named Conditioning Run, target HR zone 3, pace: 6:30 – 7:00. 
    • Weekly mileage: 
      • Before tapering: 60 km 
      • After tapering: 40 km
  • Swimming, Cycling and Gym will be used as cross training. 

Phew, I could just throw the thinking hat aside and get sweaty. Just do it and I will feel better, stronger and more confident. Yeah!

For those whom is dreaming of doing 5 km or 10 km, I strongly believe you can do it. All you have to do is to stop for few second, take a few deep breathes, change your clothes, put on a running shoes and just run. First you can run a bit then walk and repeat the process. The moment you get sweat hard enough, you will realize that you could do more and will decide to be a runner. It is just like me, I can do it, certainly you can do it as well. 

All the best and keep running your new healthy habit. We all need a strong foundation for health, mental and strength to face head-to-head with incoming life challenges. 

I will post an update on my race result in December. Watch out 😉

2018 reading : 50 books so far and what I learned (Part 1)

My review for the book can be found here: https://goo.gl/NWbYs8

In this post, I promise to go straight to the learning points for those interesting books I read so far in 2018. Please bare in mind that, It only contains my personal opinion, hence it would be better if you take it, read the book and reflect it with your own opinion. And of course share your thought with others to spread the spirit of learning.

I will organize the sharing into three parts.

  • Part 1: [Now] will talk about the most important book and those that sharpen my personal life: to be father, husband, runner
  • Part 2: [To be] will talk about the books that enrich my thinking, knowledge of personal finance and other aspect of personal excellence.
  • Part 3: [To be] will talk about the books that cultivate mindfulness, different world view and open me to other aspect of life.

It is a great journey for me so far and it comes in a long process of trying hard, giving up and repeating until it sticks. Now I would really enjoy a good book while exercising, commuting to work, or just simply waiting in a queue line. For me, reading or listening to audio books has become a great habit. The more I read, the more I learn, the more millage I run, the more humble, patient, and humanity I am. I feel thankful for those books that sharpen my life and my focus.  I am still discovering my true-self and I strongly believe eventually it will come, regardless the form, just keep moving forward and continue to read and open to learn.

Mike Nguyen, October 2018

To make it a bit more interesting, I would snapshot few books by my personal categories and kind-of-self-discovery questions. Hope you enjoy it!

List of questions in part 1 will be: 

  • What is my life changing book ?
  • What books that turn me to be a distance runner ? 
  • What book help to make me a listening and better father and husband ? 
  • What book helps to sharpen my diet and make better choice of what I eat ? 

The book that change my life is the 7th, title 5 Seconds Rule by Mel Robbins.  I love the story and Mel’s honest way of telling her own personal drama as I found some part similar to mine. I even bought her 2nd book title Kick Ass that composed of various of live interviews Mel did all over the world to use the rule to help them transforming their live. But I end-ed up abandoning it as there was much more interesting books to read on. Sorry Mel :). 

I read the book in course of 2 days straight and immediately after the rule while I am reading it. When the alarm rings at 5:30 AM, I wake up, turn it off, go to toilet to brush my teeth, go to kitchen to get a cut of water, sit down to my study desk, and look at the clock: it is 5:35 AM. Now I set the alarm to be 5:00 AM. 

Mike Nguyen, June 2018

There is no rocket science, it’s just the psychology behavior of how our brain and mind work. Don’t believe me? When you are undecided position: you want to do it in your guts but your mind keeps hesitated: start counting from 5,4,3,2,1 and push yourself to take an action. Scientifically, the urge of doing the right things is being pull off after 5 seconds. Your mind will make up thousand of excuse of being OK to be a coward. 

The books that turn me into a distance runner and completed my first ultra 50 km in last September are Let Your Mind Run by Deena Kastor, Running Man by Charlie Engle, and Run Forever by Amby Burfoot.  There are few more that I have read that enable me to culture the ultra mindset and equip me with better understanding on running long distance knowledge. Certainly these three are the top for those want to be a runner.

Let Your Mind Run by Deena Kastor

A great story of competitive runner conquering her way to the TOP. It goes as your own personal story when you are struggling your goals and continuously find a way to overcome it. Key learning points
1. Have and maintain positive mindset when approaching to any challenge 
2. Be grateful and thankful for surrounding that leads you to be more open-mindedness 
3. Have a game plan and push yourself hard through the boundaries 
4. Have well balance diets and rest is very important beside the exercise 
5. When facing fatigue, looks around let your mind wonder for greatness beyond yourself. Just let your mind run and the body will follow. 

Mike Nguyen, May 2018

Running Man by Charlie Engle 

Awesome story and it comes with lots of emotional touches. It’s not just a book about endurance running (even through it’s nuts and may not applicable to any of us), it’s about the desire to achieve outstanding performance and strong characters as well as ability to transform pain and suffering to the the energy that fuel the endurance. 

What I admired the most is the pure spirit of giving all in, the courage to put everything for chasing his dream and believe in faith. It is certainly lots of unknown and the only way to win is to take one step at a time with confidence and self-belief. 

I wonder if what would we could achieve as any individual if we could be free of what-ever-materialized-things-surrounding us. How could we cultivate courage to live with the dream ? How big could it be ? Or we may not even dare to dream … 

I recommend you to read the book. At least, i hope, you will be inspired to dream. 

Mike Nguyen, June 2018

Run Forever by Amby Burfoot

Excellent book for better runner and person. The book embodies lots of scientific facts related to running and enduring exercises. I picked up right away a few tips which now makes running my hobby and passion. Such as run walk, run relax and slowly, eat healthy breakfast and lunch, persistence and consistency, just to name a few. 

The books was organised in form of short essays and well structured content hence makes it easier to absorb. The author is extraordinary runner. He has been running for 7 decades and keep going strong (adjustable standard) that leaves a significant impression on me. 

This book will definitely be in my favorite shelf for future revisit. Highly recommend for those whom love running but somehow give up trying to get the feeling of ‘return home’ to running and brighten your life. Just like it does to me.

Mike Nguyen, July 2018

The book that make me to be a better father is How to Talk so the little kid will listen: A survival guide to life with children ages 2-7 by Joanna Faber, Adele Faber, Julie King.
For those who has boys, I would recommend another book title Boys should be boys: 7 secrets to raising healthy sons by Meg Meeker. I am in the middle of finishing it though. 

How to Talk so the little kid will listen: A survival guide to life with children ages 2-7

This book is very practical and well equipped with handy communication toolkit that enables us, busy inpatient parents, to converse more effectively to our children. 

Through out the book, I pickup techniques and start using it right away: I started asking my son questions and phrases them to guide him express more his feelings. I started be more patient and observant. I started to see more desired behavior. I got more confidence to bright future that I wanted to teach my children problem solving, kindness, courage and confidence. 

The second parts (40%) are about workshop and experience sharing. It is a good opportunity to recap what we learnt. 

Overall, I highly recommended this book for parents and I strongly believe this will smoothen your pains of dealing with kids. 

Mike Nguyen, July 2018

The book that introduces me to healthy diet and good food is Genius Food: Become Smarter, Happier, and More Productive While Protecting Your Brain Life by Max Lugavere and Paul Grewal

Genius Food: Become Smarter, Happier, and More Productive While Protecting Your Brain Life

I finished this book as audio version. I like this book despite the fact it is quite difficult to catch when coming to the scientific facts, I still can’t get well to the terminology. The PDF version of summary those facts is definitely helpful. 

What I learnt from this book are the intentional choice of food that enable performance and cognitive brain development. Yes, our brain is still in the progress of development, the speed of those gradually reduces upon aging. I like the fact that those could be improve by those choice of food we take in.
I made a few choices: eat avocado, eggs, green veggi and natural yogurt for breakfast, take a big walk after lunch, eat beef one or two per week, eat lots of fishes during dinner (3-4 times per week), snack with almond (baked whole skin), change to olive oils etc. 

So far, I am happy with those choice I made. I could feel and see the change in the way I work and look into things with more calmness, patience and curiosity. 

Mike Nguyen, August 2018

To be continued. 

In second part, I will talk about those books that enrich my thinking, knowledge of personal finance and other aspect of personal excellence. 

Quantify Software Characteristics

To measure to to know that increases the odd of being success

Motivation

  • Architect’s is largely to help the system have these desired qualities (fast, responsive, extensive), and to balance the inevitable conflicts and inconsistencies between them. 
  • Without objective criteria, architects are at the mercy of capricious users (“no, I won’t accept it, still not fast enough”) and of obsessive programmers (‘no, I won’t release it, still not fast enough”)
  • If these are not quantified, then there is no basis for acceptance of the system by its users, value guidance is stolen from its builders as they work, and the vision is blurred for whom architecting it. 

How to questions

  • How many ? In what period ? How often ? How soon ? Increasing or decreasing ? At what rate ? 
  • Answers of those questions should be in the business case for the system. If they are not, then the job of architect is to go to get it from the business owner. 
  • Next time if someone tell you that a system needs to be “scalable”, ask that person where new users are going to come from and why. Ask how many and by when? Reject “lots” and “soon” as answers. 

Techniques

  • Uncertain quantitative criteria must be given a range: at least, the nominal and the most
    • If the range cannot be given, then required behavior is not understood. 
    • Finding these range and checking again them is a time-consuming and expensive business.
    • If no one cares enough to pay for performance trials, then more likely performance doesn’t matter. You should be free to focus your architecture efforts on aspects of the system that are worth paying for.
  • As the architecture unfolds, it can be checked against these criteria to see if it is still in tolerance. As the performance against some criteria drifts over time, valuable feedback is obtained. 
  • Example of a good requirement: 
    • “Must response to user input in no more than 1,500 ms. Under normal load (defined    as …), the avg response time must be between 750 and 1,250 ms. Response times less than 500 ms can’t be distinguished by the user, so we won’t pay to go below that

Clean Coder Summary

clean coder

Clean coder is one of the classical book that every developer should read written by Robert  C. Martin (Uncle Bob). The book contains 14 chapters provides guiding principles to be an outstanding developer.   

This summary is solely based on my filtered eyes hence could be used mainly for a quick reference after you have read the book at least once. So please go ahead to read the book first to ensure you yield the most learning.  

 Here we go for the 14 long chapters. Hope you enjoy it.

Chapter 1: Professionalism 

  • Being a professional means taking full responsibility for one’s actions.
    • “What would happen if you allowed a bug to slip through a module, and it cost your company $10,000?
    • The non-professional would shrug his shoulders, say ‘stuff happens’, and start writing the next module.
    • The professional would write the company a check for $10,000!”
    • [real disaster story about field-failure of a routine each test of which took hours]
  • First rule is not doing harm to the function nor the structure of the software.
    • You will always make occasional mistakes, but you must learn from each. Promptly
  • You should be certain about all code you release and firmly expect QA to find nothing wrong with it.
    • Test it. Test it again.
    • Automate your tests.
    • Demand 100% coverage.
    • Design your code to be easy to test.
  • You should follow the Boy Scout rule and always leave a module a little cleaner than you found it so that it becomes easier to change over time, not harder.
    • Suitable automated tests can allow you to not be afraid to change the code and continually changing it makes sure it stays that way
  • Your career is your responsibility, not your boss nor your employers.
    • Spending 20 hours a week beyond your normal work to improve your knowledge and skills
    • Read, experiment, practice (kata), talk to other, collaborate, look over the fence, mentor
    • It should be fun.
  • Also, know your domain, identify with your customer (no “us vs. them”, ever).
    • Be aware of arrogance inherent in programming and learn to be humble, too.

Chapter 2: Saying No

  • Real disaster story about premature deployment of a totally immature distributed system
  • Professionals speak truth to power. Professionals have the courage to say no to their managers.
  • Managers and developers have roles that are often adversarial, because on the short term, their goals tend to conflict.
    • The manager will defend her objectives, but will also expect you to defend yours for the best overall outcome, which is reaching the largest goal that you and the manager share, which may be tricky to determine
  • The higher the stakes, the more valuable a “no” becomes, and the harder to say.
  • Good teams will successfully work towards a yes, but only a right yes, that will later work out in practice.
    • Saying “no” is often a prerequisite for getting that right yes.

Chapter 3: Saying Yes

  • There are three parts to making a commitment
    • You say you will do it
    • You mean it
    • You actually do it
  • A professional will not stop after step 1 or step 2.
  • Unconditional commitment always takes a form equivalent to “I will achieve goal X until time Y”
    • Commitment means taking full responsibility.
    • Most results depend on conditions you cannot fully control, so you will often only commit to actions or commit only conditionally
  • Your commitment must respect the limits of what you expect (based on your experience) you can and cannot do
    • IF you recognize you will probably not be able to meet a commitment, you need to raise a red flag immediately

Chapter 4: Coding

  • Coding requires a level of concentration and focus that few other disciplines require.
    • A clean coder codes only if she can guarantee enough focus
    • Distractions (personal, environmental, or whatever) are a problem.
    • Overtime is a problem.
  • Flow (“the zone”) is not as good as people think: you will be locally productive, but will often lose sight of the bigger picture and possibly product no-so-good designs
  • Interruptions are bad distractions.
    • Pair programming is helpful to cope with them.
    • TDD helps to make the pre-interruption context reproducible
      • Minimize time spent debugging
  • If you have writer’s block, start pair programming
    • Make sure you take in enough creative input, e.g. reading fiction books. Find out what works for you
  • Coding is a marathon, not a sprint, so conserve the energy and creativity.
    • Go home when it’s time, even in the middle of something important.
    • Showers and cars are problem-solving resources too.
  • Continuously re-estimate your best/likely/worst completion time and speak up as soon as you recognize you will likely be late.
    • Do not allow anyone to rush you.
    • Consider overtime only for short stretch (2 weeks max.) and only if there is fallback plan as well.
    • Use a proper definition of “done”, with sufficiently high quality requirements
  • Programming is too hard for anyone, so get help and provide help to others, in particular (but not only) in mentoring style.
    • Don’t protect your turf, don’t shy away from asking, don’t show away others who ask.

Chapter 5: Test-driven Development 

  • TDD is not a cure-all and is impractical or inappropriate in some (rare) cases.
  • Three principles:
    1. You are not allowed to write any production code until you have first written a failing unit test
    2. You are not allowed to write more of a unit test than is sufficient to fail, and not compiling is failing
    3. You are not allowed to write more production code than is sufficient to pass the currently failing unit test
  • The cycle only about 30 second long
    • It provides certainly not having broken anything when making changes
    • It reduces defect injection rates often 2-10x
    • It provides courage for cleaning up messy code
    • It documents how code is to be used
    • It makes you create designs with low coupling

Chapter 6: Practicing 

  • A programming Kata is a precise set of choreographed keystrokes and mouse movements that simulates the solving of some programming problem.
    • You aren’t actually solving the problem because you already know the solution.
    • Rather, you are practicing the movements and decisions involved in solving the problem (IDE, TDD, CI)

Chapter 7: Acceptance Testings

  • Avoid garbage in, garbage out. Make sure you understand the requirements, and expect your customer to initially not understand them.
    • Creating this understanding means removing ambiguity
  • Best way to do this is defining acceptance tests:
    • Ask the customer for all conditions they will plausibly want the software behavior to fulfill and turn them into automated tests.
      • Customers often will not want to answer all your questions, so developers or tests will have to guess, in particular for the failure cases, and then validate the result with them
    • Success of those tests constitutes the definition of “Done”
  • Code implementation should start only when the test implementation is complete.
    • Look out for silly, awkward, or plain incorrect tests and work with the test authors to improve them
  • Unlike unit tests (which are for programmers only), the audience of acceptance tests are both business and developers.
    • Prime purpose of both kinds is specification, testing is only secondary.
  • Test GUIs mostly one level below the actual GUI (on abstractions of the GUI elements) to reduce test volatility
  • Run all tests in a continuous integration and immediately fix any failures that may occur.

Chapter 8: Test Strategies 

  • Consider QA part of the team. They act as specifiers: writing acceptance tests, including the failure cases and corner cases, and perform exploratory testing
  • Testing pyramid
    • Most tests are unit tests
      • By developer and For developers
      • Executing almost every statement of the class and asserting its behavior
    • Many tests are component or integration tests
      • By QA or Business assisted by Developers, For Business and Developers
      • In a component testing framework, executing all relevant paths through larger combination of classes.
      • Component tests mock away other parts of the system and assert correct business rules.
      • Integration tests may or may not mock and assert correct choreography of the pieces
    • Some tests are automated system tests of the whole, usually at GUI level with the respective tools
    • A bit more testing is done manually at system level in creative, exploratory fashion

Chapter 9: Time management 

  • Software development, especially in management roles, requires good time management discipline
  • Meeting are necessary but are also often huge time wasters, so avoid meeting that have no clear benefit -> this is a professional obligation.
  • Meeting must have an agenda and a clear goal
    • Agile stand up meetings can be an efficient format
    • Iteration planning should take 5% of the iteration (2 hours for  one-week iteration)
  • Any argument that can’t be settled in five minutes can’t be settled by arguing. So don’t try to; make measurements, flip a coin or vote
  • Concentration (focus) is a scarce resource
    • Use it well when present and recharge with simpler tasks (meetings) and breaks in between
    • How to improve?
      • Sport
      • Creative input
      • Pomodoro techniques (25 – 30′ block time)
  • Professionals work on their real tasks, in a sensible priority order, even if they don’t like some of them
    • They admit when they have chosen the wrong path and leave it quickly
    • They recognize messes (whether their own or others’) and never accept them, they clean up.
      • Nothing brings down productivity more than a mess.

Chapter 10: Estimation 

  • Estimation is the source of most distrust between business people and developers, because the latter provide estimate which the former treat like commitments.
    • both are insufficiently aware that the estimate really is a probability distribution, not a fixed number
  • The PERT technique computes and uses such distribution based on base-case, nominal and worst-case estimate for the project or better each task
    • Program Evaluation and Review Technique (PERT): analyse and represent the activity in a project to illustrate the flow of events in a project
    • PERT is a method to evaluate the time required to complete a task within deadlines, also cost.
    • PERT involves following steps
      1. Identifying Tasks and Milestones.
        • Every project involves a series of required tasks.
        • These tasks are listed in a table allowing additional information on sequence and timing to be added later
      2. Placing the tasks in a Proper Sequence
        • Tasks are analysed and placed in a sequence to get the desired results
      3. Network Diagramming
        • A network diagram is drawn using the activity sequence data showing the sequence of serial and parallel activities
      4. Time Estimating: this is the time required to carry out each activity, in three parts:
        1. Optimistic timing: the shortest time to complete an activity
        2. The most likely timing: the completion time having the highest probability
        3. Pessimistic timing: the longest time to complete an activity
      5. Critical Path Estimating:
        • Determines the total time required to complete a project
  • Wideband Delphi (e.g. Planning Poker) is an estimation procedure where several estimators iteratively work towards agreement.
    • Can be combine with PERT

Chapter 11: Pressure 

  • The professional developer is calm and decisive under pressure, adhering to his training and disciplines, knowing that they are the best way to meet the pressing deadlines and commitments
  • Avoid situations that cause pressure via
    • make only commitments you can fulfill
    • keep your code clean
    • work in such a way that you need not change it when in crisis
  • Don’t panic. Make a plan (and talk with your team). Don’t rush. Trust your disciplines.
  • Offer pairing to others in crisis

Chapter 12: Collaboration

  • Not all but most programmers like working alone. But we need to understand the goals of the people around us, including business folks.
    • This requires communication.
  • Likewise, within the development team: only collective code ownership and pairing produce a good level of communication.
    • Programming is all about communication.

Chapter 13: Teams and Projects 

  • Teams need time (months) to gel, to really get to know each other and learn to truly work together
  • Assigning fractional people to projects is a bad idea, as is breaking up a good team at the end of a project.
  • Instead, assigning several projects to one team can work well

Chapter 14: Mentoring, Apprenticeship and Craftsmanship 

  • Young programmers need mentoring.
    • Mentoring can be implicit or explicit
      • Implicit = reading a good manual or observing someone working)
    • Medicine has established a system of apprenticeship for new practitioners (a full year) in which mentoring is likely to occur and another 3 – 5 years of apprenticeship are required to become a professional in medicine specialty
  • Given that we entrust software with all aspects of our lives, a reasonable  period of training and supervised practice would be appropriate.
    • A system of masters, journeymen and apprentices as in the crafts might be suitable.
    • We currently do not impose on the elders a responsibility to teach the young.
      • We are missing the mindset of craftsmanship and so the elders fail to consciously act as the role model that would make the young adopt the craftsmanship attitude as well

Application And Tools

  • Version management:
    • Enterprise tools
    • CVS, SVN
    • Git
    • Branching
  • Editors / IDEs
    • vi, Emacs, IntelliJ, Eclipse, Textmate
  • Issue Tracking
    • Pivotal tracker
    • Light house
    • Wiki
    • Bulletin board
    • Issue dumps
  • Continuous build: Jenkins
  • Unit testing tools
    • JUnits, RSpect, NUnit, Midje, CppUTest
  • Components testing tools
    • FitNesse
    • RobotFX
    • Green Pepper
    • Cucumber
    • JBehave
  • Integration Testing Tools
    • Selenium
    • Watir
  • UML / MDA (Model Driven Architecture)
    • Code vs. details as main problem

Cloud Journey : First Baby Step


The journey of a thousand miles begins with one step

Lao Tzu

A question keeps popping my head a while back, a few years may be “Why shouldn’t I start the Cloud Journey”. As many others, I felt anxiety, fear and unknown. Mainly because I didn’t try to put on the hat of businessman. I was ordinary developer, process, and result driven person in the world of best practices, awesome technology stacks and fancy terminology. 

Until lately, I start enjoying challenging myself both mentally and physically when I decided to be a long distance runner. I progressed fast and on my way to complete first 50 KM race in coming end of September 2018. The deep inside reason of my pursuit is to embrace the challenge and create a strong foundation for future pursuits in all aspects of my life in which I am a Daddy, Husband, Clean Coder, Tech Leader, Architect, Agilist and Runner. I start to make myself think more like Tech Leader and Architect, not just do the ordinal job as I used to do. It is just by such small change, the Cloud Journey become obviously sensible to me.

I start looking at where I am at now (2018) and trying to feel and learn from other anticipations what will happens in 10, 20, and 30 years time in Cloud space. I image myself living in a whole new world in electronic devices are interconnected and self autonomously operated. For example, self driving cars that could operate on their own defined route with precise timing (makes fluent traffic flows be possible) and could perform self charging function at any Charge Station upon certain fuel condition. I image self learning algorithm be part of smart devices brain that make them operate more efficient (certainly to a degree of their purpose focusing on certain function). Under those living e-devices is Cloud network in which those devices send and receive information and commands. Cloud network will certainly be a layer in which we human putting the best brains and effort to set boundary and control those devices. 

Enough of those fantasy. Let me get to the reality by sharing some key information that I have learnt during my Cloud Journey so far. 

The History until Date

  • 1999: Saleforces.com started as the first SaaS
  • 2002: Amazon started AWS
  • 2005: AWS introduced EC2
  • 2008: Gartner promoted “Company-owneed hardware and software assets will soon be transformed into per-use service-based models”. It means a strong prediction on success of SaaS and IaaS in coming years
  • 2009: Web 2.0 was introduced.  Google participated via google docs.
  • 2010:
    • Feb MS released Azure.
    • Jul Rackspace Hosting and Nasa introduced open source cloud software OpenStack
  • 2011: IBM introduced SmartCloud framework to support Smarter Planet
  • 2012: Jun Oracle introduced Oracle Cloud
  • 2013: Google released Google Compute Engine
  • 2016: Three popular model of cloud: IaaS, PaaS, SaaS
  • 2018:

Enterprise Public Cloud Adopton

First question I want to understand and answer is Why Cloud ? what benefits to business to move to cloud 

Why Cloud ?

  • Easily deploy-able models 
  • Simplified IT management and maintenance 
  • Built-in Security 
  • Remote access
  • Cost efficient 
  • Reliable delivery, management and support services

To understand the Cloud advantages, it’s also important to understand the characteristics of Cloud. 

Cloud key characteristics 

  • Agility 
  • Cost reduction: change from capital expenditure to operational expenditure 
  • Device and location independence 
  • Ease of maintenance 
  • Multi-tenancy: enable sharing of resources and costs among users
  • Performance 
  • Resource pooling 
  •  Productivity 
  • Scalability and elasticity via on-demand provisioning of resource on a fined-grained, self-service basis near real-time
  • Security: supports both kernel modeling and audit log. 

According to National Institute of Standard and Technology (NIST), Cloud has five essential characteristics   

  • On-demand self-service
    • A consumer can provision computing capacities, server time, network storage as needed automatically without requiring human interaction with each service provider 
  • Board network access
    • Capabilities available over the network and accessed through standard mechanism that promoted use by thin or thick client platforms (mobile devices, PC, tablets etc.)
  • Resource pooling
    • Pooled to serve multiple consumers using multi-tenant model with different physical and virtual resource dynamically assigned according to user demand 
  • Rapid elasticity 
    • Elastically provisioned and released to scale rapidly outward and inward commensurate with demand
  • Measured service
    • Automatically control and optimized resources use by leveraging a metering capability at some level of abstraction appropriate to the type of service (storage, processing, bandwidth and active user account). 
    • Resource usage can be monitored, controlled and reported, providing transparency for both provider and consumer of utilized services. 

Wow, it seems a big steps so far, does’t it. Well, not really I  would say. For me the Cloud Journey just starts. This article aims to provide some fundamental facts and raise the awareness and trigger curiosity. If you are interested, keep watching out for future posts in this series. 

What next ?

In next article I will write out Cloud models, business adoption option, services available and trends. 

Until we meed again, happy learning and clouding !

Cheers!
Mike

Good questions architects should ask

I was inspired by the O’Reilly Software Architecture Conference New York 2018 talked on topic of developing a chaos architecture mindset by Adrian Cockcroft (AWS), when he mentioned his best role as architecture in his early career was not to define the standard or to tell other people what the architecture should be. Instead, it was to ask awkward questions.

Question 1: what problem are you trying to solve ?

I recalled times when being ask this by my boss when I was the engineer or lead that I often described technical challenges I or the team was facing (e.g. building or installing framework etc.). It was wrong answer. A good answer is something involving users or business needs. It helps sharpening thinking as well as the way you could communicate the problem more effectively.

Following are list of remaining questions mentioned in the talk and important points being tagged along

Question 2: What is the user need ?

Question 3: What does the value chain look like to support the user needs ?

  • What’s your time-to-value?
    • Days
    • Months
  • How is the value chain evolving ?
  • Have you heard of Simon Wardley ?
    • Wardleys maps is used to visualize evolution and innovate further up the value chain
      • What is your position and movement on the maps ?

Question 4: What should your system do when something fails ?

  • Stops ? Because it can’t do something safely
  • Carry on with reduced functionality ?

Question 5: If a permissions look up fails, should you stop or continue ?

  • Permissive failure, what’s the real cost of continue ?
  • See Memories, Guesses and Apologies by Pat Hellad

Question 6: Do you have a backup datacenter ?

  • How often do you failover apps to it ?
  • How often do you failover the whole datacenter at once ?
  • A fairy tale
    • Once upon a time, in theory, if everything works perfectly, we had a plan to survive the disasters we thought of in advance.
    • How did that work out ?
  • Common problems. Things happened
    • SaaS vendor:
      • Forgot to renew domain name….
    • Entertainment site:
      • Didn’t update security certificate and it expired
    • Finance company
      • Datacenter flooded in hurricane Sandy

You can’t legislate against failure, focus on fast detection and response (Chris Pinkham)

Question 7: Do you have a defined architecture ?

  • Are processes and roles documented ?
  • Are documents up to date ?
  • Do people follow the documented process ?
  • Is the architecture implemented as designed ?

Question 8: How do you try to make people comply with your architecture ?

  • Authoritarian High Modernism Workers should do what they’re told
  • Taylorism Management as an exact science
  • Synoptic Illegibility
    • If you can’t write down exactly what really happens, you can’t write a synopsis and the architecture is ad-hoc and messy

Book recommended

  • The Safety Anarchist – Sydney Decker
  • Drift Into Failure – Sydney Dekker
  • Release It ! – Michael Nyberg

Hope you find it helpful. Until we meet again, happy coding and questioning !

Cheers.
Mike