Thursday, September 28, 2006

Swing gone crazy

An article I saw yesterday on the SWTSwing project, which attempts to allow you to program to the SWT interfaces but really use Swing underneath, brought back a lot of bad Java GUI memories for me. Here is how I remember the big mess that has been made of Java on the client side:

In the beginning - Java 1.0 - Java supported GUI components as part of its core library. At the time this was fantastic because most of the other competing languages did not provide a "standard" GUI package. The Java GUI framework was called Abstract Window Toolkit (AWT).

Now, AWT had its limitations. It only supported a few of the most common widgets. It also had threading issues - all of the AWT components are updated from a single event thread, so you have to jump through a few hoops to get updates from another thread on to the AWT thread (NOTE: this is common in GUI frameworks, including .NET forms). And most serious from Sun's point of view (and IBM complained a lot about it as well) was that AWT was built on top of "native" widgets, which look different on different operating systems.

Sun's solution - with more than a little help from IBM - was Swing. Swing had lots of widgets - menus, popups, sliders, you name it. Threading was solved by implementing a MVC pattern. And the different look on different operating systems problem was solved by "drawing" (simulated) each Swing widget so that it looked identical on each operating system.

Swing, however, was painfully slow. Most of the blame was attributed to the widgets have to draw themselves line-by-line, pixel-by-pixel, although I reckon some of the internal implementation was just badly done.

So a few years went by without Sun doing much to improve the performance of Swing. There were a few religious wars over native widgets vs simulated widgets, but Sun stuck to their guns when it came to ensuring the same look and feel across all operating systems.

Finally IBM - cohorts in the creation of Swing - went a different direction and created SWT, which was based on top of native widgets. And it didn't have any MVC support. SWT was used as a foundation for Eclipse.

A couple of years ago RedHat decided to support Java in a big way. In particular they wanted to add Java compiler support - actually compile Java programs to assembler - to the fantastic gcc and be able to run Eclipse on Linux. One major stumbling block to this ambition was getting Swing to run natively. Since SWT was implemented on top of native widgets it worked pretty much straight away with gcc. So along comes the SwingWT project which implemented the Swing interfaces on top of SWT.

And as I said at the top of this post SWTSwing implements SWT on top of Swing. And now SWTSwing is integrated with SwingWT, which is "great for those places where you want native if available, but can fall back to Swing if not".

When will this madness end! (Particularly now that Swing in Java 5 is actually pretty speedy and looks ok.)

Tuesday, September 26, 2006

Desperate to try the new Flaming Big Mac

And I thought this would only happen in America. From the Sydney Morning Herald:

When you've got to eat, you've just got to eat. That was the case at a McDonald's restaurant today when the lunchtime rush continued unabated even though a fire had broken out in the establishment's dumpster bin...

"Someone called the fire brigade [but] in the meantime an endless stream of vehicles continued to drive in through the drive-thru and continued to be served, which is quite amazing because there were huge flames.

Dot com days returning?

From a Wall Street Journal article:

Two and a half years ago, Facebook was a college project run by an undergraduate. Today, in an echo of the 1990s technology boom, it is being chased by large companies with their wallets wide open.

During one series of talks with Microsoft, Facebook executives told their Microsoft peers they couldn't do an 8 a.m. conference call because the company's 22-year-old founder and chief executive, Harvard dropout Mark Zuckerberg, wouldn't be awake, says a person familiar with the talks. Microsoft executives were incredulous.

In an interview, Mr. Zuckerberg declines to comment on any talks. The young entrepreneur says he generally works late -- he recalls eating French fries recently in the parking lot of a local McDonald's restaurant at 3 a.m. -- and doesn't get to work early. "I'm in the office at 10:30 a.m. sometimes," he says.

Saturday, September 23, 2006

Who was Winston Churchill?


Status of Churchill at Parliament Square, London

Question on BBC1's Test the Nation: "Who was Winston Churchill?"

-A rapper
-US President
-The Prime Minister
-The King?

Teddy Sheringham (famous English domestic and international football player)'s girlfriend, Danielle Lloyd:

"Wasn't he the first black president of America? There's a statue of him near me - that's black."

Thursday, September 21, 2006

Using the WebSphere transaction manager with Spring and Hibernate

It is surprising that there is almost no documentation on how to integrate the common Spring/Hibernate combination with WebSphere's transaction manager. (The Hibernate forums berate IBM for not providing info on WebSpere JTA hooks, and you have to crawl through some of the Spring code to find the correct classes to use.)

