Feeds:
Posts
Comments
Test Version: GWT 2.0 and above

Use of “main” method

Each Java class can include a “main” method to perform class execution. This feature is especially useful for experimenting, testing and debugging the pertaining code within the class without resorting to using helper class. Generally it is more efficient and productive to test a particular class (if one already pinpoint the problematic class) rather than to test a whole application that has more overheads and which takes longer time to run. By including a “main” method in class, other developers can also quickly experiment with different API of the code within the class without creating additional testing helper classes. In addition, it is easier to build a reliable application if the classes that make up the application are reliable themselves. Apart from this, the use of “main” method will also encourage one to design the class to be “simplified” so that it can easily test from “main” method.

public static void main(String[] args) // Java’s main method

That to say that the “main” method is not a replacement for unit testing, and vice versa. Their intent and usage are different. Unit testing is more formal whereas the “main” method is less formal. Many test cases are included in unit testing and is run periodically to ensure that nothing break the code and create bug from modified code as in the case of time-consuming build process. Unit testing is usually automated and does not involve GUI interaction since the unit testing can be invoked in command-line prior to software development process like build process or check perform by version control system after code check-in.

On the other hand, the “main” method does not subject to such intense test and is not run unless one modify that class and want to have a quick test ensure correct behaviour and result. Developers are free to change whatever in the “main” method of the class during development as long as the “main” method of the class is not used to start up the application, and not call by other classes (It is bad practice to reference and use “main” method from other class.).

 

Continue Reading »

Software Requirements:
– Windows OS => WinXP, WinVista, Win7
– Eclipse v3.5
– JProfiler v5
– YourKit v8

Objective

A profiler is a very powerful tool to help pinpoint performance and memory issues. It offers a variety of ways to which a developer can help track down classes that lead to dismal performance, inefficiency and memory leak issues. This includes taking and comparing snapshot at certain point in time, watching how CPU time and memory is consumed in realtime in a visual chart and marking interested classes for analysis.
There are many profilers in the markets , both open-source (eg VisualVM that bundled with Java SDK) and commerical offerings. However, this document will show the steps to configure two of the best commerical Java profilers in the market, YourKit and JProfiler, to profile GWT client application in Eclipse in the Windows environment.
Even though both profilers are just as effective and powerful, both use different approach to profile the application.

Still, the following steps will work with any IDE (eg Intellij ) since it is just a matter of adding adding additional profiler’s agent as argument to the JVM. All IDEs allow argument to be passed to the JVM that run the project application.

Yourkit and JProfiler offer a 15 and 10 days evaluation trial respectively.

Continue Reading »

Here is the books I read for February.

imageClosing the Innovation Gap: Reigniting the Spark of Creativity in a Global Economy

Available in National Library


This book presents a well-research study of how innovation has become increasingly important to organizations and nations, and how to build, sustain and leverage on the innovation ecosystem for competitive advantages and business.

imageStart-up Nation: The Story of Israel’s Economic Miracle

Available in National Library


How is that nation that is surrounded by hostile countries and constantly plagued with threat of war and terrorism is been respected and recognized worldwide as a powerhouse for extraordinary source of innovation ? What is it about Israel that attracts Intel to put the company’s future and trust since the 1960s into the hands of Israel chip designers to develop innovative CPU like Pentium, Centrino and the next generation of supercomputer chip ?  Why is that most developed nations with greater wealth, economic stability and excellent infrastructure fail to replicate the culture of innovation and start-up culture of Israel ? All these answers can be found in this extremely well-written book on Israel’s start-up history and culture. By critically looking at past events that shape Israel, the authors uncover the root of innovation of Israel that closely linked to military.

This book uses the story-telling style that effectively captivates the reader with factual dramas and interesting insights. The lessons learnt are well-supported with example and research, and summarized at end of each chapter.

A great deal of material also covers Singapore’s obstacles towards a innovative nation and explains hindrance like rigidity, lack of core value and sense of purpose, inability to attract R&D centres, obsessive focus on GDP, materialism and wealth-building, lack of freedom of speech that discourages questioning mind.

