Pet Store with JavaFX 1.0. Part 1.

I work for a company called Farata Systems. Laura is our office manager, and she doesn “t know Java. Everyone else does. We work in the enterprise RIA space using Adobe Flex as a main development tool for creating all these Web pages connecting to the server side applications written in Java.

In December of 2008, Sun Microsystems has released the first version of a language for developing UI for RIA. I “ve been watching the evolution of JavaFX from its announcement at JavaOne 2007 till its release, but wasn “t able to find any demos that would prove that this extension of Java platform can be considered as a candidate for boring needs of enterprise applications. Watching demos like a bunch of balls moving inside a glass didn “t look too convincing to me.

We decided to contribute to Java community and invest some time and resources to figure out what JavaFX 1.0 is capable of. Most of the Java developers know what Pet Store application is. For many years this reference implementation has been used by Sun Microsystems as a part of Java BluePrints program for Java EE platform.

The current version of this application is described in the article called “Introducing the Java Pet Store 2.0 Application rdquo; that “s available at http://java.sun.com/developer/technicalArticles/J2EE/petstore/.

We re-used the existing back end of the Pet store, but performed a little facelift by replacing the UI developed with AJAX/JSP/JavaServer Faces with JavaFX 1.0.

I was working on this project with our senior Java developer Alex Litskevich who “s done lots of digging and research trying to find the best solutions whenever we would run into limitations of JavaFX.

The goal of this introductory article is to demo the JavaFX Pet Store. You can watch a quick prerecorded demo at this URL .

In the future, I “ll deploy this application in one of our public servers and will review the code.

Last year, while attending a conference in India, I met an excellent Sun “s software engineer Greg Murray, one of the authors of the idea of Pet Store application. Greg, I hope you “ll like this version of your pet store.

Flex, JavaFX, Silverlight hellip;

I “ll be honest with you, during development of this application in the back of my mind I “ve been constantly comparing the way things are done in JavaFX with how I “d do the same with Adobe Flex.

Simply put, today, Flex is a lot more productive than JavaFX. But let “s remember that we are comparing products of versions 3 vs. version 1. If you know how to develop Swing applications, you might want to continue doing this rather than manually creating JavaFX 1.0 wrappers for Java code as we did in our Pet Store.

The biggest issue is that JavaFX 1.0 doesn “t include any UI component library that a Web developer needs. I “m not talking about data grids or tree views. Even such simple things as a hyperlink component aren “t there. I can “t think of any other reason but a trivial lack of time and limited human resources allocated by Sun for development of this new UI set.

Hopefully, Sun will release a JavaFX 2.0 in foreseeable future with a full set of UI components, containers, navigators, and layouts. Just to draw an analogy, Microsoft has released absolutely naked Silverlight 1.0 in 2007, but full featured Silverlight 2.0 became available a year after.

The good news is that Java developers have already started building their own open source components for JavaFX. The name of this project is jfxtras .

On the other hand, I see some features available for JavaFX developers that are missing in Flex.

