Hi, Docker and Ubuntu

I was watching #MSBuild2017, looking over the balcony, up to the cloud, a voice whisper in my head, Oh man, you are far behind. What a moment! So many new things, I decided to pick Docker as a starting point. Honestly, I had no clue where to start. However, I did know that I had to start somewhere. A wise man said start small. Docker has just that, a hello world application.

Whenever I want to learn something, I head over to Pluralsight. Here we go. Give me Docker

Pluralsight Give Me Docker
Pluralsight Give Me Docker

I decided to take the Getting Started with Docker, then later Docker Deep Dive (still enjoying this course). They are awesome. The author, Nigel Poulton, has a good sense of humor.

Docker on Windows

I have been using Windows since I first met a computer. It is fairly simple to run and try out docker on Windows. Head over to Docker on Windows, download and follow the instruction.

After installation completed, fire up PowerShell, your very first command is docker version.

Your very first docker command

Have not used Command Line Interface for years, that output gave me a strong feeling. I uttered “wow it is cool“.

You cannot imagine my feeling when I ran this command

Hello World from Docker

From that moment, I know that I can do many things with the abilities Docker gives.

Docker on Linux

Here is another fact. I do not know Linux. I have not used any Linux system. Years ago, it was hard to setup a Linux lab. What is now?

Hyper-V The power of virtualization

With the power of Hyper-V, I can have as many machines as I wish. I decided to download and try with Ubuntu server (The course suggested it as well).

Installing Ubuntu on Hyper-V is simple. Download Ubuntu Server here. Hello Ubuntu.

Hello Ubuntu

Let try docker

Hello World on Ubuntu

Such an amazing moment 🙂 They are exactly the same in both versions.

Values?

Sound a trivial task. However, there are many things that I gained during the weekend.

  1. It triggers my learn process. I feel energized again after years of writing code.
  2. It opens opportunities. The more I know, the better I am. The better I am, the more opportunities I see.

What I showed here is the end result. Just like anything else in the world, the devil is at the detail. When you actually get your hands dirty, you will meet the roadblocks. Solving them gives me some Linux pieces.

Some Linux (Ubuntu Server) Command Line I learned

sudo su: Run as administrator (mapped to Windows environment).

ifconfig: Same as ipconfig in Windows.

ip addr show: Display the IP addresses with other information

route -n: Display kernel routing table.

apt-get install [name]: Install a package. For example: apt-get install docker.io will install docker on your Ubuntu

apt-get update: Install all updates.

service [name] status: View status of a service [name]

Not a bad result for my weekend. Not mention that I, now, love the Command Line approach.

 

So far so good. It is enough for me to move on. My next challenge is how to take advantages of them. It would be fun.

 

 

Agile, My Own Version

People talk about agile these days in Software Project Management. Each has their own understandings and practices. Sometimes, I have a feeling that people focusing too much on its concept; on what it is; on what we should apply; on how to apply …

Is there any problem with that? I do not know. I cannot judge someone decisions.

However, these are what I know. I know that I have to start with asking the right questions, that Agile is a tool to solve a set of problems.

  1. What are my problems?
  2. How can Agile help solve my problems? Has it solved the similar problems?
  3. What are fundamental steps I should follow?

What Are Problems?

You cannot bring a tool to fix a problem that you have not known. It seemly does not work. There are hundreds of problems when running/working a team. Each team has different set of problems. There is no perfect team, my opinion.

The first step is to identify basic problems that the team is facing. As a software development team, there are some common problems that I have seen. Yours might be different than mine.

Lost Focus

What if you ask a developer in your team “what are our goals this week?“. I hope you will get good answer that your members know the team’s goals. From my experiences, they cannot say clearly about the team’s goals. They might say let me check the board. The point is that those goals are not clear to them.

Why? There are 2 possible reasons I could think of

  1. Developers are so focus on their tasks (or they say so). Everyone has their own “to do” list on their mind.
  2. The goals themselves are vague. Even the leader cannot say it clearly in 1-2 sentences.

