Notes about PersistJS

After I tried to use PersistJS, I am impressed. Then people are asking me to write-up my findings. So, here are my notes about PersistJS:

The first recommended reading is Why This is Awesome section. It makes a good case why you should use PersistJS. One interesting aspect of PersistJS is explained in its README: “Each backend is wrapped by PersistJS and exploses the exact same interface, which means you don’t have to know or care which backend is being used.” This means that you are not limited by a single technology and this enables you to adopt to a different storage easily. This statement might leave you with the question about which one does PersistJS choose? To answer this question, I found the order which PersistJS chooses a back-end store:

  1. gears
  2. localstorage
  3. whatwg_db
  4. globalstorage
  5. flash
  6. ie
  7. cookie

In my first implementation that uses PersistJS, I did not load extras/gears_init.js or extras/swfobject.js, this means that google gears and flash back-end stores are not enabled in my use of PerisstJS. With this setup, localstorage becomes the first one that persist JS attempt to store data.

PersistJS uses HTML 5 localStorage DOM attribute to implement its localstorage storage. HTML 5 is a new specification in draft state now. localStorage is one of the two storage mechanisms introduced, which “is designed for storage that spans multiple windows, and lasts beyond the current session.” The the storage format that HTML 5 exposes are key/value pairs. Both keys and values have to be strings. For further reading, see specification draft.

If you are an Ext JS user, you can use PersistStateProvider to persist UI state and application data.

A quick scan of “The Future of Programming Environments” article

Andreas Zeller‘s “The Future of Programming Environments”, provides an high level overview on the current trends of development tools. In this article, Zeller stated that development tools are evolving from extensible frameworks that supports integrated tools and their automation to “automated assistance in all development decisions”. Zeller further pointed out many known techniques that collects data about a piece of code in both static form and during run-time, then apply various automated analysis techniques that leads to visualization, statistics, data mining and machine learning to increase the productivity and code quality.

The paper serve more of a “review” or a “digest” of current trend of tools development than a “research” paper. Zeller certainly stated various recommendations that can serve as “best practices” for developers of tools. I would treat these recommendations as more of “common sense” than “design patterns”. This certainly is a good introductory paper with some interesting ideas and examples on what others have done in the tools space.

NetBeans 6 beta 1 is more JavaScript friendly than earlier releases

I’ve been using NetBeans 6 beta 1 for a while now. Today I just found out that if I am working on a static file such as a JavaScript file, all I need to do is to redeploy the project to the local server instance to see the changes. No need to rebuild or recompile. This is very cool. I don’t have to wait for the compilation of all that Java code in the same project to see changes in JavaScripts. This saves me a lot of time and I don’t have to go to a command line and do the copy myself. Again, very cool!

First impression on package mangement on Mac OS X

Ok. I’ve only used a Mac for a couple days, they were certainly long days with many steep learning experiences. Here are some of my comments:

On Mac OS X, you have several options to install an application. You can use pre-packaged binaries such as Universal Binary or a platform specific installable binary for your Intel or PowerPC based Mac computers. This class of binary is equivalent to setup.exe/intall.exe on Windows except this is much better at the first glance. From the user point of view the installation process typically involves double click or click OK/Yes until you are done, which translates to about 3-4 times and this is much shorter than most other installation steps that I am used to. To me, the impressive aspect of installing applications from pre-packaged binaries is the concept of drag-and-drop of a single icon into just about anywhere you want to install the application. Behind that, there are a lot of other complexities that is being abstracted out for the user. That level of simplification is an eye opening experience for me.

Working with installable binary directly by point-and-click your way through essentially means you are managing the application portfolios by you self. This reminded me of early Fedora days when I would go to different application repositories or web sites to download individual rpm packages. Having to manage individual packages you self can become a challenging task. At least, you may loose track of which packages are getting outdated and need to be updated. In the worse scenario, you may need to figure out all the dependencies you self and install them in the correct order. This certainly isn’t the most optimal way to manage a modern operating system. Even with extreme ease of use from UI point of view, I still have to do all the clicking on each package isn’t all that exciting.

Besides the regular installable binary, you can use a package management system, Fink. It provides both a repository for many open source software and a popular command line tool, apt-get, to easily manage the packages. apt-get is a very popular tool among Linux distributions and it made me feel at ease initially. What’s unusual to me about Fink is that it isn’t just a binary package management system, it can even handle install from source code, similar to how the emerge tool from Gentoo. You can configure it to use newer unstable version of the source tree and with a single line of command, you can essentially trigger the system to download the source package from the repository, compile and install the compiled binary in a sequence that satisfies all dependencies. In addition, all software are installed in an isolated directory so they do not conflict with any existing software you may already have. This essentially is the same approach as‘s way of manage applications. Fink combines many great designs and features among many modern package management systems and it certainly looks great on paper.