For simple applications that only hit a single database you can probably get away with using Hibernate's default simulated transactions, but if your app has to talk to multiple transactional resources (good ol XA) then it's a good idea to hook into WebSphere's transaction manager.

Without further suspense here is how you do it:

First, use the highlighted Hibernate properties when defining the Spring session factory:


<bean id="petStoreSessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
<prop key="hibernate.transaction.manager_lookup">org.hibernate.transaction.WebSphereExtendedJTATransactionLookup</prop>
<prop key="hibernate.transaction.flush_before_completion">true</prop>
<prop key="hibernate.transaction.auto_close_session">true</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
</props>
</property>
</bean>


If you are using Spring 2.1 RC1 or later then define a transaction manager using the WebSphereUowTransactionManager bean:


<bean id="wsJtaTm" class="org.springframework.transaction.jta.WebSphereUowTransactionManager"/>


For earlier versions of Spring that do not provide org.springframework.transaction.jta.WebSphereUowTransactionManager, and for versions of WebSphere earlier than V6.0.2.19 or V6.1.0.9 that do not provide com.ibm.wsspi.uow.UOWManager, transaction support in WebSphere is available by using a basic Spring transaction management bean :


<bean id="wsJtaTm" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="autodetectTransactionManager" value="false"/>
</bean>



This configuration supports a restricted set of transaction attributes that does not include PROPAGATION_NOT_SUPPORTED and PROPAGATION_REQUIRES_NEW. The Spring class org.springframework.transaction.jta.WebSphereTransactionManagerFactoryBean, which also claims to provide PROPAGATION_NOT_SUPPORTED and PROPAGATION_REQUIRES_NEW capabilities, uses unsupported internal WebSphere interfaces and should not be used.

And finally when you define a TransactionInterceptor or TransactionProxyFactoryBean make sure to use the WebSphereTransactionManagerFactoryBean with the JtaTransactionManager :


<bean id="petStoreTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<bean class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="wsJtaTm"/>
</bean>
</property>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
<property name="properties">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
</property>
</bean>


And that's it. As my old colleague Stuart Cooper likes to say: "MMMaaagggiiiccc!!!"

Update: The article "Using Spring and Hibernate with WebSphere Application Server" highlights some Spring 2.0 specific integration issues, such as transaction isolation levels and threads.

Windows UI team now blogging

Ever wondered why the Windows UI is the way it is, or want to ask about one of the Vista features? (Or even what ideas they borrowed from Apple for Windows 3.1 and from XWindows for Win 95) ? Well now you can ask the dudes/dudettes directly on the Shell:Revealed blog.

Monday, September 18, 2006

Challenges of running a Managed Service

Over recent years I've seen quite a few companies, particularly IBs, create their own IT Managed Services. They are interesting beasts, and I learnt quite a but about them while working inside a large IB that established a Managed Service based on a J2EE infrastructure. Below are some of my observations of these beasts.

What is a Managed Service?

A Managed Service assumes responsilibity of day-to-day running of important business critical systems. The same Managed Service group can assume responsibility for a number of applications that cross multiple business lines.

The main purpose of a Managed Service is to save money by centralizing operations and infrastructure instead of having to duplicate the same stuff for every new application.

A Managed Service model is very similiar to an ASP or help-desk model, but differs in that it is usually internally run (i.e. not outsourced, but many members of the group may still be Inidian consultants) and closely aligned with the business.

What are the incentives for starting/running/using a managed service?

The main incentives to run a managed service are:
  • Reduced cost by hosting as many applications as possible on common servers (i.e. less servers required to host the same number of applications than if each business group had their own servers)
  • Reduced number of staff required to support the infrastructure (i.e. each business group does not need to have its own support teams)
  • Reduced cost by using common infrastructure (i.e. developers do not have to keep "re-inventing the wheel" every time)
  • You do not have the resources to deploy and support applications, so you are happy to use somebody else's infrastructure (as long as the price is right!)
What are some of the barriers to starting a managed service?
  • Control. IT people in particular like to have control over their infrastructure and will often re-invent the wheel.
  • My empire is bigger than yours. A managed service is likely to be used by many different business groups and therefore has the potential to be larger than a group within one business line. Managers within the business lines may get very jealous.
Keeping it Visible

The most important thing you can do to establish and maintain a managed service is to keep the service visible. i.e. tell everybody about the service and keep telling them.