Low Productivity

Output is not good. There is a high bug rate, high regression bugs. There are different definitions for Productivity depending on the team and organization. However, in short, Productivity means you deliver what you are supposed to deliver.

Why?

  1. Lost Focus (from above): People are not aware of what they should deliver.
  2. Cooperation: a crucial factor of a team.
  3. Lack of energy: There is no rhythm in the team. People feel bored.

Agile as a God

Agile has emerged. People pay attention to it, read articles, books. And they quickly start to apply in their own teams and organizations.

Then we see people asking about “how to apply agile?”, “why does Agile not work in their team?”, …

Imagine the situation when you come to your team meeting with a strong claim: guys, we apply Agile. Then you start explaining about it. How cool it is. How popular it is. You have hundreds of reasons. You, then, set up Kanban board, announce daily standup meetings, … all other practices written for Agile.

What will you get after some weeks?

Soon you will chase to solve another new problem: why has Agile not worked with my team?

Wait a second! What was the problem that we wanted to solve at the first place? I hope someone in the team will ask that question.

Agile, on My Eyes

I would like to use Agile as adjective (yes, Agile is an adjective). That is Agile is a set of principles to help us improving our way of thinking, help us delivering better software, better output. That it has some practices to help us solving (improving) our problems (some I mentioned above).

I do not like to think Agile as a set of processes, steps, … or a set of instructions that we should follow.

Let take it small steps.

Daily Standup Meeting

The most common concept that people talked in that meeting is the three questions. In the nutshell, they are

  1. What have you done yesterday?
  2. What will you do today?
  3. What block your way?

My opinion, they are boring. I do not think they work as expected, either. To force myself from not thinking about them, I called them Three Stupid Questions.

Wait! What the problems the meeting is trying to solve? Focus and Cooperation. By letting the rest of the team knows what you have done, everyone has the same vision. By raising the impediments, other can have a chance to help. The intentions are good.

However, in practice, I have not seen it worked (I know it might work on other teams). How to verify that? I suggest asking one of these questions (after the meeting)

  1. How far are we closed to the delivery?
  2. What were the team’s accomplishment yesterday?

Pyramid and Brick

I created my own version of daily standup meeting. The main idea is to utilize the visualization. In stead of writing the goals in words, I draw a picture with the concepts of Pyramid and Brick.

Agile DailyMeeting Goals Visualization
The visualization of the goals for the team

It must be a hand-drawing one. Team leader will draw it everyday in the team meeting.

  1. Pyramid: is the rectangle.
  2. Brick: the yellow or black boxes.
  3. The window on the top right: The visualization of the delivery. In this example, it is a web form.
  4. The face (with 2 arms): The team. The team controls the pyramid. They are in charged of everything. In the end of the meeting, it will either a smiled or sad face.

How does it work?

In the first meeting of the week (or sprint, I prefer weekly basic), the team will help build the pyramid. Bricks are work they have to do to build the pyramid. In the Agile terminologies, they can be either Epic, Feature, User Story, Bug, or task.

On the next meetings, each member will say what they have done will either move the bricks forward or out of the pyramid.

Agile Goals DailyProgress
Check the daily progress. Should be more yellow bricks. The red ones are out of track

By having this visualization, everyone is more aware of what going on and how far they are closed to the delivery without reading a whole bunch of words.

At the end of the meeting, we should expect this happy face. If not, we should draw a sad face, honestly.

Agile DailyMeeting HappyFace
A happy face we should expect at the end of the meeting

It depends on the creativity of each team to make the visualization alive. The more creative the better they will remember.

Task Based Completed

Put aside the requirement of having a good user story. Because we do not have that much luxury. The reality is that most of the time, we do not have a clear requirement, a well-written user story. That causes some problems. One of them is the feeling of getting thing done. Having spent more than 8 hours per day, working hard on the job, and the next day, we cannot proudly say what exactly we have done. We are kind of aware of what we did, but fail to name them.