In practice, I found it also suffers similar issues as emerge on Gentoo when you venture beyond the stable binary into unstable source packages. A software package may fail to build. If a such error does occur, the user may have do some heavy-weight lifting to troubleshoot the error. I did tried to build Gnucash and it failed on me. One big difference that I found between Fink and Gentoo’s emerge it it’s community. When I encountered an error when attempting to install or upgrade a package, all I had to do was go to Gentoo’s we forum and past the error message. Most of the time, I would see people’s discussion about that specific error. Many would post suggestions and solutions. Having such “howto” materials available EASILY was really useful, important, and educational to me. on the other hand, my first impression with Fink when venture out to the unstable tree has left me stranded for several days so far. It appears to me that the community activities among Fink circles wasn’t as active as other forums among major Linux distributions that I’ve worked with. So, be careful when you are thinking of turn that switch to unstable tree. I would advice you to do some search for support materials first.

In addition to Fink, you also have the option of Macports, which is a source based package management system. It requires you to download and install Xcode, a free development tool from Apple. Xcode basicly contains gcc compilers, an IDE and utilities that are geared toward developers to write applications for Mac OS X. At about 923MB download size, Xcode certainly makes Macports a much more heavyweight than other package management options. Macports works similar to Gentoo’s emerge command, except you use port command to install applications. One thing typical of a source based package management system is that it takes a lot of CPU cycles to build each application from source. If you don’t mind keeping your computer on and generating heat for extended period of time, such “need” should not bother you much. If you are mobile or have a need to shut down your system form time-to-time, you may wish to plan your windows of opportunities to use Macports. This means less practical for laptop users, who typically have a need to shutdown the laptop from time-to-time.

Furthermore, Macports is only single threaded. This can be both a good thing and a bad thing for dual-core CPU owners. It can be a good thing because you will have the other core doing something else while one core is busy working for Macports. It can be a bad thing if you don’t need to use the other core and wish that Macports can take advantage of all the processing power you have. To me, this is where I wish to see Gentoo’s behavior. Back when I had only one slow core running Gentoo, the system can be 100% busy compiling sorce code while I do my regular light-duty Internet browsing and emailing without feeling any lag. I could even pushed the system a little by watching a video, which normally pushes CPU utilization higher on a slow CPU. The trick that Gentoo did was to set the priority of the activities emerge to low to avoid slowing down any user activities. If Macports can do something similar while multi-thread the compilation process, it will be a lot more efficient, especially with the new quad-core CPUs.

In my short experience with Macports so far, it has failed to install Gnucash and MySQL correctly for me. Such efforts cost me many hours of troubleshooting and searching through the Internet for possible solutions. The out-of-box experience certainly left me underwhelmed when comparing to rest of the OS or even to popular Linux distributions.

Am I bitter? Not at all! This is kinds of stuff I deal with every day and I am learning a lot going through all these hoops. If I don’t try to experiment with all these technologies, or attempt to break it, I won’t know how it works. ;) Even if I end-up not able to resolve some of the issues, I learned to appreciate with a sense of accomplishment when I am able to solve some of these wicket problems or finds a much easier or efficient alternatives. Such as installing MySQL from a pre-build package in .dmg format, than trying to agonizing over the issues when using Macports or found out after the fact that Fink’s MySQL is one release behind what I need. :)

webtest and jWebUnit: first impression

I spent a little bit of time check out both webtest and jWebUnit. Here are my first impression:

webtest is declarative and XML configuration file driven. If you like configuration management more than programming, you might like this format. All you need is edit the test definition and hit the run command, no compilation necessary. If you have well formed HTML and working JavaScript, then you should not have too much trouble running this. My initial simple test case works once I commented out the non-working and irrelevant JavaScript reference in the HTML. I tried to take another mini-step forward by attempting to “configure” a click to select one of the link items in a JavaScript widget. Webtest has 3 ways to click on a link, by ID, label, or xPath. The widget’s link item doesn’t have an ID, so I can’t use that. I tried label and that didn’t work. Then I tried xPath and that didn’t work for me either. So, that second mini-step didn’t go very far for me. Any one know an open source xPath validation tool or web site?

