Sunday, August 22, 2010

Best of this Week Summary 16 August - 22 August 2010

  • Great performance analysis (PDF) between Java IO and Java NIO by Google engineer Paul Tyma. Java IO is performing about 25% better.

  • Of course I have to mention Oracle's Java lawsuit against Google. Several viewpoints can be found here (more on the profit/free markets) and here (more elaborate and technical details) and here (Android == Java?).

  • A short comparison between Spring Web Services and Apache CXF.

  • Several short HTML5 tutorials by Bob Leah from IBM collected at one place.

  • Five things you might not know about .jar files.


Sunday, August 15, 2010

Best of this Week Summary 9 August - 15 August 2010

Sunday, August 8, 2010

Best of this Week Summary 2 August - 8 August 2010

Sunday, August 1, 2010

Best of this Week Summary 26 July - 1 August 2010

  • Pretty nasty, some application apparently depend on the the company name in the JDK! Including Eclipse, causing OutOfMemoryErrors since Oracle changed the name from 'Sun Microsystems, Inc' to 'Oracle'. Sounds like a magic constant somewhere... Though as it says here it had to be put in to work around another bug. Oracle rolled it back until JDK 7.

  • Evolutionary architecture and emergent design: Leveraging reusable code, Part 1 and Part 2.

  • A Spring MVC 3 Showcase, which should give you have a good idea of what the technology can do.It includes a sample project, along with a supporting slide presentation and screencast. After digging in, you should have a good understanding of what Spring MVC can do and get a feel for how easy it is to use.

  • Some random Android tips/lessons learned.

  • Java Iterator Quiz time!

Sunday, July 25, 2010

Best of this Week Summary 19 July - 25 July 2010

Sunday, July 18, 2010

Best of this Week Summary 28 June - 18 July 2010

Wednesday, July 7, 2010

Android performance tips

All videos and slides from sessions during Google's I/O conference last May 2010 are available here.

I watched The world of ListView and Writing zippy Android apps. Below are the items that were most interesting to me. They are all Android performance related.

The world of ListView

  • 9:15: A View in Android costs about one or 2K of RAM

  • 16:55: Call notifyDataSetChanged() (from the UI thread) when something in your adapter has changed.

  • 18:27: getItemViewType() is used to make sure convertView is of the correct type in getView().

  • 19:06: Make sure getViewTypeCount never changes. Note that it doesn't hurt performance if you always return say 10 even if you only have 2 different view types returned by getItemViewType().

  • 30:13: Shows how to create a custom list selector in xml.

  • 40:40: android:smoothScrollbar to prevent scrollbar changing size. Especially useful for listviews with items of which height can differ greatly

  • 41:00: Use fill_parent instead of wrap_content in a ListView

  • 53:10: If refreshing the whole screen via notifyDataSetChanged() is too much of a performance hit, you can try to get the visible position and use getChildAt() to figure out what view to update. Example code for that is here.

  • 53:50: Use inflate(item, parent, false) to prevent relative layout attributes being ignored in a listview.

In general: don't try to outsmart the ListView by building your own caching, nor depend in any way on the order of getView(position) getting called.


Writing zippy Android apps

Zippy means non-janky which means sluggish, slow etc.
  • 08:00: example apk of how not to do things/see how stuff performs. Includes small Perl sqllite wrapper script to see how much is being read from sqlite

  • 15:00: read/writes I/O on emulator is a lot faster than on a real device

  • 19:00: An AsyncTask can get killed before it finishes, e.g if the user hits the Home key. If it's important that the task finishes, use IntentService.

  • 24:15: Profiling/tracing apps 'adb shell am profile ...' with the TraceView tool.

  • 47:00: handling rotation when you don't want to reload your heavy objects: usegetLastNonConfigurationInstance() and onRetainNonConfigurationInstance(). See the Android reference for more info.

  • 51:00: Think about using files instead of sqlite (if you have limited structured data for example)

Sunday, July 4, 2010

Lessons learned Wicket + Spring + Hibernate + Mod4J project

At a recent project we used the following tools & frameworks:


Below are a couple of lessons learned which I remembered to write down:

Wicket
  • In a ModalWindow you'd probably want to use a AjaxSubmitLink, not a SubmitLink, if you want to use modalWindow.setWindowClosedCallback(). See here for explanation.

  • ajaxrequesttarget.addComponent: addComponent name might be a bit confusing for beginners. It means "add the component to the list of components be re-rendered/refreshed".

  • An AjaxSubmitLink doesn't update the model when setDefaultFormProcessing() is set to false. Not totally illogical, but you still might run it to it when you don't expect it.

  • Here are tips to validate related fields. (In the original the example code is missing.)

  • AjaxSubmitLink: if you get a "Component-targetted feedback message was left unrendered. This could be because you are missing a FeedbackPanel on the page" warning in your Tomcat server console, it seems you have to tell in the onError() of the AjaxSubmitLink which feedback panel(s) you want to have updated.
    You get the warning even when you have feedback panels higher up in the tree of the (Base)Page. An example to update those panels could be:

    Component infoFeedback = getPage().get("infoPanel");
    target.addComponent(infoFeedback);
    Component warnFeedback = getPage().get("warningPanel");
    target.addComponent(warnFeedback);
    Component errorFeedback = getPage().get("errorPanel");
    target.addComponent(errorFeedback);

    This solution was inspired by these posts: post1, post2, post3, post4.

  • To show/hide any HTML markup block dynamically, just wrap it with a WebMarkupContainer. In the code create that wrapper and make it visible or not depending on your requirements:

    boolean makeVisible = false;
    WebMarkupContainer blockContainer = new WebMarkupContainer("blockWrapper");
    blockContainer.setVisible(makeVisible);
    add(blockContainer);


  • Sometimes you might get a popup when using a ModalWinow that says "Reloading this page will cause modal window to disappear" when you don't expect it. Check the logs/console, you might just got an exception in your app (after which Wicket tries to redirect to the error page, which causes the popup to show; at least that's my reasoning).

JUnit
  • If JUnit can't find the Spring context.xml in the resources directory, then you have to add the resources dir to your Build path

Mod4J
  • Does not really support LazyLoading so not very efficient for large "graphs" of data/dependencies. In those cases you could decide to skip the DTO layer and directly access the domain model.

  • The Maven plugin IAM in Eclipse can be turned off for the Mod4J models project in Eclipse, otherwise it runs twice: once by Mod4J features, once by Maven (plugin).

Sunday, June 27, 2010

Best of this Week Summary 15 June - 27 June 2010

Sunday, June 20, 2010

Best of this Week Summary 14 June - 20 June 2010

Sunday, June 13, 2010

Best of this Week Summary 7 June - 13 June 2010

  • When rewriting an app from scratch doesn't make sense, and when it might make sense.

  • Java deadlocks through Cyclic Dependencies: title says it all.

  • Carnegie Mellon University's CERT (Computer Emergency Response Team) has released the Basic Fuzzing Framework (BFF), which is a simplified version of automated dumb fuzzing and includes a Linux virtual machine that has been optimized for fuzz testing and a set of scripts to implement a software test. It helps identify and eliminate security vulnerabilities from software products.

  • A nice (external) analysis of the FIFA World Cup website against performance best practices.

  • "Nokia's set of learning and teaching materials on Java in Mobile Devices (JME/MIDP). In fact, it is Forum Nokia’s most comprehensive set of information ever. Included are five courses, 23 lectures, 25 lab exercises with source code, and more than 1,200 slides with notes. The material has been designed for university instructors and students, developers, and self-learners. Five main topics are covered:

    • Java ME basics

    • Multimedia

    • Networking and messaging

    • Games and graphics

    • Security

    Of course JME is not so sexy as Android these days, but Nokia still has the largest number of mobile phones out there. And most (even quite low end) support JME, so from a market perspective the potential is much higher than building apps for Android phones...

  • Several CSS reset examples, including a few really short ones.

Sunday, June 6, 2010

