Thursday, December 22, 2011

Why I decided to take Scrum training?

Yesterday I registered an Certified Scrum Master training.  I choose the seminar on Jan 12, 2012  from Berteig Consulting.  Actually I am not so interested in SCRUM, rather I am super fan of Lean/Kanban, XP and software craftsmanship.
I have a bias on SCRUM because I feel its process is oversimplified, and focus on manager side only, ignores developer side; and it lack the whole picture of Lean and flexibility of Kanban. Another reason is so far I did not find a good SCRUM example in my past experience, so I really doubt the its performance.
The third reason is recently I found many articles which pointed out the issues of SCRUM.

As a many years of working experience as a software developer, I really doubt a certificate is useful.  I don't think that you will become an SCRUM master just for 2 days training, which means master Agile philosophy is too easy.

But recently I changed my mind, and decided to get a SCRUM Master certificate. You may wonder why I changed my mind so quickly.

Why learn Scrum?
1. I realized that the current IT situation is that  Scrum is still the de-facto process, even though Lean/Kanban is really hot inside the Agile community, but outside of the community, Scrum is still the most popular one. I will say 90% of the IT managers does not know Kanban. They are  more familiar with SCRUM.  If you have a Scrum training or get a certificate, it will be helpful for your career path. My long term goal is Agile coach, so I hope I can use CSM as a business card to help me find better jobs.

2. I hope the CSM certificate can help me make changes in my company. 6 month earlier, I tried to suggest to my managers thinking of using Lean/Kanban, they are familiar with Scrum, but not Kanban. I found I get stuck, because I don't know how to persuade them, since neither I have Kanban experience, nor I have Scrum certificate. Now there are 3 Scrum Master in our company. I hope if I have a Scrum certificate, then I could use their familiar "Scrum" language to communicate, then it would be easier for me help the company to transform from Scrum to Lean/Kanban.

What do I want to know about Scrum?

  • Clear the misunderstandings about Scrum;
  • Focus on the principles and philosophy behind Scrum;
  • Figure out the fundamental assumption which support Scrum;
  • Find out the good and bad parts of Scrum;




Monday, December 12, 2011

Cynefin framework and software code

Recently I read some article about Cynefin framework, it is really inspiring. As the diagram shows, cynefin framework categorize the problems in to 4 domains:

  • simple
  • complicated
  • complex
  • chaotic
For different domain, the approach and strategy are quite different.
Today I would like to analyze the software code using cynefin framework.

Which domain does software belong to?
In General I will say software belongs to complex domain. One reason is software product environment changes so fast, the other reason is its entropy nature: always grow from simple to complex. Software product is so hard to predict and plan. That is the reason why we choose agile methodology: we follow TDD, keep refactoring, iterative developing and continuous integration. These methods are to deal with rapid the software's rapid changing context.
Let's compare the complex domain with agile practices:
complex, in which the relationship between cause and effect can only be perceived in retrospect, but not in advance, the approach is to Probe - Sense - Respond and we can sense emergent practice.
Here The probe - sense - Respond is same as TDD and iterative development, since we don't understand the domain, so we have to rely on immediate feedback.
And the emergent practice and retrospection, which is the same as refactoring, refactoring itself is emergent practice.

We can also conclude that the reason why waterfall does not working is because they assume the problem domain in software is always in simple domain.  

How about other domains?
If we don't care code base and let it grows, then code base will becomes more and more complex until it becomes chaotic. As a developer we all have the experience of working with messy legacy code base: the messy code is hared to understand, hard to maintain; you fix one issue, then will generate another issue unexpectedly; the software is unstable, a small change will cause a big issue; the issue is always unpredictable;nobody understand the system; we spent all the time putting fires. Which is totally unstable and uncontrollable. These symptoms fit nicely with the chaotic domain model.

But if we keep writing clean code, the code are easy to understand, easy to maintain, easy to change. In agile world writing clean code also means simple design. So this  will fit nicely in simple or complicated domain. Since they are both ordered. so they are manageable and controllable. That is software's ultimate goal -  flexibility, maintainability and reusability. So we will say clean code will help the software reduce the complexity.