jWebUnit is one of the many unit testing frameworks based on jUnit/HtmlUnit. The interesting aspect of this framework is that it supports both HtmlUnit and Selenium test cases. jWebUnit uses similar programmatic model as jUnit, so you can stay comfortable within your favorite IDE. I was able to create a new project in NetBeans and leverage it’s jUnit feature, by creating an unit test and rewrite that as a jWebUnit test case, while using NetBeans to drive the test execution. jWebUnit, or the underlying HtmlUnit engine appears more picky about JavaScript than Webtest, I had to start tweaking YUI libraries in an attempt to load a page, which shouldn’t be something that I supposed to be doing anyway. Perhaps YUI engineers use a different unit testing framework. The test page actually loads without a major issue in Firefox.

Both frameworks do share one thing in common, both do not use actual browser instances to drive the testing. And that explains why they don’t work as well as some of testing frameworks that built within or on the real browser instance because of behavior differences when processing JavaScript. At the same time, both may have one advantage over browser based testing framework, which is the ability for non-interactive testing through ant and is very useful for continuous integration servers such as CruiseControl. Again, I’ve only looked a few testing frameworks and let me know if you know a browser based unit testing framework that works with ant. Thanks.

Comments and notes on Wikinomics (part 1)

A person I know urged me to read Wikinomics by Don Tapscott and Anthony D. Williams. So, I started reading. So far I read chapter 1, 4, and 5. I agree with less cheerful reviewers of this book (here and here) that this book probably doesn’t worth my time spent reading it. I actually agree the general theme presented by the book (what). I just wasn’t so thrilled by the way authors presented their ideas (how). One of the reviewers, Timothy Haugh, clearly pointed this flaw out by saying “Wikinomics suffers from a common malady among these ‘cheerleading for the future’-type books; namely, that what they take 300 pages to say could have been more easily and better said in about 60 pages.” Other than a few interesting anecdotes and catchy slogans, I didn’t feel I am learning something new and useful.

Here are a few notes on interesting anecdotes and catchy slogans:

* Low-cost of entry: Page 12: “What’s more, people can contribute to the ‘digital commons’ at very little cost to themselves, which makes collective action much more attractive.”
* Page 12: “A world where only the connected will survive.” This is digital divide and the authors says nothing about how to bring in the un-connected world.
* Globalization: Page 14: “Today 180,000 people work, live, learn, and play on Foxconn’s massive high-tech campus, designing and building consumer electronics for teenagers around the globe.” How this related to the central theme of the book? Did the globalization of FoxConn happened because of wikinomics or could it happen even without wikinomics? This reminded me the following sentence from “What Got You Here Won’t Get You There” by Marshall Goldsmith and Mark Reiter, “I’m talking about the difference between success that happens because of our behavior and the success that comes in spite of our behavior.” (Page 26)
* Page 20: “The new art and science of wikinomics is based on four powerful new ideas: openness, peering, sharing, and acting globally.”
* Page 24: “BiOS (Biological Open Source License)”
* Page 26: “But if your invention can be replicated at no cost, why should anyone pay? And if no one pays, how do you recoup your fixed-cost investment?” Where is the answer?
* Page 27: “The first time Michael Powell, then chairman of the Federal Communications Commission, used Skype, he concluded: ‘It’s over. The world will change now inevitably.’” So what? The world is changing all the time. The old world telcom industry still exists today and are getting bigger. What’s the point here?
* Page 32: Prosumer = “producer consumers” This word has many conflicting meanings according to wikipedia
* Page 104: “In fact, virtually all companies with sizable patent holdings are now busy mining their portfolios, looking for licensing-out opportunities, and taking technologies off the shelf that can bring in revenue.” What’s so wikinomic about this?
* Page 107: “When the company finds those good ideas, Huston says, it brings them inside, where it can capitalize on internal capabilities to enhance or append the offering.” Isn’t this an old concept? i.e. acquisition
* Page 107: ideagoras = “they help link all of these individuals, companies, and organizations together by establishing connections and facilitating transactions between buyers and sellers of ideas and technology.”
* Page 114: “‘Open innovation efforts can die like a flash in the pan,’ says Stern, ‘because some senior executive says, ‘I’m giving you two people and an external budget of ten thousand dollars, and we’d like to see ten deals in the first year.’ It just doesn’t happen. It takes quiet a bit of time for these initiatives to mature.” Many people probably would like to show this to their upper management this statement. However, it convey no potential value and such argument probably won’t go very far without clear communication of value-add.
* Page 114: “Employees should also be rewarded for spotting and acquiring external ideas.” I would love to see this happen. At the same time, I don’t have high hope for this.
* Page 117: “Superior technology alone will not produce competitive advantage.” Next…
* Page 129: “But when it came time to rethink the telematic features for future models(such as GPS navigation), the company released a digital design kit on its Web site to encourage interested customers to design them instead.” We should let our customers design our products too! ;)
* Page 144: “Users exert editorial control by clicking on the digg button for each story they like. Articles that receive the most diggs are promoted to the homepage. And so the community collectively updates the front page. You could say the community is the editor.” We should let our users be the editor too!
* Page 146:

* Give users access to raw content such as interviews as a 
means of providing greater transparency and accountability.
* Provide tools and become a platform for user-generated 
rather than firm-generated content.
* Redesign all content to be a conversation rather than a 
corporation monologue.
* Treat advertising as content too.
* Use new distribution forms, including peer-to-peer networks.
* Adapt content forms and schedules to user demands.

* Page 148: “If you make it profitable for customers to get involved, you will always be able to count on a dynamic and fertile ecosystem for growth and innovation.”

First impression about ColumNav 1.0

Special thanks again to David Lindquist for adding a new feature in the most recent release of ColumNav 1.0, which is the ability for ColumNav widget to load arbitrary HTML in one of its columns. This feature can really enrich the widget to go beyond a tree listing of menu items.

Yes. You can certainly display arbitrary HTML. The HTML might render a little differently than when the same content was in a HTML page. For example, if you use a <div> in your arbitrary HTML, you might get a non-scrollable scrollbar similar to the example below:
Coumnav 1.0 with arbitary HTML

So, depending on what HTML content you want to include in ColumNav and what browser you use, your mileage may very. For me, <div> is not a must have for me. If I have more time to play with this, I may try to use other HTML elements instead.

Not so dynamic “Animated Collapsible DIV”

I had a lot of fun playing with Animated Collapsible DIV. However, when I wanted to dynamically insert the content of the collapsible DIV, it would not work. I realized that it would only work for static content that doesn’t change on fly. The Collapsible DIV is initialized at page load and doesn’t dynamically change size if the content in the DIV changes. Bummer, I wished it would do more.

Notes from “What Got You Here Won’t Get You There”

Marshall Goldsmith and Mark Reiter wrote a book “What Got You Here Won’t Get You There: How Successful People Become Even More Successful!” This book focus on 20 workplace bad habits and some key good habits. I enjoyed the reading enough to give a short speech on a few points in the book and won a best speaker ribbon for the day! :) I am including some quotes that I noted from the book. To really understand the motivation and explanations on these statements, you should get the book and read it!