Best of this Week Summary 30 May - 6 June 2010

  • Google Web Toolkit vs. Smart GWT: Which should you choose as front-end? Start immediately with Smart GWT, or start with GWT and pick SGWT components when needed? Some insights here.
    Related to that, you might want to check Vaadin: "Vaadin is an open source web application framework for rich Internet applications. In contrast to Javascript libraries and browser-plugin based solutions it features a server-side architecture, which means that the majority of the logic runs on the servers. Ajax technology is used at the browser-side to ensure a rich and interactive user experience. On client-side Vaadin is built on top of and can be extended with Google Web Toolkit. Vaadin utilizes Google Web Toolkit for rendering the resulting web page. While Google Web Toolkit operates only client-side (i.e. a browser's JavaScript engine) – which could lead totrust issues – Vaadin adds server-side validation to all actions. This means that if the client data is tampered with, the server notices this and doesn't allow it.
    Historically, Vaadin has been compared to Echo and ZK frameworks that use similar of server-side programming model. The server-side APIs are quite similar providing both events and GUI components, but the client-side (i.e. web browser) interaction differs in the way that Vaadin uses Java programmed GWT widgets, while ZK is jQuery based, and Echo has its own implementation. Currently, the most frequently compared frameworks include Adobe Flex, Google Web Toolkit, Apache Wicket and ICEfaces."

  • A new open spec collaboration has started: OExchange, which is an open protocol for sharing any URL with any service on the web. Bigger parties involved are LinkedIn, Microsoft, Google.

  • A new way of phishing: TabNabbing - phishing by switching background tab content. Discovered by Firefox's creative lead Aza Raskin. Biggest challenge seems to get the malicious Javascript on a site the user goes to.

  • Google announced a partnership with VMWare (and thus SpringSource and thus Spring) at I/O by adding its (GTW) widgets to Spring and deployment to the VMWare cloud. In marketing speak: "This is VMware and Google's view of the power of using Spring along with Google's presentation widgets to get apps started in hours, delivered in days, and deployed in minutes". Below it's shown in a diagram:



  • The iPad isn't without "errors" in its usability (UI) according to Jakob Nielsen. For example: cross-app UI experience is inconsistent, and for some reason almost no app supports scrolling and shows information only per page.

  • "An overview of how to design websites and optimise them for Maemo, iPhone, Android, and a variety of touch and non-touch devices based on S60 on Symbian OS. After reading the document, you will have the basic knowledge you need to start developing mobile web pages that provide cross-browser-compatible content in a user-friendly manner. Furthermore, with the tips and advice contained in the document, you can avoid making design choices that could eventually lead to a dead end or poor design, thus saving time in implementing and debugging features that will not work".

  • Show Slow: an open source tool that helps monitor various website performance metrics over time. It captures the results of YSlow and Page Speed rankings and graphs them, to help you understand how various changes to your site affect its performance

Sunday, May 23, 2010

Best of this Week Summary 17 May - 23 May 2010

  • Codelab ("tutorial") from Google that "shows how web application vulnerabilities can be exploited and how to defend against these attacks. The best way to learn things is by doing, so you'll get a chance to do some real penetration testing, actually exploiting a real application. The codelab is built around Jarlsberg, a small, cheesy web application that allows its users to publish snippets of text and store assorted files. "Unfortunately," Jarlsberg has multiple security bugs ranging from cross-site scripting and cross-site request forgery, to information disclosure, denial of service, and remote code execution. The goal of this codelab is to guide you through discovering some of these bugs and learning ways to fix them both in Jarlsberg and in general."

  • A new IBM Redbook on WebSphere Messaging and High Availability has just been released.

  • A cool Android with Hudson continuous integration. Led on mobile phone changes color depending on the build status. Remember the Lava Lamps version?

  • Java dynamic proxies explained. They are for example used in Hibernate for lazy loading entities and in Spring for AOP. Also explains what CGLib proxies are for.

Sunday, May 16, 2010

Best of this Week Summary 10 May - 16 May 2010

Sunday, May 9, 2010

Best of this Week Summary 03 May - 09 May 2010

Tuesday, May 4, 2010

Clonezilla backup steps

In the last two years I had to get my harddisk replaced twice by a new one.
To minimize effort of setting up the new disk, I investigated which harddisk-copy program would best fit my needs, without complex setup things or complex instructions to create a bootable/live CD.