To improve the situation, we came up with “Task Based Completed“, known as “The Golden Board“. In the Standup Meeting, your face should be on the board. There is no rule, no punishment, nothing required. Simply your face should be on the board. If not, not a problem, see you tomorrow. Again, your face should be on the board.

There are some benefits with this approach.

  1. Encourage the cooperation and design. To breaking down in to small delivered tasks, they have to cooperate with each other and in that process, design the system. Tasks become your technical design documents.
  2. Short error prone detection cycle: While implementing a task might spot a fraud in the design or requirement. The sooner the better.
  3. Feel good. We know for sure that we have done something; that we get the job done; that we move things forward; that we cooperate with others.

One of the key point to make this system works is to make the task creation/completion super easy. In other word, do not put processes in the task creation. Task creation should be easy as creating a task in to-do list application. However, one should be improving the task’s name. The task’s name should be clear and understandable to the creator. Again, there is no requirement for others to understand others’ tasks.

 

Final Thoughts

Tools are tools. They are their to help us, human being, do our job. Each tool solves a set of problems. Before applying any tool, make sure we analyze our problems first.

When come to the teamwork, the most important factor is people, not tools/processes. Do not throw a tool to a person without instruction/training.

Boy Dig a Whole
Boy, here is the hoe, dig a whole.

Have a good week!

 

Mind, Body and Spirit

The only thing in this universe that we have control over is ourselves. Speaking another way, we have the full power on ourselves. For things to change you have to change yourselves, people said.

Yeah! I know I have full power on me. I have to change me (I wrote me on purpose). But, what exactly should I change/improve/focus on? How do I get started? To get started, we need more concrete detail than a general statement.

I am pretty sure that many people have heard about that statement. However, they have not still made any progress on their life. Why? Maybe, yes just maybe, they have not had a clear idea of what it means, what they should start with. Therefore, they might choose to know and let it go as any other events in life.

Since I have started a new journey of Personal Development (sometimes I called it Personal Excellent) some years ago (around 3 years). I have read books about the topic, applied and experienced in my daily life. I have made a good progress. Which encourages me to try more, experience more and as a result, share more. Sharing is a part of Personal Development.

A human being has 3 parts: Spirit, Mind and Body. They are all equally important. Do not neglect any.

I am sure there are books talking in detail about them. However, I choose to explain them in the way it makes sense to me; in the way I understand them.

Spirit

It is our mental assets. Everyone has their own relationships. We have parents, children, spouse, friends, coworkers, classmates, … Some people have plenty of good ones. Whereas some have a few or none.

To leave a good life, we have to built up our mental assets. As any other asset, mental asset can come and go if we do not build/protect it. I have a few suggestions

  1. Assert your current relationships. Simply write them down will make a huge impact on your thinking. Not believe me? Try it.
  2. Priority the relationships that you value most.
  3. Focus on improving them. Sometimes a phone call might help.

There are things that make us feel better such as favorite songs, movies, …

It is our attitude on life. Some looks at life with an anger eye. For some people, everything is so annoying. They hate everything. They have a pessimistic opinion. But, there are people who see life joyful. Every event is a gift, no matter how bad it is.

You do not have to cheer for a sad event. You do not have to cry for a good event, either. Develop yourself to have the right attitude on each event.

Same event, different reactions, choice is yours.

Mind

It is our intelligent assets. It is our knowledge, our skills. Unfortunately, many people that I knew, spoke to do not care much about this (Yeah, maybe I have not met enough people).

My favorite question that I usually ask myself is “what have I learned since the last year?“. In any job interview, I asked candidate the same question. Sometimes, I felt one year was too short, I asked them: what have you learned since graduated from the university?. Not many said it fluently.

What have I learned since the last year?

Are you dare to ask yourselves that question?

You should have a plan for your mind. Otherwise, you will stay behind. We are leaving in a fast changing age. The information is on over the internet.