Issue

Final variable is used to define constant value and reference, and can only define once. In most cases, declaring a final variable is just a matter of assigning to a primitive value or a object reference directly.  However, in some cases, declaring a final class/instance variable may be more involving especially it get assigned from method that throws Exception (eg API for database access, web access), or it may involve multiple statements. In such cases, the code may become cluttered with class helper method and dummy temporary variable that help define final variable, making the code look less elegant and harder to maintain. The following common ways of declaring a final variable in those situations might look familiar to many.

Continue Reading »

image

I know exactly what you thinking because it is exactly what I’m thinking when I first see this surreal picture. A picture that is so skillfully doctored to show a large plane landing near to the coastline as short to the start-point of runaway. To created such a illusion with perfectly matched details to thwart even the meticulous critics will require very highly-skilled artist and countless hours of work. Just look at those shadow, lighting and other amazing details that fit so well with the environment, not to even mention that no airline in the world is so sane to put the public in such a dangerous area.

Continue Reading »

Issues

I always thought that there is ought to be better way to develop JavaFX application, with kind of similar and gratifying experience as developing Java Swing application. Traditionally in developing desktop application, one normally develop and test using class file to save time, and only uses JAR file for deployment (or if running in mobile emulator or device). However with the advent of RIA platform, the trend is to use a application container file (eg jar, swf) as default way of development since it facilitates seamless running in several modes without hassle (eg as Applet, webstart, and mobile device). Unfortunately, this is rather inefficient if one is developing desktop application, or experimenting with ideas. Unnecessary waiting time only disrupts the creativity and programming flow. Saving a few seconds for every run will accumulate into significant saving of time. Besides, it is rather counter-productive to use container file as the only mode of development if the technology can support alternative efficient way.

Continue Reading »

Here is the books I read for January.

image BlackBerry Planet: The Story of Research in Motion and the Little Device that Took the World by Storm

Available in National Library


This book chronicles the history and rise of BlackBerry devices and the company RIM. RIM shows that the secret to the company’s success is to develop core competency, sustainable innovation and entrepreneurial culture.  A substantial part of the book also highlights on how BlackBerry is used as a effective and indispensable tool in Obama campaigning for president-ship.

image After the Software Wars

Free download at http://www.lulu.com/content/4964815 


This is must read for those who want to get excellent insight into the changing world of Information Technology. A wide range of interesting topics are covered, including Linux, open-source movement, DRM, Google and Java. Basically, all the important things you ever want to know about computer world is covered in this book. Do not miss it especially when it’s free.

image  Programming Clojure

Available in National Library


Functional programming and concurrency are all the rage now as multi-core CPU becomes commodity and trend of the future. Clojure, a derivative of the venerable LISP language running under the powerful Java Virtual Machine, has caught the computing world by storm due to its elegance and uniqueness, combined with unmatched performance. By merging the flexibility and power of LISP with Java, Clojure provides a attractive language for those Java veterans who want to take their skill to another level. And for that, one will need Programming Clojure, the only book currently available for the language. This book provides a great reference and tutorial for those who want to come to speed in learning and using Clojure.

image  iPhone User Interface Design Projects


How does one create a world class attractive iPhone application that is easy-to-use ? What is the thought process in designing and building iPhone application ? What better way to learn about building iPhone application than by learning through actual experience of those who been there.  This book is for those who will want to get valuable insight in creating beautiful GUI for iPhone.

image  Beginning Java Google App Engine


Google App Engine is a disruptive cloud platform not only because of its power. scalability, reliability and ease of use, but also because one can deploy and use application for free compare to other cloud vendors like Amazon. This book will provides a excellent introduction to those Java developers using Google App Engine and explain the concept and technology behind the engine.

Do you know what it means to be a innovator ? According to Professors Jeff Dyer image and Hal Gregersen image , it means to develop a set of skills and traits that necessary for creative innovation.

 

