Saturday, January 30, 2010

Focus on Workflow instead of plans

Recently I watch the Mary Poppendieck's video "The tyranny of the plan", which is another good video about agile. The key point of the presentation is - Focus on the workflow instead of the detailed plans
I put some of the notes here:

3 main principles:
  1.  Design the system to meet the constraints; do not derive constraints from the design.
  2.  Decouple workflows; break dependencies!
  3. Workflows are easier to control & more predictable than a schedules.
Mary used the Empire building example is used to support the principles:
   Start with the constraints, then design the system to meet the constraints;
   design based on the schedule (constraints);
   schedule does not depend on the detailed design.

What I learned is that the system design depends on constraints, which might be resource, schedule and cost, etc. while schedule should not depend on design. This is a 180 degree reverse of the mindset change.
  
The problems of the schedules.
We need schedules because:
 -  To control when things happen, but
     Detailed schedules are deterministic and do not allow for normal variation.
     Managing a level workflow is a lot easier than following a deterministic schedule.
 -  To predict when things will happen, but
    Schedules based on experience are reliable; if it is based on wishful thinking are not
    When reality does not match the schedule -  the schedule hypothesis was dis-proven!
 
 The workflow is more flexible, always updated based on the situation, "plan is bad, planning is good"

Pull scheduling
 Mary also mentioned the pull scheduling, pull scheduling is time-boxed:
 don't scope box,  don't ask how long will this take, ask what can we done by this date?
 I think which is the concept from Lean/Kanban. I will check it in detail later.

 Resources:
 1. Presentation video
 2. PPT, which is different from the presentation, but actual concepts are same.

Tuesday, January 26, 2010

My Vision of the future mobile platform framework

Develop a mobile application is painful, develop a portable mobile application is really hard. I've been a mobile developer for many years, and I am struggling many years to make them portable to different platforms. To deal with fragmentation, which is the nature of mobile platform, my vision of the future mobile platform framework would be:

Support multiple platforms
support J2ME, iPhone, android, blackberry, Windows Mobile, etc. One solution supports multiple platform, which will makes our life much easier.  I hope new new framework will provide a more abstraction layer, then developer can only write one piece of code can support all.

Separation of concerns
- Separate platform independent logic from platform specific logic
- Separate application logic from specific user interface
The platform specific logic should be encapsulated as component modules, and developer should not care more about their details. Think about the IC and drivers, our mobile application is like a computer mother board which plug different cards and installing different drivers.
The concept of separation of concern reminds me of how GIS works, GIS map is composed of maps in different layer, each layer map focuses on a specific concern, same as the mobile application, the mobile app will be composed of different layers, UI layer, business logic layer, model layer, etc. And each layer can be easily modified and plug-in. Then graphic designer can focus UI, generate the rendering logic; BA focuses on business rules, generate business logic, then developer integrate them all into one application, and each layer can be easily changed and upgraded.

Easy to customization
The mobile framework should takes the advantage of different platforms technologies. we should not do the way of common denominator, like J2ME MIDP widget, which is a bad example.

Open and easy to integrate with other libraries
The new mobile platform should be open to other framework or library, it should be easily to integrate with other libraries. for example, developer can integrate different UI libray easily, like LWUIT, SVG, oepnGL, etc. and the mobile platform does not want to reinvent the wheels, it focuses on integration.

Follow agile
The mobile framework should be agile, which means
- support TDD, provide a mobile unit test framework or support 3rd party test framework
- Encourage short feedback, the mobile framework provides powerful simulator which can simulate different platforms, developer can easily to know what is going on for his application, and it is also a good demo and presentation to our costumer, the simulator can be run inside the browser so that it is a good demo for end users.
- provide build and deploy automation, since different platform has different SDK and build tools, manage them is a nightmare, having a build automation tool will greatly improve the developer's productivity and speed up the application development cycle.


Several possible technical paths:
- DSL/Code generation 
  Define a mobile Domain Specific Language,  then generate the native source code for different platform. we can use Ruby or ANTLR. I like the idea of code generation, because it can meet the needs of different platform, and can easily to implement the AOP