Some might say “I do not have time and money to learn.”

Oh really! Are you sure?

Body

It is our health (not the body building part 😛 ). It is not the good looking appearance (of course if it is good, then perfect). With the fast growing of internet, mobile devices, IoT, everyone seems too busy.

I do not have time to exercise“, they claimed. If a 70 years old, laying on the bed (or hospital) says it, I believe.

We can build up our Spirit, improve our Mind anytime. But we cannot do the same with Body. The body has time constraint. Therefore, you cannot delay it for tomorrow. If you delay it too long, you will reach “I do not have time” soon. In other word, it is too late.

Suggestion? Yes. Do whatever it takes to build a habit of improving your Body (the health) NOW. Keyword is NOW.

 

Everyone is unique. Each has their own life, their own way of living. If we choose to think that we are victims of circumstances, then we have no power to improve. But if we choose to think that a human being has 3 parts Spirit, Mind and Body; and we have full power on them, that we can control and improve them; we will make a huge difference on our life. In fact, circumstance is the result of our actions. You reap what you sow.

Spirit, Mind and Body! I hope the post will give your some ideas to think over the weekend and get you started if you choose to. Once you choose to do it, you will find out how to do easily.

Have a nice weekend!

Performance Improvement – From Thousands Queries Down To 1 (or 10)

One day, you got a performance bug report. The report said that the customer got a timeout issue. Because the system database is SQL, you open SQL Profiler and monitor what happened inside the SQL server when a single button clicked.

Right in front of you opened eyes, there are more than 7.000 (yes, seven thousands) queries executed to serve a single request. The request is to search a list of records, and there are more than 2.000 records returned__seven thousands queries for two thousands records.

The system is a typical client – server application. The server side is built with WCF + NHibernate (SQL). The system has the notion of CQRS. NHibernate is used to manage domain object with mapping to the database. Therefore, the request (search records) belongs to Query side.

Root Cause

Lazy Loading! It is not hard to figure out the root cause. We use NHibernate to conduct a search query and load all the found records. Here is a simple overview of the architecture.

Architecture Overview
Architecture Overview

The problem happens at the map between domain and view.

Solution

Quite simple. Follow these steps

  1. Define the Model that contains enough data for the View. Note that I am talking about Model not Domain.
  2. Define a SQL View that collects all the data to serve the Model.
  3. Use NHibernate to load data from SQL View instead of Domain.

The general idea is that we should get enough data in a single or two queries.

Lessons Learned

Command and Query Separation

Even the architecture says CQRS notion, there is no real separation of Command and Query. They share the same data model (the domain). The Domain should only appear and use in Command side only. And the Query side, there should be a notion of Model. Domain holds the business logic of the system. Whereas, Model models the read data of the system.

Martin Fowler Command Query Separation.

Overused Tools (NHibernate)

NHibernate is a great tool. However, just like other tools, it has good and bad scenarios. I am sure NHibernate is not a good fit for searching data just to returning partial data for clients. In the example, NHibernate is used to search for list of records, take some of information, and transfer to a view.

However, if we decide to use NHibernate to for this job, then we should read about Select N+1 problem.

Utilize Our Tools (SQL)

We tend to depend so much on ORM framework that we forget how powerful SQL Server is. By defining a SQL view for search request, we can utilize the SQL server. Later we can ask DBA experts to improve SQL performance without redeploying the application.

Final Thoughts

Today, there are thousands of tools at our disposal. We should choose them wisely. Otherwise, there is a big payback in the near future. Every tool has its advantages and disadvantages. You do not have to know them all. However, you should consider studying them before using.

The more I code the more I love CQRS principle. At the highest, it is about Separation of Concern.

I have introduced some concepts in this post. Just in case you have not known about them yet, here are some references:

CQRS on MSDN

CQRS Martin Fowler

SO Select N+1 Problem

CodeProject Select N+1 Problem