If people don't know about the managed service they won't use it. If people become complacent about the service they will stop using it.

Some ways you can keep a managed service visible are:

  • Regular presentations to managers and developers.
  • Comparison of the managed service with similiar services. It is often hard to get information on managed services being run inside competing companies; it is easier to get information on services provided by application hosting companies. The most important comparisons are cost and Service Level Agreements (SLAs).
  • Statistics. Managers need to know how the managed service is being used, including:
    • Number of applications deployed
    • Number of outages
    • Resources used by the applications (memory, CPU, disk space, etc)
  • Provide feedback mechanisms. Customers need to feel they are being listened to.
Environments

Depending on how much money you have it is generally standard practice to have at least the following three environments:

Environment Description
Development A development environment should be similiar to a production environment, but developers should be given the freedom to experiment with it. With freedom comes the potential for disaster. If possible isolate one development environment from another. Make it clear to developers that support for development environments is much less than support for QA and production environments. The worst case should be you may have to destroy and then recreate the environment from scratch.
Quality Assurance (QA) The QA environment should be as similiar to production as possible. This means you follow the same processes to get an application into the QA environment as you follow to get the application into the production environment. Access to the QA environment should be restricted to the managed service support staff.
Production The processes for deploying an application into production must be well defined, well understood and - above all else - auditable. Auditability simply means all changes to an environment (e.g. a change to configuration or a new version of an application is installed) have been recorded and are reproduceable. This often means changes are scripted and those scripts are put under version control. Access to the production environment must be restricted to the managed service support staff.

Management, Management, Management

Some of the key things you need to manage in a managed service:
  • Well-defined Change Management Processes. The processes of getting an application installed into a managed environment must be well documented and well communicated.
  • Change Windows. It must be well reported when changes can be applied to a managed environment. Changes to a production environment have to typically be done out-of-business-hours, such as late at night and at weekends. The processes to get your application into a change window must be well documented.
  • Escalation Procedures. Formal procedures to raise issues is a must. If you don't have any escalation procedures then people will do all sorts of ad-hoc and chaotic things to work around problems; often an issue will be reported by a person up through their management chain, then down through your management chain.
  • Request / Bug Tracking system. A system to track work requests and bugs gives the impression of a professionally run managed service.
  • Patching Policy. One of the trickiest issues to deal with is the issue of patching. Let us say you are running 10 applications on the same server using the same libraries. One of the applications report a bug. A bug fix is made to one of the libraries. The dilema: Do you apply the patch required by the one application to the libraries used by all 10 applications? Do you do regular (e.g. six montly) patch updates to your managed service? If you don't do at least regular updates then your infrastructure becomes difficult to support; big hardware and software vendors do regular updates to their products and can be slow to fix old versions.
  • The Stick. People must be given incentive to not abuse the managed service infrastructure. There must also be incentive to agree with the patching policy. The only incentive that really works is to charge people more money if they don't follow the managed service guidelines.
Don't forget the developers!!!

Starting a managed service and continued funding for a managed service will require the support of senior managers within the company, so they should obviously the primary target of your efforts. Developers will (most of the time) use whatever their managers tell them to use.

However, don't neglect the developers. If the developers are not happy with a managed service then they can spread rumours. And some developers will become managers in the future.

Developers are usually interested in the technical details and the processes. Ways to keep developers happy include:

  • Simple, brief "Getting Started" documentation. This includes doco on:
    • Guidelines on use of the supported technologies (e.g. "this is how you use Message Driven Beans inside WebSphere over MQ")
    • Using various development tools
    • Processes to build and deploy applications in the managed environment
    • Tricks and gotchas
    An internal website is a good place for this stuff.
  • Choice. Developers like to experiment. While a managed service must lock down processes for QA and production environments, you must allow a bit more freedom in the development process. For example, you can recommend and officially support a particular development tool, but you shouldn't try to force developers to use those tools.
  • Technology chat channels. Get into the 21st century and install an instant messaging system. Developers love to share insights and opinions with other developers.
  • Access to debug information. Since developers won't have open access to QA and production environments they will need access to some sort of debug information so they can support the applications. At a minimum they will need secure access to application log files.
  • Request / Bug Tracking system. The ability for developers/managers to sumbit requests for work and bug reports. The submitter can access the system to check the progress of their request, and review the work that was done to complete previous requests.

Beating the freeze - Disabling XP's built-in ZIP support