- Use web based script languages
  Using html, xml, CSS, java script, then render in the browser or using parser to generate the native source code. This is also a good concept, actually there are already have several open source project doing like this, for example PhoneGap,but what I really worry about are: 1) How to address the fragmentation for each platform; 2) to solve the question 1, may leads to common denominator issue. For this reason, I really doubt the JavaFX Mobile framework, because there is no way to handle the fragmentation issue in script language level.
 
I hope in the near future, I can do something for the new mobile platform. I have a dream, in future: UI designer, BA, developer and QA will share the same framework, each works on his own part, then developer integrates them by pressing a button, then generate mobile applications for different platforms, hope this won't take long.

Thursday, January 21, 2010

How to add a J2ME 3rd party library into your NetBeans project

Scenario
You need to port our J2ME application to a specific platform, either Nokia, Samsung or LG, etc. You have to use OEM's specific API to implement a feature, but that special API is not included J2ME standard library, nor included in the OEM's J2ME SDK. You got an ZIP or jar file of the API library, but mostly it they are just stub classes, the only real implementations are inside the actual devices. What you need to do is adding the library in your project class path, but without including them into the J2ME jar file.

Solution
In NetBeans IDE, You can add the libray of zip/jar file in your J2ME project without including in the packaged jar file. Here are the steps:
  1. Select your project, right click mouse, choose "Properties"
  2. Select Build - Libraries & Resources, click button "Add Jar/Zip ...", then select the libray file you want to add, press "Open"
  3. You will see the library file is included the file/folder list, pleases make sure uncheck the "Package" checkbox, this is the most important step, it will tell IDE don't include this jar/zip file into your J2ME jar file, or IDE will not build successfully, because it can not find dependencies packages for the libraries. The screen shot is attached at the end of this article.
  4. Select OK, and build your J2ME application 

Java ME SDK 3.0 review

Last week I spent some time on Java ME SDK 3.0. One of my application need to support both landscape mode and portrait mode, currently J2ME wireless toolkit does not support the feature of changing the screen orientation, I heard that Sun's new JavaME SDK V3.0 emulator support changing the screen orientation, so I installed it and hope it will help my work. but unfortunately I feel disappointed.

Issue of integration with NetBeans IDE
After installing it successfully on my windows machine, I tried to add the SDK into My NetBeans 6.1 IDE, and then later I realize that the all the tools and Prefrence setting of the SDK 3.0 are disabled in my NetBeans IDE. which means you can not profile, clear database, change emulator settings inside the NetBeans IDE.
At first I thought maybe due to my NetBeans version is old, so I installed the Netbeans 6.8, which integrates the Java ME SDK 3.0, but I found the same thing; and I also tried the NetBeans 6.5.1, it is still not working. I also found this thread in a forum about the same issue I found in NetBeans 6.7. I don't know when Sun will fix this issue, but I do know that if this issue is not fixed, then few developer will use the new SDK, since so many mobile developers are tied with the NetBeans IDE.

Lack of the options to launch the emulator
For the emulator, I need a scenario that my application launched in a landscape mode, but I did not find there is any setting in the SDK allow you to do that, it always start as portrait mode.While Nokia S60 3rd SDK already supports this feature. Sun should provide this feature both in GUI menu settings and command line.

Failed to debug
I tried to debug my application by setting a break point using the SDK 3.0,I tried twice, but no luck.

No document to describe how to customize the emulator
 Compare to WTK 2.5.x, the SDK 3 changed a lot for the emulator file structures, I realize it becomes much more complicated than before. For WTK 2.5.x, it is really easy to customize the emulator, I now how to change screen size, how to enable touch screen; but for SDK 3, I don't where I can start,I hope Sun could provide an official document to describe the architecure of the new emulator. I found this article about customizing the emulator in SDK 3 in Java ME SDK team blogit might be useful.

Based on the reasons of above, I don't think the current version of the JavaME SDK can help me for my application development, so I have to change back to WTK 2.5, and use Nokia's S60 emulator, even if it is slow,but at least it works. It seems Sun has a long way to improve its new mobile SDK.

This artcile is based on windows version, I haven't touch the Mac version and Linux version yet.
 
