I am a 20 year veteran of the IT industry. I have been using both JavaEE and Java SE since 1998. I have developed Web and Desktop applications for a variety of clients in various industries, including the airline and banking fields. I was a tester for Java Studio Creator, and was the first Creator Hero, highlighting my emergency responder application. I have been a presenter at the JavaOne conference, and I earned the 2008 JavaOne rockstar award which highlights outstanding presentations. I am currently a Java trainer, presenter, and consultant in the Cincinnati area, and the owner of JFrets, an open source guitar teaching and tablature creation application. I am a guitar player for The Stone Bunnies and bass player for G.P.S.
I am a 20 year veteran of the IT industry. I have been using both JavaEE and Java SE since 1998. I have developed Web and Desktop applications for a variety of clients in various industries, including the airline and banking fields. I was a tester for Java Studio Creator, and was the first Creator Hero, highlighting my emergency responder application. I have been a presenter at the JavaOne conference, and I earned the 2008 JavaOne rockstar award which highlights outstanding presentations. I am currently a Java trainer, presenter, and consultant in the Cincinnati area, and the owner of JFrets, an open source guitar teaching and tablature creation application. I am a guitar player for The Stone Bunnies and bass player for G.P.S.Why? Because that’s The Way It Is!
If you thought your job as an application development person is difficult, try being a consultant. I love my job as a consultant because I am able to affect change, that is, when people want it. The most dreaded phrase a consultant can hear is “that’s the way it is”. Those words have no rebuttal, no further review. It’s the organization’s way of saying “talk to the hand”! My job is to find gaps in code or process and bring them up to the client. Often times the client has fallen into way of doing things that are counter productive, or more likely, have not changed since the process was in place. A case in point, I was having a discussion with an architect about code review. I noticed that they had the Legacy style user, date, and change comments at the top of their classes. I made a review comment that they weren’t necessary, because Subversion tracks the changes for them. It was due to their work process that comments would be lost by Subversion on multiple merges. I mentioned that several high profile companies use Subversion and don’t seem to have a problem. The architect said that research was performed and it doesn’t, and if I have a better solution, I should do my own research before making a comment. I told him that software does indeed improve, and that if research has been done, it should be reviewed periodically to see if the issue had been fixed. I did research the issue, and Subversion did have bug but was fixed, and my client could use comments in their merged code. The key here is that the staff complains that changes don’t get done, but when they are in a position to make it better, they don’t do it. If anyone investigates a new technology or work process it should be DOCUMENTED AND REVIEWED! I don’t know if it will be investigated because it seems like a trivial issue, but the main problem is that the application development people complain that nothing changes. It’s our Culture. Culture is people, and all people, especially application development people can change culture. If there are deprecated methods and TODOs in production code, bring them up in your code review. I don’t accept “that’s the way it is” as a reason. You can’t change a decision for business reasons easily, but you can fix how things get done. If I don’t like the way that it is, I make it better.
Phone Questions and Blog Roundup
I have been writing a lot about phones recently. What application development person wouldn’t be excited about the new smart phones? I will talk about that later, but first, the news! My colleague Aaron Whitenberger has been interviewed about his role as a Certified Business Analysis here at STAR BASE. If you didn’t know there was such a thing, you should read it now. I wrote my take about Google VS Viacom. Google spent 100 million dollars to defend their right, and it didn’t even go to trial. Vicacom is appealing, of course. The price of freedom is very steep.
Now on to my phone questions! A Java application development peer my client site refuses to get a Android phone because of “market fragmentation”. “I like that iPhone is walled off, but it’s on ATT”. He loves his blackberry, so maybe he doesn’t need it. This post from Slashdot seems to support his case. My questions to you are why did you get a smart phone? Did you consider the operating system when you got your phone? Which would you rather choose, a fragmented but open system where you can get any type of app but could have bloatware, or an operating system ruled by a “benevolent dictator” which strictly controls your hardware and software, but you are free of bloat issues? I choose Android because of its openness. I do have the technical skills to root my phone to remove bloatware if I need to. Some people can’t or don’t. I think Apple went down this road before, and I think you will see Android be the market share winner. Let’s see if Google can do better than Microsoft in maintaining some control of the platform, but still give 3rd parties the tools to innovate.
The Value of Communication
There are many skills needed as an application development person to be successful, but none more important than communication. In fact, that is point of our job, to be able to communicate to our peers, partners, and customers. I believe that most organizations make money in spite of the immense lack of communication. Most of the application development people I know complain more about the policies and procedures than about anything else (although it’s always something!). Aren’t policies and procedures communication? Certainly, but it’s the internal communication that enables and drives the external communication. Everything we do has an impact on our ability to communicate. Say the wrong thing to a journalist, and you will be removed. Miss that deadline, forget about the promotion. Governance is important for the security of communication, but when do these rules get reviewed? Ask any software development person or manager why, and the answer usually is “that’s how we do things here”. The real answer is that someone set that restriction to an event that happened long ago, and nobody is willing to change things. If communication is the life blood of an organization, why would we restrict the life blood arbitrarily? If this sounds like your organization, maybe you need to review how you are handling your communications. If you need help, STAR BASE Consulting has years of experience triaging your life blood, and making it flow easier, better, and stronger.
Phone from England
I wrote in my last post about looking forward to using my phone in England. Well, I am back (It was wonderful) to tell all of my application development people and friends about my experience. It was a bit of a struggle to get my phone unlocked. I had just unlocked my G1, and when I purchased my new phone, my provider said that they only allow a phone number to be unlocked once every 90 days no exceptions. I understand that, as unlocked phones are very desirable on the open market, but I want to use my phone. After not taking "no" for an answer several times, a workaround was found. Once landing in England, finding a phone provider was easy. Unlike the US, you have to purchase your phone at full price, and then select a provider. Sure, you don’t get a cheap new phone, but you aren’t saddled with a poorly operating service provider either. My first stop was at an O2 store by my Tube (London underground) station. They were very helpful, even though they couldn’t provide me with a plan. They suggested I go to T-Mobile, and even gave me directions! I would like to know from my application development friends if they ever had helpful service from their phone provider. I went to T-Mobile, and got my SIM card. This is a pay as you go card. I got the card and put 5 pounds for use. Since my phone is not available in the UK yet, I got to show it off. I also got the free international rate of 5 pence (about 8 cents) a minute to the US. My roaming charges would have cost me $1.49 a minute. The data plan was 1 pound a day for unlimited surfing at about 10 MPS. That was much better than $15 per Megabyte usage. How difficult was it to switch networks? I just swapped out SIM cards and it was ready to go. I was able to use Google maps (with turn by turn walking directions), get tube updates, and find places on the Internet. It was the fastest my phone had ever worked. I had used up my initial 5 pounds, so I went to Tesco (like CVS or Walgreens) and added another 5 pounds there. Super easy! Now, if I go back, I have everything I need to use my phone. On my return trip I swapped my SIM card back to my original, and everything worked from home again. I wished the US had this as the competition was on consumer services, and better features and not trying to make it difficult to use your phone or change services.
Roaming the UK
In my recent post, I talked about my new phone for my upcoming trip to London. I am excited about my new phone, but not the cost. My carrier charges .35$ per outgoing SMS, .20$ per incoming SMS, and 15$ per MB for data. Since my phone is always “listening” on the Internet, it would cost a lot to actually use my phone in London. I can put my phone in “airplane” mode and use the camera, games, and music capabilities, but why have smartphone and not use its features? Fortunately, the solution is relatively simple. I can unlock my phone and use a pre-paid SIM card while in the UK. For my application development friends who are not phone savvy, let me explain. US phones are “locked” for US usage only. All carriers also make some phone features unavailable to the customer. In some cases, you are charged an additional fee for a feature your phone could perform for free! In this case however, I am unlocking my phone so I can use it on other networks. You may have heard of the term “Jail Breaked”. This refers to a phone that has been hacked to allow all features on your phone to be used. Some phone manufacturers and carriers don’t like this, and can make your phone unusable, or “Brick” your phone. Unlocking through your carrier is perfectly fine though. Once your phone is unlocked, the second part is to get a SIM card in the country you are traveling to.The SIM card is how the network recognizes you. If you opened your phone and swapped your SIM card with a friend, you would get all of his calls, and he would get yours! You can pick up a prepaid SIM card with a data plan for about 10 pounds (approx. 15$) a week. That’s a hefty monthly bill for a local customer, but it is much cheaper than the roaming plan. Remember, your phone number is different with a different SIM card! I can use my phone features to post messages and images on Facebook, for example, like I was at home. I can communicate with people at home without paying hundreds! I will let you know how this works out when I return.
New Android Phone!
In a break from my recent posts, I am going to give my application development peeps a review on my new Android phone, a MyTouch 3G Slide. The reason I got a new phone is that I am going to England with my son in a couple of weeks, and I want to use my phone as a camera and video device (and GPS, etc). The G1 can do these things, but it doesn’t have a flash or zoom. Besides, it’s been nearly 2 years since I have switched. Phones have become the new computers; a drastically newer, faster, cooler version comes out every 6 months. I was seriously looking into a Nexus One, but Google makes it too difficult for existing T-Mobile customers. To get a Nexus One, I had to get a NEW line. The T-Mobile representative said I could have folded that account into my existing account, but I couldn’t use my existing phone number with the new phone. That was too many hoops to jump through just to get a new phone. Could I find a comparable phone by T-Mobile? I was in luck, the new MyTouch 3G slides just came out! In specs, the only glaring difference was that the MyTouch doesn’t use a snapdragon processor. One of the other big selling points was that the MyTouch has a QWERTY keyboard. I have big fingers, and I enjoy the tactile feel of a real keyboard. The MyTouch comes with Android 2.1, with Froyo (2.2) coming soon. Some cool new things about my new phone:
3.5 MM jack (My G1 had a proprietary jack)
Larger storage- comes with 8G SD card, accepts up to 32G
Syncing my ITunes library with my phone
Adding movies to my phone
Overall, I am very happy with the speed and features. The only drawback is that my apps didn’t come along for the ride. I think I am going to create a backup on the G1 and try to move them to the new SD card. Hacking type application development people would love Android! The funny thing is that my phone comes with Swype, a new way to type by tracing a line to each letter of a word. It sounds complicated, but it is fast! I don’t need to use my QWERTY to be productive! I can hear my application development friends asking what will I do with my G1? I can now play around with rooting my phone and flashing Cyanogen without worrying about bricking my phone. If my experiments work, my son may be getting a sweet phone!
Youtube Versus Viacom
For those of you not following geek things, there is a lawsuit going on between Youtube (owned by Google), and Viacom (CBS, Daily Show, Colbert Report). Viacom is angry that some of their content was posted on Youtube. Apparently, there was 63,000 separate items on Youtube that were copyrighted by Viacom. Viacom has been supported with a “Friend of the Court” brief by NBC, BMI, and ASCAP (Basically the RIAA). Google has similar briefs by EBay, Facebook, Amazon, and Yahoo. How does this court case affect me as an application development person? Well, it could determine your web application development. There are many interesting issues here: fair use, piracy, site owner responsibility. The key issue here is for the very soul of the Internet. As you probably know, the Internet was created to share information amongst researchers around the globe. This communications device allows us to share voice, text, audio, and video. This makes it easy to share ideas, even if those ideas weren’t ours. A part of that communication is the same kind “water cooler” talk that everybody has done for years. “Did you see what that talk show guy said last night”? The only difference is now you can post it. This song expresses how I feel, and I have added some pictures to show how it has affected my life.
The media outlets want the site owners to control the content on their site. They claim that Youtube is a content provider, and thus are “stealing” their content for gain. This would be analogous to suing the U.S. mail for getting a threatening letter. We have fair use, so any signal sent through the airwaves is free for anyone take and use. This meant that anyone who broadcasted, the content could be consumed by anyone. The content providers made money by placing advertisements in the content. Since that time, content providers have been using congress to side step these boundaries by changing the length of copyright, putting "digital" rights on formerly analog content, and pushing for laws that allow content to be controlled by the provider. The large media companies ignored the Internet because there wasn’t any correlation to their business. When companies like Google started to compete for the same advertising dollars, the large media outlets saw the Internet as a threat to their business model, and are now looking to destroy it.
No one is trying to deny content providers money. It was agreed long ago that your work was yours, but eventually it would be owned by the public. That changed when media companies are entirely built upon their own content (just look Mickey Mouse at Disney). Do people take content that doesn’t belong to them? Yes. Are people just posting items broadcasted to make their point, or to inform? Yes. We have to decide as a society whether the Internet is place to allow copyrighted material as a form of communication. NBC found it distasteful that their shows were on Youtube. That’s why they created Hulu.
What do you want the Internet to be, a free (as in liberty) communication device, or a pay-per-view broadcast medium?
Know Your Role
I am finding out things at my current client that everyone, including application development people knows; having a process is only half the battle. I have been to organizations where business workflow processes were not in place, and the productivity gains were huge when implemented. But over time, those processes stop getting followed. There are many reasons for this; the IT culture rejects the change, the processes don’t get reviewed in a timely basis and become a burden, and the players forget their role.
My client has a decent development workflow in place. Analyst get requirements from the business units, architects turn the business requirements into technical requirements, and application development people execute the requirements. Managers should manage the process, making sure that the resources are available when needed. I always wondered why top technical guys get passed over for management in favor of PHB (Pointy Haired Bosses), and now I know. It’s that PHBs know their role. Managers are managing the PROCESS, not the solution. Often, technically savvy managers want to work the issue. Software development is a very fluid process, and what works now, may not work three years from now. If you are manager for more than six months, you probably don’t know the correct solution. Regardless, your role is to make sure application development staff are available for the solution designed by the architects. Managers have a right to review the design during the design phase, but once finalized, let the architects and application development people do their jobs.
The same is true for consultants. Yes, they are using older technology, and yes it’s a pain to use, and yes it needs to be updated. Your job is to help resolve those issues within the framework of their organization. Unless you are brought in as a CIO consultant, the choice is probably not yours to make. It may be that the business has urgent needs that supersede modernization. They may not have the technical people to maintain the new code. The organization could be planning to replace the system with a prepackaged application like SAP. Or it could be that the technical staff knows their role, and is waiting patiently for their opportunity to upgrade.
The Secret to Good Performance
I am now in my second stint as a performance architect. There are many tools to measure performance. Usually there is some criteria like time or memory that is failing. I think most application development people know that the secret to good performance is good code. The problem is that good code is impossible to measure. There isn’t any metric you can show your boss that shows refactoring this class will make the code run faster, or at least will not remove that class from the performance list. Besides we have these new features that need to be added. So how do I make code perform at a high level?
Write unit tests. Make sure that the tests cover all of your method calls. Make sure that your test captures error situations, not just the "happy path". Write your test cases BEFORE you write your code so you can "code to the test". Of course, you need good use cases from your architect and business analyst to write the unit tests.
Comment your code. Make sure your method names describe the function it is performing. Most IDEs add the parameters and returns for you; all you have to do is describe the reason for the method. These are easy things to do. They are boring yes, but when it comes to adding that new feature, or changing a method call, it saves a lot of time when you can run a test to prove that your changes work.
Refactoring. All application development people should learn refactoring. The Java language has changed tremendously in the last 15 years, and your code hasn’t. I think that the Date object has been revamped twice since the 1.x days. New features like annotations and generics may not change the performance of the code, but it sure does affect the readability of the code. Readable, easy to understand code is also easy to maintain and update. It makes a six month project become a three month project. The business always has more projects, so they will be happy. Fewer errors happen, so your boss is happy. You get to solve more interesting problems so you are happy. When you are happy, both you and your code performs better.
Death by A Thousand Cuts
My client has great code promotion rules. All code that changes gets system tested or it doesn’t get promoted. Code doesn’t change unless it has a bug tracking ticket. You say Matt, that’s great! Why is this a problem? The problem resides in the fact that everyone in IT is stretched to the limit, and deadlines are tight. Application development people are getting the code working with little refactoring, architects struggling to get the analysis piece out and little time for code review, and not enough testers. This situation makes it difficult for performance. As part of the performance team, I can review all of the code, and make some changes, but the problem is that if the code is not a part of the release, it will be impossible to get promoted due to time/resource constraints.
For example, a process was taking a long time to complete because of improper error handling, but the call is not necessary. The proper fix is to remove the call, but the fix going in only resolves the exception. Why? The low priority of the code, coupled with the testing constraints and lack of testers makes these changes common. Some application development people may say, "Well, the code is fixed". True the performance issue is resolved, but there is an unneeded call. If the attitude from application development people is "I would fix it, but it’s too much trouble to test", unneeded code can add up quickly. Extra code is in all projects, but if changes like this or, removing a variable passed to a method, or even changing code to remove unused variables don’t get fixed, the "extras" add up. Not one of these changes significantly affects performance, but all of them will. The solution is to work with management and your application development people to limit "extra" code. This can be done by reviewing and fixing code in your maintenance or enhancement project. Have a "refactoring time" built in to the project plan. The time put in up front will bring great dividends both in performance and future coding effort.
Got Tools? Use Them!
I have a new client in Cincinnati. New clients are always interesting because you never know what issues and opportunities you will find. My client seems to have their act together. My application development friends will appreciate their setup; Maven 2 projects with built-in JUnit tests, a code coverage dashboard that show code complexity, code coverage, and Find Bugs reports. Things seem great, them why do they need a performance engineer?
The reason is common; who defines the duties of ITsets the rules. IT and the business need to be aligned to work on the common goals and increase productivity. If IT is too dominant, there is too much focus on technology and the business doesn’t get the tools they need to be productive. If the business unit is dominant, only projects that have a tangible return get done. In this case the business is more dominant, so projects like refactoring code, or cleaning up errors found by software like Find Bugs has a much lower priority. They do happen only if performance is an issue to the business. The performance team is set up like a clean up crew that comes in after the fact, to make things work better. There are coding style forms and best practices, but is up to the each developer to follow them. Since the focus is getting the project done on time, the developers are concerned on getting code that works,not what works best. The performance team is used to fix the worst performance offenders.To be fair, I have been at clients where IT treats the business units as a nuisance. The best tools are there, but little support for the business.
What’s the solution? IT needs select a technology that best suits the solving of business problems. The business should prioritize their issues, but work with IT to plan for fix releases. IT must utilize the tools that they have and encourage the usage of them. If you have the tools, use them!
Getting Some REST
After playing with JPA, I realized that I really don't want to directly hit the database from the client, because that would mean opening up the database port to potential attackers. JPA is really great, but either you hit the database locally, you hit the database directly from a remote location, or you access the database through a connection pool. JNDI is the best way to access a server resource, but it needs to be in a server container. I could not find a way to call JPA using a JNDI context from the client. All database servers have some mechanism to accept multiple connections. But besides the obvious security issue, I already have an application server and connection pool. I should let the connection pool do the work, and figure out plan B.
I reviewed all of my options. I am lucky because I can use the latest and greatest since this is all new. I am using Java 1.6, so I can use EE5 or EE6. Most application development people know that EJB has had a history of being complex, and at times, unwieldy. I could call JPA via servlet, but I was concerned about performance. I decided to use RESTful web services to push data to my JavaFX application. Using REST in JavaFX is quite easy, because the 1.2 specification has a HTTP request object. That means I can write all of my access and utility objects in JavaFX, instead of accessing a class library externally. The big drawback I have thus far is that all of the related objects are another link, and another call to a REST resource. For example, if you look up a specific Customer Record using REST, you will get the details in XML or JSON. To get the collection of Orders related to the Customer, the XML returns a link. You must make another call to get another XML/JSON to parse the related information. The parsing process would not be to big of a deal, except that everything is done asynchronously. I have a Table A object where one of the fields would be a collection of Table B objects. The Table B object contains a collection of Table C objects. In JPA, all of the related collection objects are there and ready for me. Since REST is asynchronous, It makes it very difficult to set up a Table A row object, because Table B is a separate call which will start and finish without Table A's call knowing anything about it. For my database application development people, the key is to de-normalize your relationships. Since this is a big departure to my original schema, I decided to create a whole new database in case I wanted to go back to JPA. After some trial and error, I have a way to asynchronously access and display REST resources in a JavaFX application. I now have to work on writing that data.
Everything Old Is New Again
This post may shock you... the Java Rocker is going to talk about legacy iSeries and AS/400! Before you panic, and call it the end of the world, let me continue. This post is about running all of the cool new Web 2.0 things on your IBM hardware. Really! Even in Cincinnati! Many people, (myself included) thought the old IBM hardware was only for RPG and COBOL (shudders). It turns out that IBM has been adding functionality to run Linux on the box. That means Wikis, Ecommerce, blogs, and web applications are now there for iSeries-AS/400 people. The catch is that your iSeries needs to be up to date, which sadly for most organizations is not. My IT consulting colleagues at STAR BASE are good with taking your tired old hardware and doing the maintenance necessary for the modernization piece. They get your hardware and software cleaned up and ready, so I can help you with all of the cool new application development projects that I have been talking about.
Packaging Fun
Stop Whining
I don't often get on my soapbox, but I feel it's time for this. Stop whining! This refers specifically to application development, but I guess it can be applied to most everything. The point I am talking about is application frameworks.
I am using JavaFX, which is relatively new. The problem it is trying to solve is to remove the cruft from desktop application development (Swing), add 2d animations, and be able to run on a variety of devices and platforms. For me the holy grail of Java development would be to create an application that runs on mobile, desktop, and browser, all using the same code! JavaFX does this nicely. Some application development people won't even look at it because features like menus are not there yet. Are there some things missing? Yes, but there is a difference between “where's function X?” and “Epic fail! I can't do anything because function X is missing!”.
All languages, especially new ones have holes in them. You must learn to work around things, that's why I call myself a hacker. Would I want to have something work out of the box? Of course I would, but I also understand that knowledge comes with getting your hands dirty. Just because I can't drag and drop a control doesn't mean it doesn't work. I think the rule of thumb for me is, if the work takes more code than the application I am working on, then's it's broken. I think the whining is more apparent in the younger guys, because of the great things we can do in our IDEs. Not to sound like a greybeard (but I will anyway) is that I started coding Java in NOTEPAD! The same is true with HTML and XML. I love that code completion and other useful features have become standard now, but I bring this point up for a reason. I know how to fix it when breaks, because I know how it's put together.
Sure code is tough, but if you think writing an application is tough, you should see what it takes to write an API. The application development “magic” doesn't write itself. If something doesn't work right, investigate it, instead of complaining. You may have the key fix to make it great. I know you will learn something during your research. You can't drag that control, so you will wait until it's so easy, even a caveman can do it. If you do, you may be replaced by a cheaper caveman.
JavaFX + JPA = Awesome
Yes, this is another of my continuing series of JavaFX posts. I hope you are enjoying the posts, and hopefully you will take a look at JavaFX, because it's really going to be a great platform. One of the key complaints from some application development folks is “yea it does cool animations, but where's the non-trivial uses?”. True there has been a lot of “toy” applications, some touted as “Enterprise”, but I want to give you a key usage for your business application development.
First off a brief primer on JPA, or Java Persistent API. The technology grew out of the complexity and (loathing) of the EJB 2.0 spec. Hibernate came up with way to use POJOs to persist data. The brains behind JPA were the driving force behind JPA. Now is the time to learn JPA, because it's a big part of the EE 6 spec.
Some notices here first; I am using NetBeans as my IDE. You should be able to use the general theme with Eclipse though. JavaFX can use Java classes in the script. The key part for me was how to integrate them. The easiest thing to is create a new Desktop application project (New Project → Java → Desktop Application). Pick the database application, so the JPA wizard displays. Select your table, and the wizard creates the JPA controller, and all of the Entity classes for you. Run the Build project, and now you have a JAR file. If you don't have NetBeans, or want to do this by hand, create the Controller and Entity classes and put them in a JAR file. Add the JAR file to your JavaFX project path, and your ready to go! The following Code can be put in your script to access:
var db = new YourTableJPAController(); //Creates a new instance of your controller
var list = db.findYouTableEntities(); // find all of the entities of your table. To display all of the values, you can run a for loop like this:
Vbox { for(y in new YourTableJpaController().findWineEntities())
Text { content: y.getField() }
} The code above iterates through the List object created by findYourTableEntites, and puts it in a Vertical Box (Vbox). Each item in the Box is a Text object whose display value is one of your fields from your table.
You can now dynamically populate your fields from a database, but more importantly, you are using JPA to handle all of the heavy lifting. Notice I didn't mention anything JDBC. I let JPA do all of the communicating with the database. This is a layer abstraction that let's be an application development guy, not a DBA or Network Admin (not that there's anything wrong with that). If you are using an application server that handles JPA like Glassfish, then you can make your JavaFX application available on the browser and desktop. Now you can have that awesome looking application that actually does something. You are happy to start doing something cool, and your boss is happy because it does something he wants.
Deploying JavaFX on Glassfish and Facebook
First, sorry for the tardiness of my posts. Between the holidays, coming back from the holidays, a cold, and a secret project (for now), I haven't had time to blog.. until now. My current focus has been a Facebook game application. Well it's still in the alpha phase, but I wanted to get the architecture up and running. There's nothing worse for an application development person than to finish your application, then find out you need to rewrite it (or worse) because of the architecture doesn't support it. Even without Zembly, setting up a Facebook application is pretty easy. Since I had most of the defaults already in, the only thing I need to do is to tell Facebook where my application resides. Since I don't have Zembly anymore, I have to put on my application development and network administrator hats on set up an application server.
My first test was to deploy the application into my local Tomcat. NetBeans does a great job of having the files available to you, but the thing you learn quickly is that there isn't a simple deployment piece. Tomcat needs a WAR file, so I tried to use the JAR command to WAR up the files in the dist folder. No dice. The war file needs a proper web.xml file to work properly. Rather than use workarounds on workarounds, I created a web application project in NetBeans, linked the jar file from my JavaFX project, and copied the JNLP and HTML files to my new project. I now have a WAR to deploy. Tomcat loves this file. I run and... “FILE NOT FOUND?” was heard all throughout Cincinnati. Your JNLP file that was created points to a servlet called internally by NetBeans. Make sure change the following lines:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://your server.com/app path/" href="SBWarsTest_browser.jnlp">
<information>
<title>SBWarsTest</title>
<vendor>STAR BASE </vendor>
<homepage href="http://your server.com/app path/"/>
Once I made the change to localhost, everything was fine. Now I wanted a real application server, so I downloaded and installed Glassfish V.2.1 on one of our servers, changed the JNLP file and we are in business. I tried to hit it from my machine, and no dice. After some extensive research, I found out the the Java 7 EA JRE does not play well with JavaFX. I uninstalled it (which reverted to JRE 1.6.18), and it works. In Facebook, you need to set the canvas callback URL to your host application path. The result is the pretty picture you see at the top of my post.
Riding the Wave
When I went to JavaOne this year, I had some friends who went to the Google I/O conference a few days before. Besides getting a new G2 phone (lucky), they were raving about Google Wave. Google recently released Wave into beta, and I have had a chance to play with it.
For those who do not know, Google Wave is a new type of communication software that allows real time collaboration. I know, it sounds all buzzwordy, but it is real cool. Think of Wave as email, SMS, and a working SharePoint all in one. To start a Wave you select new and a text area displays. Select from your contacts to add people, write some text and press send. Sounds like email right? Well, what if after some correspondence, you need to bring other people into the loop? And those late comers are now asking new questions? I don't know about you, but I get confused trying to read emails with lot's of history, and getting new emails based off of some of that history. Google Wave fixes this because everyone is updating a single thread in real time. If you are added late, there is a play button to show the order of the messages. Since it is in real time, all response are shown when entered. You could follow a meeting while listening to a conference call, and ask questions during the meeting, instead of having a second meeting to discuss the first meeting.
Collaboration is the key aspect of Wave. I am using Wave to let some people in Brazil help me test my JavaFX application. As a Cincinnati based application development person, this already saves me time and money. I added a zip file, and instructions on how to use it. I can get their feedback, and update the zip file. I think all application development people can see how useful this is. I can update my code to my users, and have a history of feedback. This will work well for those “confused” management types who “forgot” their feedback.
Google Wave is also a development platform. You can create your own widgets to run on Google Wave. The widgets provided by Google are a poll widget, collaborative Sudoku, and emoticons. I have used the poll widget, and works nicely. If you have a yes/no/maybe question to ask, it really is useful. I have an idea of using TTS to create “talking” Waves.
The one thing I would like to point out is that you will be able to run the Google Wave engine on your boxes. That means you can have a “private” Wave and a “public” Wave. You can set access restrictions on Wave, so you can have control of who uses Wave. Now that it is in beta, look for an invite and get riding!
Fun with JavaFX
I have recently discussed my application development with JavaFX. After using it for a while, I am generally impressed. I come from a Swing background, so desktop application development is not difficult. The concepts that you will most use are sequences, binding, and triggers. Sequences are arrays of objects, but JavaFX makes it easier to use. You can use an index of course, but the insert and delete keywords give more control. You can simply add to the end of the sequence, or insert or delete before or after any item in the sequence. The hardest thing to deal with is that there are no multi-level arrays in JavaFX.
Bind and triggers are an interesting way to dynamically update values on the screen. They seemed awkward to me first, but once you get the hang of it, they work well. You can use the bind keyword assign a variable or attribute a dynamic value. There are times though that the runtime won't update. Instead of Listeners, JavaFX uses the on replace keyword to change the value in runtime. Anything inside the brackets will fire when the value changes. Just update the bound variable in the on replace, and the runtime will update. It seems like you are creating the same value twice, but it is a better way to control runtime events, without a bunch of unused Listeners taking up space.
For most application development people, it is the ability to customize and extend controls that makes a language useful. One thing that I have been doing is creating custom groups. Each control, (Text, buttons, progress Bar, etc) are actually a node on a scene. You can use the Group container to combine the controls into a single class. The Group control is more than a container because application development people can add special attributes that affect the group. I have created a group of polygons that act as buttons. I can't use the ButtonGroup control, so I change the selected button and hover color inside the class by using attributes. The cool thing though, is that I don't create the mouse events in the class, but when I create the group. The mouse events interact with variable on my main class, so there isn't any coupling of my custom class to my main class. That means I can use my polygon buttons in any project I wish.
The are many different effects that you can apply to the controls, too many in fact. As most application development folk don't have a solid background in graphics, a solid guide on gradients, reflection, glowing and other effects, and animation would be great. I just don't know how to control some effects, and I am still learning how to blend effects to make things look cool. That tutorial or book would be my new best friend.