I'm often downloading and experimenting with all sorts of software and more often than not those downloads are packages as a ZIP file. Out of habit I dump all of those zip files in a single archive folder. A nasty side effect of XP's built-in support for ZIP files is that when I use Windows Explorer to open that archive folder Explorer and often other applications just freeze for a few minutes. The cause is that Explorer is trying to open and examine all of the ZIP files in the folder... gggrrr...

Thanks to this post I now have the solution to disabling the built-in ZIP support (I prefer using 7-zip anyway).

To disable XP's ZIP support:

1. Select Run from the Start menu and enter

regsvr32 /u %windir%\system32\zipfldr.dll

2. Click OK.


To re-enable XP's ZIP support:

1. Select Run from the Start menu and enter

regsvr32 %windir%\system32\zipfldr.dll

2. Click OK.

Friday, September 15, 2006

Transient Documents

An interesting new product from Xerox: reusable paper in the sense that the content is automatically erased after a period of time, ready for fresh printing. This would save a few trees from the occasional thing I print out to read on the train going home.

MS promise not to assert web services patents

In a move to keep web services open and standard Microsoft have pledged not to assert any patents it has on 35 listed web services standards. MS did a similiar thing with regards to the XML schemas defenititions in Office2003.

What is the legal status on XAML patents I wonder?

Deep-fried Coca-Cola

Thanks to the Onion for pointing me to this innovative food that starred at this years Texas State Fair. Don't forget to take the survey!

What's next? Mmmm. Deep-fried water.

Thursday, September 14, 2006

Celebrity baby pics really are big business!

I've always been sceptical of exactly how much those celebrity baby pictures actually adds to the bottom line of a newspaper or magazine. Until I saw a reprint of this article in the free (as in beer) amny :

The nationwide obsession with baby TomKat drove a whopping 4.3 million page views on vanityfair.com on Wednesday, according to a spokeswoman, nearly three times more than the previous record for page views when the title posted b-roll of Keira Knightley and Scarlett Johansson from Tom Ford's Hollywood issue in February. VF also signed up 4,000 subscriptions on Wednesday, its largest one-day total, from that day's 1.9 million unique visitors. No doubt a special offer that guaranteed receipt of the October issue to new subscribers (while supplies last) helped pique interest. On Thursday, the Web site attracted 1.1 million page views, 465,000 unique visitors and 1,700 new subscribers. Comparatively, vanityfair.com averages about 60,000 page views and about 20,000 uniques a day.

Let's assume TomKat got $3 million for the photos (I haven't seen the amount reported, but it is safe to assume they got less than the $4 million for the Brangelina photos).

Let's also assume the 5,700 new subscribes chose the bargin 24 issues for $40 deal, which would net Vanity Fair $228,000. Not bad for just two days "work".

Who knows how much other revenue was generated by print and on-line advertising.

Saturday, September 09, 2006

.NET CLR faster than JVM for dynamic languages

An interesting post from the dude that originally ported Python to the JVM and who just finished version 1.0 of the .NET Python port:

I started work on IronPython almost 3 years ago. My initial motivation for the project was to understand all of the reports that I read on the web claiming that the Common Language Runtime (CLR) was a terrible platform for Python and other dynamic languages. I was surprised to read these reports because I knew that the JVM was an acceptable platform for these languages. About 9 years ago I'd built an implementation of Python that ran on the JVM originally called JPython and later shortened to Jython. This implementation ran a little slower than the native C-based implementation of Python (CPython), but it was easily fast enough and stable enough for production use - testified to by the large number of Java projects that incorporate Jython today.

I wanted to understand how Microsoft could have screwed up so badly that the CLR was a worse platform for dynamic languages than the JVM. My plan was to take a couple of weeks to build a prototype implementation of Python on the CLR and then to use that work to write a short pithy article called, "Why the CLR is a terrible platform for dynamic languages". My plans quickly changed as I worked on the prototype, because I found that Python could run extremely well on the CLR - in many cases noticeably faster than the C-based implementation. For the standard pystone benchmark, IronPython on the CLR was about 1.7x faster than the C-based implementation...

Wednesday, September 06, 2006

Selling stocks the subliminal way

Watch the advert at the end of this post. You are getting sleepy. You love this stock...

Friday, September 01, 2006

Apple/Google join forces to take on Microsoft?

Eric Schmidt, CEO of Google, has joined the board of Apple. Hhhmmm.