Why clean code will help reduce the complexity?
The following tools and method help us writing clean code:
  • SOLID principles
  • high cohesion/loose couple
  • Design patterns
  • DRY principle
  • LoD principle
  • Refactoring
Lets' dig them deeper:
Break the unnecessary dependencies
   Uncle Bob once said writing software is all about dependency management. SOLID principle, high cohesion/loose couple means reducing dependencies. We all know that the more interactions between objects, the more complex the software will be, so reducing the dependencies means making the software simpler.
- Set Rules and Constraints
  Design patterns basically is describing the rules of the relationship between objects in a specific context. To make software reusable, stable and manageable, we do not allow objects interact each other randomly, they have to follow certain rules. This is quite similar in human society, we have to maintain the orders via laws, rules or regulations. 
Encapsulate changes
   One of the advantage of design patterns is how it deals with change: encapsulate changes. Which means when we identify a concept which it changes, then we encapsulate it by putting it into a class.  we don't want them randomly change. we put them in a box, isolate them. Once we put those details evil in the box, then we can understand or control the system by using abstraction. Then the system becomes stable, manageable and controllable

Conclusion
  • In General software belongs to complex domain. The agile practices are the right practices to solve the complex domain problems;
  • Writing clean code will help us reduce the complexity, will move from complex to simple/complicated domain;
  • Writing messy code will increase the complexity, will move from complex into chaotic domain, this is what we are trying to avoid.
Strategy
So our strategy will be constantly refactoring our code base, keep code clean, avoid messy code.

Resources

Saturday, December 3, 2011

How javascript call java in Phonegap android


Phonegap is a great mobile solution, since I am working in Grapple mobile now, our platform use quite similar solution with Phonegap, so I really want to learn Phonegap to see if we can steal some ideas from it.
What troubled me a long time is in its android platform: I wonder how does its javascript code calls java native code? Before I tried to read its android source code, but did not find the answer. This week I spent some time on its source code, finally I find the answer. I would like to share this result with you, this might be valuable especially if you want to dig more to phonegap, since I seldom find the answer from google or books about phonegaps, none of them talks about this.

The phonegap source code I checked out is from github, the current version is 1.2:
1. phonegap android source code: https://github.com/callback/callback-android
2. phonegap platform sample code: https://github.com/callback/phonegap

Digging the source code
From phonegap-1.2.0.js

For example looking at accelerometer:  in javascript layer, the accelerometer is implemented by calling Phonegap.exec() method:
The PhoneGap.exec() method will be like this: So the exec method will invoke a javascript prompt()- which is popping up an dialog, huh, it sounds weird.

Let's look at the java code:
Inside com.phonegap.DroidGap.java, find the inner class GapClient, which is a subclass of WebChromeClient, it override the following 3 methods: onJsAlert(), onJsConfirm() and onJsPrompt()
Here we only look at the onJsPrompt(), look at the android API for onJsPrompt():
Tell the client to display a prompt dialog to the user. If the client returns true, WebView will assume that the client will handle the prompt dialog and call the appropriate JsPromptResult method. If the client returns false, a default value of false will be returned to to javascript. The default behavior is to return false.

So it is quite clear that: if prompt() is called in javascript layer, then onJsPrompt() method will get invoked in java layer. Phonegap just uses this way to handle the javascript to java communication.

Let's look at the onJsPrompt() method in details:  So here the phoneGap PluginManager will delegate the the javascript call to different native plugins.

From the article of http://stackoverflow.com/questions/7251557/phonegap-and-prompt
and phonegap release note: http://phonegap.com/2011/04/28/phonegap-0-9-5-released/, it mentioned that
Worked around JavaScript bridge exception for Android 2.3. Use “prompt” instead of calling objects directly.
So it seems that this is a workaround for an issue in Android 2.3.

Summary
To recap, this is the flow of javascript call java in phonegap android is like this:
1. in javascript layer, all the javascript method will finally delegate to Phonegap.exec() method
2. PhoneGap.exec() will call prompt()
3. In java layer, DriodGap.GapClient override onJsPrompt(), which will capture the prompt() method call in java, which then delegate to PluginManager to invoke the native java method call.