After trying several things, Clonezilla 1.2.2-31 did it for me.
I tried DriveImage XML, but that required me to make a streamlined CD for XP first, because I got a d:\i386\layout.inf not found error. I also looked at Paragon Backup & Recovery, but couldn't find how to create a live CD.

Creating a bootable live DVD was easiest with Clonezilla, and it's standalone, so no OS disks like Windows XP needed. The actual steps to make a backup a bit difficult for non-unix/linux people, but not impossible.
Below are the steps I now use to make a complete backup of my harddisk (including Windows) to a networked external disk via Samba.
Whether you can use these steps for your setup completely depends on your setup. Main reason for listing the steps here is so I have an easy reference to them :)

Prerequisites

  • Make sure you have an external harddisk connected to your network.

  • Make sure you have its IP address. If you're normally using DHCP, you might want to give it a fixed IP.

  • Make sure you have enough diskspace left on that external harddisk

  • To minimize network errors during the copying, you might want to use a network cable instead of a wireless connection. I definitely did that.

  • I used it for Windows XP, but any OS should do (it makes a byte-by-byte copy of the source disk


Steps to make copy
  1. Put the bootable CD/DVD in the drive to boot from it. Choose F8 or F12 at startup if you manually need to select your machine to boot from it.

  2. Wait until the boot sequence is done

  3. Choose language, and Don't touch keymap

  4. Choose Start Clonezilla

  5. Now you have to get the network card to get activated. That happens in the next steps

  6. Choose as Mount dir: samba_server

  7. Choose eth0. Choose DHCP

  8. Enter the IP of the networked external disk. E.g: 192.168.1.70

  9. I canceled the Domain configuration option

  10. Enter the account to use to connect to the networked external disk

  11. Pay attention when you enter the directory where the image must be stored. It is the directory in which the directory with the image information will be put. If you enter a non-existing directory, the mount (happens when you hit OK) will fail. Not a problem, just that you know. If the mount fails, just restart the process, this time with an existing path. Example path:


    /public/home/partimag


  12. Hit OK. This will start the mount command. It will ask you for a password if applicable. When the command is successful, you'll see the filesystem mount points listed.

  13. Choose Beginners Mode. Choose savedisk.

  14. Enter a name for the image. I usually append some more identifying information to the prefilled filename, which is something like: 2010-05-02-18-img

  15. Then choose the disk from the machine you want to make a backup for. For me it's only one: sda. Hit OK.

  16. Now you should see a summary of the command, which looks like:


    /opt/drbl/sbin/ocs-sr -q2 -c -j2 -z1 -i 2000 -p true savedisk "2010-05-02-18-img" "sda"


  17. Hit ENTER. That should start the backup. No errors should occur. My 500G harddisk with about 100G of data took about 4,5 hours to get backed up. One time I had an error in the output, saying something like the eth0 NIC was "gone". But the backup continued, and no other official errors were shown. It was not clear whether Clonezilla recovered successfully from the connection being away for a little while. Still, to be on the safe side, I made another backup, that had no network errors at all.



Steps to restore copy
These steps are about the same as making the copy, except that you select restoredisk instead of savedisk. But for completeness, here are the steps:

  1. Choose language

  2. Select Don't touch keymap

  3. Select Start Clonezilla

  4. Choose first option device_image

  5. Choose samba_server

  6. Choose eth0

  7. Choose DHCP

  8. Enter IP address of server you've stored the image on (e.g. 192.168.1.70)

  9. Cancel domain

  10. Enter account name to login on server

  11. Enter as directory: /public/home/partimag (note it's the same as when making the copy)

  12. Enter the password for the server. If correct, you'll see again the mount result (filesystem diskspace usage)

  13. Choose Beginner

  14. Choose Restore disk

  15. Choose the image you want to restore (e.g 2010-05-02-18-img)

  16. Choose target disk: sda

  17. Now you should see a summary of the command, which looks like:


    /opt/drbl/sbin/ocs-sr -g auto -e1 auto -e2 -c -r -j2 -p true restoredisk "2010-05-02-18-img" "sda"


  18. Hit ENTER. That should start the backup. No errors should occur. My 500G harddisk with about 100G of data took about 2,5 hours to restore.

Sunday, May 2, 2010

Best of this Week Summary 26 April - 02 May 2010

  • Google's Chief Java Architect Josh Bloch "discusses many of the problems facing the Java community, including the ineffectiveness of J2ME, licensing problems, Java 7's late ship date, and even the JCP issues that James Gosling often opined about. He points out that these problems predate the Oracle acquisition of Sun, so everyone should just stop pointing their fingers at Larry Ellison."

  • Another Getting Started blogpost for a Mahout-Taste based movie recommendation engine, which uses Wicket as presentation layer.

  • Martin Fowler explaining Inversion of Control and suggesting to call it the Dependency Injection pattern. Notes that the Service Locator pattern can also remove the dependency, just as the DI pattern tries to. Describes which of these options to use. Finally he also gives pros/cons for constructor vs setter injection. Also pros/cons for configuration in the code or via configuration files.

  • Several Javascript performance-optimization tips taken at JSConf 2010.

  • An article "which looks at various storage mechanisms - JDBC, JPA, JavaSpaces, Java Content Repository, MongoDB, and DB4O, primarily - from the perspective of how good they are at CRUD operations and queries". The conclusion is that there is no one "best" mechanism, each has its own best application.

Sunday, April 25, 2010

Best of this Week Summary 19 April - 25 April 2010

  • An introduction to Gizzard, an open sourced sharding framework (store data across multiple computers instead of on just one) which is used by Twitter.

  • A hands-on tutorial of creating a Spring application that uses Hibernate as JPA provider and JTA for transaction demarcation. A simple Order Processing Message Driven Bean is implemented that showcases this integration. It is deployed on a WebLogic 10.3 server.

  • Last week Jira from the Apache Foundation was compromised. Here's a description of how the hackers gained access via XSS.

Sunday, April 18, 2010

Best of this Week Summary 12 April - 18 April 2010

Sunday, April 11, 2010

Best of this Week Summary 5 April - 11 April 2010

Sunday, April 4, 2010

Best of this Week Summary 29 March - 04 April 2010

  • A short overview on what the differences are using Java in Google App Engine (and shortly mentioned in MS Azure) compared to "regular" JEE apps.

  • Three Java serialization options compared: Java Serialization, JSON Serialization and Google Protocol Buffers. Check also the comments here. Another benchmarking set can be found here.
    The protocol buffers solution was fastest in this test.

  • The third edition of Mastering EJB, is now available for free download off of TSS as PDF. The new edition includes more than 30 percent revised material and five new chapters covering security, integration, best practices, new EJB 2.1 features, as well as the latest open source Java solutions

  • Interesting read on the IT infrastructure (most of the article) in F1 racing.
    Some quotes: "each car has roughly 100 sensors placed in key data capture positions and send anywhere up to 20 gigabyes of data back to the pits during a race."
    "They are collecting four to six megabytes per lap. It depends on the track layout and the quality of the coverage but we transfer about 70 per cent in real time to the garage or the pits". And, did you know there's a connection with the factory during the race?

  • A funny observation that CSS has quite something in common with Aspect Oriented Programming! Includes a table which shows the similarities.

Sunday, March 28, 2010

Best of this Week Summary 22 March - 28 March 2010

Sunday, March 21, 2010

Android SDKs, screensizes and resolutions: comparable hardware

Trying to get an overview of the possible combinations of Android SDKs and screensizes and resolutions, *and* what physical devices are comparable, I came to the below overview. If you know some more comparable hardware, please let me know, I'll update the tables.

The first table shows the different screensizes defined as per Supporting Multiple Screens | Android Developers, mapped on real existing devices.





































































Id



Screensize, resolution, physical



Comparable hardware



A




QVGA (240x320, low density, small screen, 3.3”)




-



B




HVGA (320x480, medium density, normal screen, 3.9”)




HTC Hero 1.5 but really has 3.2”



C




WVGA800 (480x800, high density, normal screen, 3.9”)




Google Nexus One but really has 3.7”



D




WVGA854 (480x854 high density, normal screen, 4.1”)




Motorola Droid (aka Milestone) but really has 3.7” and Sony Ericsson Xperia X10 (screensize unclear)



E




WQVGA400 (240x400, low density, normal screen, 3.9”)




-



F




WQVGA432 (240x432, low density, normal screen, 4,1”)




-




The table below shows which SDK supports the above screensizes.


















































SDK



Screensize Id



1.5




B



1.6




B-D



2.0




B-F



2.0.1




B-F



2.1




B-F





Remarks:
  • The total nr of possible sdk+screensize combinations is 19!

  • Android has organized the screensizes and resolutions into three generalized sizes and three generalized densities, see here.

  • To support all these resolutions, you don't have to create icons/images for all possible combinations. By default Android tries to scale resources. Up to a certain limit it could be acceptable to let it do it for you, minimizing the number of images to create.

  • An example setting is minSdkVersion = 3, targetSdkVersion = 4 (where 3 = 1.5, 4 = 1.6). Targeting 1.6 ensures that different screensizes can be supported if the device has 1.6 or higher.

  • Cool skins you can find here. If you look at the configuration files, you can validate whether the screensize and resolutions are actually what you expect.

  • Sources: Droid, Nexus One, Hero, Xperia X10.

Best of this Week Summary 15 March - 21 March 2010

  • Twitter and Digg are moving from MySQL to Cassandra (a highly scalable second-generation distributed database, bringing together Dynamo's fully distributed design and Bigtable's ColumnFamily-based data model; a Facebook opensourced project). The reason for Digg for the move "is the increasing difficulty of building a high-performance, write-intensive application on a data set that is growing quickly, with no end in sight. This growth has forced them into horizontal and vertical partitioning strategies that have eliminated most of the value of a relational database, while still incurring all the overhead".
    Twitter has about the same reason: "No single points of failure", "Highly scalable writes (we have highly variable write traffic)", and "A healthy and productive open source community".
    Twitter tried HBase, Voldemort, MongoDB, MemcacheDB, Redis, Cassandra, and HyperTable amongst others before deciding to go with Cassandra. Interesting to read is how they slowly rollout Cassandra to limited sets of users.
    An introduction to Cassandra to get it up and running can be found here.


  • A short post on how to implement Automatic testing Oracle Service Bus using Hudson, Maven and SoapUI.

  • What to expect from HTML5 for webdevelopers.

Sunday, March 14, 2010

Best of this Week Summary 8 March - 14 March 2010

Sunday, March 7, 2010

Sunday, February 28, 2010

Best of this Week Summary 22 February - 28 February 2010

Sunday, February 21, 2010

Best of this Week Summary 15 February - 21 February 2010

  • Expected that Mozilla uses Agile everywhere, and definitely on its flagship Firefox? Think again, only recently they started to combine Agile and more traditional Waterfall as their new development model, dubbed "Lorentz".

  • Tips for hardening your Tomcat installation. Other implementation guides, not only limited to Tomcat (also for example WebLogic) tips from U.S. DOD DISA (Defense Information Systems Agency) can be found here.

  • Always interesting to at least quickly browse through: a review of the 1993 code of Doom. And more "today": the code of Doom for the iPhone reviewed.

  • Think you know Javascript? Try one of these quizes!

Sunday, February 14, 2010

Best of this Week Summary 8 February - 14 February 2010

  • Five new features of Spring 3.0 described:

    • Spring Expression Language (SpEL)

    • Object/XML Mapping (OXM) module

    • Type-conversion system

    • Formatter SPI

    • RESTful web services support

    What new Ajax simplifications have been introduced can be found here.

  • The Java EE 6 web tier introduces with Servlet 3.0 spec the ability for asynchronous processing of requests so that the thread may return to the container and perform other tasks. It also "adds annotation based configuration (@WebServlet, @ServletFilter and @WebServletContextListener) making the web.xml file optional, and introduces a new concept of web fragments."

  • Introductionary article to Apache Click. One difference between Click and Wicket is that Click is stateless by design, while Wicket is stateful. Both can be configured their "opposite" model, though these have their own pros/cons.
    Another main difference is that that Click uses templates (Velocity by default) where Wicket does not.

    Sidestep: here's a bunch of nicely designed Wicket sites that scale (note: not really clear where the scalability statements come from).

  • A 60 minutes presentation on how SOA is a hit at eBay.

Sunday, February 7, 2010

Best of this Week Summary 1 February - 7 February 2010