Page 19: “This ‘I have succeeded’ belief, positive as it is most times, only becomes an obstacle when behavioral change is needed.”
Page 21: “The challenge is to make them see that sometimes they are successful in spite of this behavior.”
Page 22: “I will Succeed” may leads to overcommitment
Page 24: “I have now made peace with the fact that I cannot make people change. I can only help them get better at what they choose to change.”
Page 26: “Superstition is merely the confusion of correlation and causality.”
Page 28: “Pick a quirky or unattractive behavior that you habitually do, something that you know is annoying to friends or family or coworkers. Now ask yourself: Do you continue to do it because you think it is somehow associated with the good things that have happened to you? Examine it more closely. Does this behavior help you achieve results?”
page 29: “You can’t force people to work together. You can’t mandate synergy.l You can’t manufacture harmony, whether it’s between two people or two divisions. You also can’t order people to change their thinking or behavior”
Page 29: “People will do something — including changing their behavior only if it can be demonstrated that doing so is in their own best interest as defined by their own values.”
Page 31: “If you press people to identify the motives behind their self-interest it usually boils down to four item: money, power, status, and popularity. … Having achieved these goals, they turn to higher-level goals, such as ‘leaving a legacy’ or ‘being an inspiring role model’ or ‘creating a great company.’”
Page 40: The Twenty Habits: 1. Winning Too much, 2. Adding too much value, 3. Passing judgment, 4. Making destructive comments, 5. Starting with “No,” “But,” or “However”, 6. Telling the world how smart we are, 7. Speaking when angry, 8. Negativity, 9. Withholding information, 10. Failing to give proper recognition, 11. Claiming credit that we don’t deserve, 12. Making excuses, 13. Clinging to the past, 14. Playing favorites, 15. Refusing to express regret, 16. Not listening, 17. Failing to express gratitude, 18. Punishing the messenger, 19. Passing the buck, 20. An excessive need to be “me”.
Page 44: “As we advance in our careers, behavioral changes are often the only significant changes we can make.”
Page 49: The fallacy of added value: “The problem is, you may improved the content of my idea by 5 percent, but you’ve reduced my commitment to executing it by 50 percent, because you’ve taken away my ownership of the idea. My idea is now your idea — and I walk out of your office less enthused about it than when I walked in.”
Page 56: “The fact that a destructive comment is true is irrelevant. The question is not, ‘Is it true?’ but rather, ‘Is it worth it?’”
Page 61: “Being smart turns people on. Announcing how smart you are turns them off.”
Page 94: “A leader who cannot shoulder the blame is not someone we will follow blindly into battle.”
Page 95: “In that sense, being wrong is an opportunity — an opportunity to show what kind of person and leader we are.”
Page 98: “If he could shed his ‘excessive need to be me,’ he wouldn’t see himself as aa phony. He could stop thinking about himself and start behaving in a way that benefited others.”
Page 99: “It comes from misunderstanding what we want in our lives. We think we’d be truly happy (or at least happier) if only we made more money… So, we pursue those goals relentlessly. What we don’t appreciate until much later is that in obsessing about money, we might be neglecting the loved ones — i.e., our family — for whom we are presumably securing that money…”
Page 100: “It also comes from misunderstanding what others want us to do. The boss says we have to show ten percent revenue growth for the year, so when it appears we will miss that target, goal obsession forces us to adopt questionable, less than honest methods of hitting the target… If you examine it more closely, we’re not really obsessed with hitting the ten percent growth; our true goal is pleasing our boss.”
Page 101: “As I say, this is why I’ve given goal obsession its own special corner. It’s not a flaw. It’s a creator of flaws.”
Page 114: “Forgiveness means letting go of the hope for a better past!”
Page 116: “…change is not a one-way street. It involves two parties: the person who’s changing and the people who notice it.”
Page 122: “In soliciting feedback for yourself, the only question that works — the only one! — must be phrased like this: ‘How can I do better?’”
Page 128-132: 5 self monitoring techniques: 1. Make a list of people’s casual remarks about you, 2. Turn the sound off (i.e. observe their actions), 3. Complete the sentence (i.e If I do this, I’ll get that benefit.), 4. Listen to your self-aggrandizing remarks, and 5. Look homeward.
Page 147-149: Think before you speak, Listen with respect, and ask youself, “Is It Worth It?”
Page 170: Practicing Feedforward
Page 175: “It’s the feeling that when we help another person, we help ourselves.”
Page 181: “If you study successful people, you’ll discover that their stories are not so much about overcoming enormous obstacles and handicaps but rather about avoiding high-risk, low-reward situations and doing everything in their power to increase the odds in their favor.”
Page 179-198: Changing: The Rules: 1. You Might Not Have a Disease That Behavioral Change Can Cure. 2. Pick the Right Thing to Change 3. Don’t Delude Yourself About What You Really Must Change 4. Don’t Hide from the Truth You Need to Hear 5. There is No Ideal Behavior 6. If you can Measure It, You Can Achieve It. 7. Monetize the Result, Create a Solution 8. The Best Time to Change Is Now
Page 222: “Many older people say they were so wrapped up in looking for what they didn’t have that they seldom appreciated what they did have.”

RTE and dojo.editor

Rich Text Editor (RTE) is an alternative to dojo.editor. Although its icon set isn’t as cute as ones for dojo.editor, the graphics are certainly changeable. So, you can replace them with your own creative versions. You can turn on or off individual icons for RTE. Dojo.editor also allows such customization when you work with dojo.editor directly. The dojo.editor that’s packaged within jMaki does not allow this customization easily when you include the widget in your web application. You probably have to tweak the pre-configured dojo.editor tool bars separately. RTE has scrollbar built-in, which is a nice touch. Dojo.editor doesn’t. Instead it grows dynamically. Personally, I prefer scrollbars and to get that effect, I surround the widget with a div that has pre-defined height and overflow:auto. I read online that Dojo.editor doesn’t work if you want to put multiple instances on the same page. I did try to put a drawer on the same page and that breaks dojo.editor. RTE claims to work with multiple instances without a success according to this demo. RTE also requires me to insert a bunch of JavaScript code fragments in a JSP rather than put them in a .js file. In comparison, jMaki’s way of including dojo widgets is much cleaner. All in all, either options aren’t perfect. Given that they are essentially free, I am not complaining. I do hope they will improve over time.