For example, ActionScript doesn “t support multi-threading. This is not an issue when it comes to communication with remote sites ndash; all remote calls are asynchronous and use callbacks for server-to-client data flows. But if you “d need to write or use an existing Java library that performs some CPU-intensive calculations on the client, I “m sure Java will beat ActionScript. The syntax of both languages is pretty similar though (see http://flexblog.faratasystems.com/?p=115).

JavaFX supports eval() function that allows to compile and execute a piece of code on the fly. Flex doesn “t support this useful feature.

Two-way binding already exists in JavaFX but in Flex will get it only in version 4.

I “ve yet to see some benchmarks comparing Flex and JavaFX network protocol. The latter just offers XML and REST for data exchange between client and server. Of course, you can program Java sockets or wrap up an RMI client into JavaFX ndash; would it be faster than ActionScript Real-Time Messaging Protocol? We don “t know. Or take HTTP tunneling between Java Applet and a server-side Java stream. Would it be faster than using AMF, an HTTP-based binary protocol? We don “t know yet.

JavaFX removes a lot of complications in developing mobile applications. It promises to remove the need of using Java SE for desktop and Java ME for mobile ndash; JavaFX should be the only solution you need. JavaFX Mobile offers hardware acceleration. Keep in mind, there are 2.6 billion of Java enabled mobile devices! JavaFX has serious advantage in this domain over Flash Lite.

JavaFX 1.1 is about to be released. It offers performance improvements, bug fixes, new features in the mobile space, but no major additions to the desktop platform.

I understand that this is not a good time to ask for some serious cash injections, but if executives of Sun Microsystems won “t find a way to double the size of the team working on the future version of JavaFX, entire Adobe Flex team can safely go on sabbatical for a year. If the money is tight, the sooner JavaFX will go open source, the better.

Even though I wouldn “t start developing with JavaFX a project that needs to go in production this year, overall, JavaFX looks promising. Try it out and see for yourself.

In defense of Joel Spolsky

Joel Spolsky doesn ‘t need my help in defending himself. But since he ‘s my favorite blogger and a person I highly respect, I fill obligated to speak up.

Mr. Curt Monash has written an article implying that Joel overestimates his importance while not achieving that much since he was able to grow his company to “only ” 25 people.

This article is written based on the wrong assumption that the number of employees is an indicator of success of the founders of the company. Joel ‘s company has about twenty five employees, which is the border number when the company remains agile, manageable and doesn ‘t require an overhead in the form of mid-tier management.

Besides, every founder of a company has his/her goals and priorities that may include (surprise, surprise!) having some spare time for personal life too.

I have no doubts, if Joel will ever decide to open a consulting arm at Fog Creek he ‘ll easily bring the number of employees to several hundreds or more.

Many business people in the US are turned into well trained zombies sharpened to achieving gross and ultimate profitability no matter what. These people can ‘t understand that investing into spacious offices and good furniture for their employees makes any sense. Why bother? Just squeeze them into tiny cubes and make sure they work hard!

This narrow-minded author doesn ‘t understand that there are small boutiques that just don ‘t want to grow and prefer to enjoy running a business, rather than turning themselves into money making machines.

Ten years ago, I ‘ve been vacationing in France with my family and friends. We ‘ve rented a car and were enjoying visiting small picturesque villages. One day, we were walking in a one horse town in Burgundy, where making wine is the main (if not the only) business. It was about noon when we noticed a small wine store and decided to purchase a case of good Burgundy to smuggle into the USA.

The store owner politely but firmly told us that he ‘s closing his store for lunch. We were shocked. A group of tourists is about to purchase his only product, we are the only people around, and he ‘s closing for lunch! The only thing we were able to negotiate was letting us in the store and browse his wine cellar while he was eating. Real French people take their lunch time very seriously.

I wonder how the author of that article could explain the behavior of the owner of that wine store? Most likely he ‘d say that French don ‘t like Americans. Wrong. You just need to accept the fact that there are people with different culture, habits, values…There are people who make business and actually enjoy their lives.

Three years ago, I had a chance to meet Joel on one occasion. I ‘ve invited him to deliver a keynote at SOAWorld conference in New York City. Not everything went as smooth as we planned – I don ‘t feel like going into details here. But I had a chance to see that Joel is not only a smart man and great speaker, but is also a person of high integrity.

No, Mr. Monash, bigger is not always better.

twitter.com/yfain

IT offshoring will put US corporations to their knees

During tough times, large US corporations try to find ways to cut expenses. All of a sudden, you don “t see those people who were watering plants on your floor. Then, the access to the drawer with office supplies becomes as restricted as getting to a safe deposit box in your bank.

The other day I met an employee of a large corporation, and she told me that her manager didn “t allow her to send a delayed report via Fedex because it was more expensive than using US priority mail.

The training budget gets circumcised next.

During the crisis times people start worrying about executives ” bonuses and try to take their corporate jets away.

But there is one expense that these jetless and bonusless executives don “t want to discuss. Yes, I “m talking about the money spent on offshore software developers.

I spoke to an employee of a huge corporation – he goes through an annual performance review and was punished for not keeping the offshore consulting team busy when they didn “t have anything to do! No, they are not allowed to cut this umbilical cord. The management keeps lying that offshore development is cheap. They keep covering up the facts that the programming quality is poor and their US-based employees have to quietly re-do the assignments received from overseas. This subject can “t even be discussed. The big shots made their decision many years ago: hiring offshore teams is good. Case closed.

I ‘m a partner in a small company, and we also work with offshore programmers. But we don “t work with teams, we work with individuals that we like and need. Every morning, I spend a couple of hours on the phone with our developers working overseas, and trust me, as soon as I “ll see that they either not deliver of don “t have work, they will be gone.

Large American companies don “t have this luxury and keep carrying this unneeded cargo. Dear CEOs and CIOs, corporate jet expenses are peanuts comparing to the amounts of money YOUR corporation loses because of wasting money on low quality offshore “helpers rdquo;. Your mid-level managers will keep lying to you that “our offshore partners are profitable rdquo;. They keep waving flags that read “Can “t beat $15 per hour rdquo;. Lie. In many cases people getting these $15 per hour just don ‘t deliver, are underutilized, and work productively only 5-10% of their time!

Let “s do some math. Say, one offshore programmer costs your organization $15*8*40=$600 a week. It looks cheap. Ten programmers cost you $6000 a week

In the best case scenario, only 3 of them are good developers and deliver. If the rest of the team that you are forced to work with is just taking your time, requires writing more detailed spec and delivers poorly tested code, this means that you are actually paying $6000 a week for the work of three developers. Each of them costs $2000 a week, which translates into $400 a day or $50 an hour.

There is so many great developers in Texas, Colorado, Utah, Georgia that will be happy to work for you for $50 a hour!

My hat off to IBM that demonstrated ultimate creativity. If you work for IBM in the USA, get prepared to get shipped to India. You ‘ve heard it right. They call it Project Match. If in the past century there were companies who were helping, say a white male to find a perfect match among black males. IBM will find a match between you and a third-world country. They ‘ll also match your compensation to level it up with salaries of people around you. Sure enough, your cost of living in India will be lower than in New York, but you ‘d better not plan to come back home with those savings you ‘ll make in Bangalore.I smell a mismatch here…

Three years ago I “ve written an article “What CIO Should Know about Outsourcing Enterprise Java rdquo;. Forget about Java ndash; it “s happening in any large IT organization regardless of what programming platform they use.

I wonder how deep our economy should sink to force executives cutting these large offshore vampires loose?

twitter.com/yfain

Data synchronization with AIR and BlazeDS

One of the main selling points of Adobe AIR is its ability to support occasionally connected applications. Imagine a salesman on the road working with an application without having a network connection. As an example, this can be a salesman of a pharmaceutical company visits medical offices offering their new pills called Xyzin.

While in doctor “s office, she uses an AIR application to take notes about this visit. The notes are saved in the local SQLite database that comes with AIR. But as soon as the Internet connection becomes available (at Starbucks or at home), the local data get synchronized with a central database.

Adobe offers a data synchronization solution based on Data Management Services for those who own the licenses of LiveCycle Data Service. But those application developers who use an open source BlazeDS don “t have any generic way of setting such data synchronization.

We came up with a such solution that will be included in the upcoming version 3.2 of our framework Clear Toolkit .

Watch the following screencast to see a demo application which shows such data synchronization in action: http://www.myflex.org/demos/PharmaAir/PharmaAir.html.

twitter.com/yfain

My talks on Flex, JavaFX and a $300 coupon

During the next three months I “ll be making a number of technical presentations for Flex and Java developers. These are the confirmed events:

1. New York Flex User “s Group, February 19, Flex design patterns, details should be available soon at http://nyflex.org

2. Java developers conference in Atlanta, March 11 – a keynote on comparing technologies for rich Internet applications and a technical session on automatic code generation for CRUD RIA. Details at http://www.devnexus.com/

3. Chicago Flex User “s Group, March 18, Flex design patterns, http://chicagoflex.org/

4. Princeton Java User “s group, Developing Pet Store in JavaFX. I “ll schedule this meeting some time in March. Keep an eye on http://myflex.org/princetonjug

5. Flex conference 360Flex, Indianapolis, IN, May 18-20, Design patterns: a Deep Dive: http://www.360flex.com

My colleague Victor and I will run a two-day public workshop for enterprise Flex architects in New York city on March 2-3, details are available at http://www.eventbrite.com/event/247789144 . Readers of this blog will get $300 discount by entering a special code adjusting2crisis during registration.

That “s all for now.

Yakov Fain

More on enterprise Flex development

The rough cuts version of the first chapter of our book “Enterprise Development with Flex ” is already available for subscribers of Safari Books Online .

The first published chapter is about the use of selected design patterns in Flex. This is not a tutorial, but rather a bunch of illustrations of why and how you can use some of the patterns in Flex. For example, everyone know what Singletons are for. In this chapter you ‘ll see how you can use Flex Application object as a singleton storing your business objects. Yep, no need to clutter your code with tons of XYZ.getInstance() calls.

Or take an ObjectProxy class – you can easily use it as a wrapper to any other ActionScript class adding a new functionality to the class being wrapped even when you don ‘t have access to the source code of this class.

Mediator is my favorite design pattern for UI development with Flex. A component A talks to a component B in a loosely-coupled manner via a mediator using custom events.

We ‘ve already submitted six chapters to O ‘Reilly, and hopefully more of the rough cuts will be published in February. In one of them we compare Flex frameworks, the other shows you how to extend Flex components to make them smarter, chapter 10 is about Flex portals, chapter 7 is about loaders and modularization, chapter 4 deals with BlazeDS and AMF, chapter 4 talks about a set of tools that an enterprise Flex team should consider.

My co-authors work on their chapters late at night, but I “m more productive during wee hours. In particular, this Saturday morning I “ve been working on the AIR chapter. It will include sample occasionally-connected application for the salesmen of the Acme Pharm company. You “ll see how to synchronize data between the local and remote databases via BlazeDS. Next week I ‘m planning to record a screencast showing this application in action.

I ‘ll finish up this brief post with an announcement for enterprise architects who somehow came to the conclusion that Adobe Flex is the right technology for development RIA. My colleague Victor and I will run a two-day workshop for application architects and development managers giving a compressed overview of the proper way of running Flex projects. This is a unique class that ‘s not offered anywhere else. The class will take place om March 2 and 3 in New York City, and the early bird price will expire in 5 days. Details at http://www.eventbrite.com/event/247789144

Yakov Fain

Getting my hands dirty with JavaFX

I ‘ve started looking into JavaFX and plan to publish a couple of articles going through development of an application that real-world software developers can relate to. Enough of the demos of bubbles moving up and down in a glass with water. Can ‘t recall any application in my rather long career that would require to program something like this.

While looking at the JavaFX way to do stuff, I subconsciously compare it with Flex. So far as expected, Flex is a hundred miles ahead. But to be fair, one shouldn ‘t forget that we are comparing products of 1.0 and 3.0 versions. At this point, JavaFX would require to do a lot more of manual coding in Java than I ‘d like to see.

Lack of such important components as data grid would require you to wrap Java ‘s JTable and program to it. You need to program such basic things as a hyperlink component…

Eclipse plugin for JavaFX is not real. As of today (January of 2009), to use JavaFX you need to install NetBeans 6.5 and have a background of a Java Swing programmer, which will be an obstacle for many Java developers.

But, let ‘s give this product a little bit of time to mature.

I ‘ll write my first JavaFX article for Java Developer ‘s Journal in February. BTW, have you seen a new look of JDJ and Flex Developer ‘s Journal ? Expect some more very interesting announcements from sys-con that may turn you into a published author. Just keep an eye on the word Ulitzer.

twitter.com/yfain

Advanced Adobe Flex Training

The number of software developers who are comfortable with Flex has reached critical mass and we started getting requests for advanced Flex training. People not just want to learn Flex, they want to use it properly.

We have created a two-day curriculum for Enterprise architects and already successfully delivered it to a group of application and enterprise architects of a major insurance company.

Now we “ve decided to offer it as a public training to help enterprise architects, development managers and team leaders to understand how to run real-world Adobe Flex projects. Attendees will get an overview of frameworks, tools, utilities and best practices of RIA development with Adobe Flex and Java. This technical event will help you to avoid typical architectural mistakes usually made on first projects with Flex.

This is not a hands-on workshop, but rather a fast paced immersion into the world of RIA with Adobe Flex. Here “s a brief overview of the curriculum:

Adobe Flex Architecture

Thinking in Flex

Accessing Enterprise Server Tier

LiveCycle Data Services/Blaze Data Services Architecture

Flex Communication Protocols

Flex Messaging:

RPC Services

Data Management Services

Modularization of Flex enterprise applications

Flex Portal Applications

Integrating Flex applications with External applications

Staffing Flex projects

Comparing MVC Architectural Flex Frameworks

Overview of Clear Toolkit framework

Troubleshooting AMF

Overview of testing tools for RIA

Automation of ANT script creation

Flex Developer ‘s Workstation

Minimizing the time of Initial Application loading

This training will take place on March 2nd and 3rd in New York City. Visit http://www.faratasystems.com for details.

If you are just starting working with Flex, consider attending five-day Adobe Certified Flex training that will take place in New York City on March 23-27, 2009.

We are also working on the courseware for the advanced two-day hands-on workshop for Flex developers. The first day will be titled “Unleashing the power of Design Patterns in Flex rdquo;. The second day goes by the working title “Enhancing Flex components rdquo;. This training will be offered to the public in April 2009.

Any of these curriculums as well as two-day introduction to Adobe AIR can also be delivered onsite at your organization.

If you can ‘t attend our training, consider reading our upcoming O ‘Reilly book “Enterprise Development with Flex. ” The first rough cut chapter is already available to the subscribers of Safari Books at http://my.safaribooksonline.com/9780596801465.

Yakov Fain

Skiing in Alps. The cutoff leg

Yesterday, in the cafeteria, there was this square thingy with a boiling water. Several eggs were peacefully boiling in special holders made of wire. Victor stopped by and picked two eggs from there. A Frenchman who was standing nearby gave him a weird look, and Victor realized that this guy didn “t like the fact that he put the eggs on the plate instead of available china egg holders. The eggs were very tasty and ten minutes later Victor decided to have one more. This attempt was not successful as the real owner of the eggs explained that each person supposed to boil eggs for himself hellip;Oops hellip;

Two firefighters from Belgium were skiing in our group. The older one (he ‘s 76) told us this story. Thirty years ago his squad arrived to a highway were a car with a man inside was on fire. The leg of the driver stuck in the car, and there were not enough time to pull him out of the burning car. And the firefighter took his axe and chopped the driver “s leg off right under the knee. Then, he pulled the driver out of the car saving his life. I wonder if this would happen in the USA today, would a firefighter made the same decision without thinking of his lost job and law suites of the saved but crippled man? I don “t know.

Here I am drinking grog during the lunch break:

We spent the evening watching the show prepared by the resort crew. The MC sucked ndash; he was an old fart of my age. The show was good, especially that long legged black girl. I knew she was a professional dancer!

Today “s the last day of our vacation. Instead of skiing a small group of us went to the Aqua place I “ve been two days ago. We arrived at 10:30AM and it was suspiciously cheap ndash; just 6 Euros. After I got in, I realized the sauna was closed till 11:30AM and the only option I had was to immerse into a pool with about 20 mermaids who were doing Aqua aerobics. The average age of a mermaid was 70 years, and this number would be a lot higher if my ever-young wife would not be one of them.

The aqua aerobics instructor spoke French only, and it was hard to figure our what movements I was supposed to do under the water without peeking at the tails of the mermaids that were splashing nearby. In 45 minutes the lesson was over and we did the sauna and the steam room.

While waiting for a seafood buffet, we “ve had a conversation discussing why some women have issues finding a new husband after a divorce. David said that one of his friends complained that no one responded to her post on the online dating Web site. David asked, “What did you put in your ad? rdquo; 
She said, “I put that I like having romantic candle dinners in nice restaurant, listening to the classical music hellip; rdquo; 
David was divorced for a long time and he responded, “With this ad you “ll never find a new husband. Write that you will cook him a nice dinner daily, wash his clothes, and won “t control him all the time. rdquo; David is a smart guy!

To add my two cents to the discussion, I told them a joke. A couple spent many years together and the wife said, “Honey, if I die first, don “t grieve for too long. Get remarried. rdquo; The husband answered, “No, if God forbid, you “ll die first, I “ll never get remarried. I won “t be able to find a woman better than you, but having another one as yourself is the last thing I want. rdquo;

We already packed our bags. This was nice group vacation. One misplaced shoulder, a swallen tooth, two pulled backs, and one pulled leg don ‘t count. It “s time to get back to work.

twitter.com/yfain