Dyer: The first skill is what we call "associating." It’s a cognitive skill that allows creative people to make connections across seemingly unrelated questions, problems, or ideas. The second skill is questioning — an ability to ask "what if", "why", and "why not" questions that challenge the status quo and open up the bigger picture. The third is the ability to closely observe (observing) details, particularly the details of people’s behavior. Another skill is the ability to experiment (experimenting) — the people we studied are always trying on new experiences and exploring new worlds. And finally, they are really good at networking with smart people who have little in common with them, but from whom they can learn.

Fryer: Which of these skills do you think is the most important?

Dyer: We’ve found that questioning turbo-charges observing, experimenting, and networking, but questioning on its own doesn’t have a direct effect without the others. Overall, associating is the key skill because new ideas aren’t created without connecting problems or ideas in ways that they haven’t been connected before. The other behaviors are inputs that trigger associating — so they are a means of getting to a creative end.

Gregersen: You might summarize all of the skills we’ve noted in one word: "inquisitiveness." I spent 20 years studying great global leaders, and that was the big common denominator. It’s the same kind of inquisitiveness you see in small children

To read on, click here

Important: This version is not the official release by the original author of NanoXML (http://nanoxml.cyberelf.be/). It appears that the development for NanoXML has ceased.

Issue in NanoXML

Back in 2008, a version of NanoXML v2.2.4 is “unofficial” released to add comment feature (Javalobby mirror). However, there is one problem that persists which prevent developers from using NanoXML to manipulate xml file. The developers might use xml file for to store profile for their application and will need to manage xml file (etc delete, rename, add). However, it turns out that NanoXML is locking the xml file while waiting for the Garbage Collector to kick in and release the file. However the GC is behaving unpredictably and might not release the file as and when the program expects it. The developers will thus want more control over the release of file resource. Unfortunately, there is currently no API to force release of file resource under current release.

NanoXML v2.2.5

Therefore, I have modified NanoXML and released it as  NanoXML v2.2.5 to allow developers to use a specific method to release file resource manually so that the file can be manipulated (etc delete, rename).

  • public void close()
    This will release all file resource that are held up by Reader.

The aforementioned method will release the file resource that is created using the static method IXMLReader fileReader(String filename) in StdXMLReader class.

Example

public class XmlTest
{

// ## means new features added.

    public static void main(String[] _args) throws Exception
    {
        IXMLParser parser = XMLParserFactory.createDefaultXMLParser();

        /*// If pass string, use stringReader
        IXMLReader reader = StdXMLReader.stringReader(“<root></root>”);
         */
        // Pass by file. Important to use toURL method otherwise exception will be thrown.
        IXMLReader reader = StdXMLReader.fileReader(
                new File(“c:/test.xml”).toURI().getPath());
        parser.setReader(reader);

        // parse() method does not include comment
        IXMLElement xml = (IXMLElement) parser.parse(true);   // ## true means parse comment too

        IXMLElement _x = xml.createElement(“newChild”);
        _x.setComment(“This is new child”); // ## Adding comment
        _x.setAttribute(“att1″, “me1″);
        _x.setAttribute(“att2″, “me2″);
        xml.addChild(_x, 0);  // ## Adding at specific position.

        IXMLElement _b = xml.getChildAtIndex(1);
        xml.removeChild(_b);  // Remove tag

        XMLWriter writer = new XMLWriter(System.out);
        // Default for write is excluded comment
        writer.setIncludeComment(true); // ## Include comment at generation.
        writer.write(xml, true);

        reader.close();

    }

}

 

Download NanoXML v2.2.5

The following file contains the full source code and the library jar file. To check on those changes that I have made, you can search for ‘GeekyCoder’ in the source code.

image
NanoXML-2.2.5.zip (93kb)

Released on 6 Feb 2010


Experimenting with “Office 2007” Zoom interface

image

I have to admit that I like the Default FullZoom Level extension which significantly improve on the FireFox’s rudimentary Zoom feature.

Continue Reading »