Related links:
  1. Java ME SDK integration in NetBeans 6.7 
  2. How to create a custom device 

Sunday, January 17, 2010

Ruby and AOP

Right now I am learning Ruby, I focus on Dave Thomas' famous pickaxe Ruby book, last week I just finished the chapter 24: "Metaprogramming".Now I learn the power of Ruby Metaprogramming, right now it is still quite difficult for me, I am sure I will read this chapter over and over in future.

Today I want to discuss my impression of AOP concept in Ruby.
I learned AOP from java, in java you have to use AspectJ or Dynamic Proxy implement AOP. But comapre to Java, I realize Ruby support AOP in the lanuage level:
  • Classes are open: you add new method or attribute for any existing class, or replace the method with new one.
  • Module and Mixin: you can easily add new functionalities by Mixin the module.
  • MetaProgramming: you can dynamically define a method on the fly, using hook method as call back, easily implement before, after and around advice
I feel by using the above technologies, it is quite easy using AOP concept in Ruby, for example you can easily implement a Logging Aspect in a Module, then get it mixin in your application code.That is separating of concern, which is the essence of AOP.
So I will say AOP is built in support in Ruby language level.

Today I found a blog called "Does Ruby need AOP?", the author argue that Ruby metaprogramming is not AOP,because he think AOP is all about semantics, while Ruby metaprogramming is too low level. I feel this argument is too academic, from the pragmatic perspective, I think as long as Ruby can do the job of separation of concern, then it is AOP, then who care about the semantics?

Here are some useful links:
  1. another blog about ruby and APO at 4 line of code
  2. slide: AOP of Ruby

Sunday, January 10, 2010

Customize Your J2ME Emulator

Why do we need to customize J2ME emulator ?
As a J2ME mobile developer, you have to port application to different devices,  while the J2ME default emulator only provide 4 different profiles, which can not meet our needs, and also some platforms like BlackBerry, Nokia S60 etc, the J2ME emulator they provided are really slow to launch, which is really inconvenient. If you can customize the emulator to support the device you are porting, which will improve your developing productivity.


Where are the emulator device profiles located?
 For example, if you installed wireless toolkit 2.5 in c:\WTK25, then the device folder is:
C:\WTK25\wtklib\devices

The mobility package is included in the NetBeans 6.5 or later version, the wireless toolkit folder is like this:
C:\Program Files\NetBeans 6.x\mobility8\Java_ME_platform_SDK_x.x

Create a new emulator device profile
I like to choose Sun Wireless Toolkit 2.5, because its Qwerty Device emulator looks better.   For example, if I want to create a device for Black Berry 9000:
1.  Copy the entire folder of  “QwertyDevice” to a new folder, rename the new folder name to “BlackBerry9000”
2.  Go inside the folder, rename the Qwerty.properies file to BlackBerry9000.properties

Enable the touch screen
The touch screen feature is disabled for J2ME default emulators. If you want to enable it, you need to modify the .properties file. In properties file, find following statement:

      touch_screen=false

Change false to true will enable the touch screen.

Change the screen size
For example, for BlackBerry 9000, its screen size is 480x320, then go to .prperties file, update the following values:

    screenPaintableRegion.width=480
    screenPaintableRegion.height=320

    and ..
    screen.width=480
    screen.height=332

Please note that you need to make sure:
   screen.height >  screenPaintableRegion.height + screenPaintableRegion.y
   In the properties file, screenPaintableRegion.y=11, so the screen.height value is 332.

   If you don’t put the correct value, the emulator will throw exception once it is launched.

Make your customization available in NetBeans IDE
Once You finished the customization, you need to update your NetBeans IDE environment:
  1. Select Tools – Java Platform,  choose Sun wireless toolkit 2.5, click Refresh button
  2. You will see the device names  you added in the device folder

Conclusion
You can easily customize J2ME emulator by modifying the .properties file, even it is really simple, it can improve your productivity considerably.

Further steps
This article is only focused on Wireless Toolkit 2.5.x , Sun released the new wireless toolkit 3.0,  the device emulators are changed a lot. I need to do more investigation on 3.0 emulator in future..