Archive

Archive for the ‘Development’ Category

Devoxx UK: Test-Driven Development with Java EE 7, Arquillian and Embedded Containers

March 27th, 2013 Comments off

Thank you all for attending my Devoxx UK 2013 presentation earlier today: Test-Driven Development with Java EE 7, Arquillian and Embedded Containers. It was a total honour to be at the first United Kingdom franchise. I am very proud to have served the community.

Here is the Slidedeck for the talk:

And you can find the entire codebase of the demonstrations exported to Github as promised: https://github.com/peterpilgrim/devoxxuk2013-tdd-javaee7.

As I said before during the presentation, actually, I am writing a JavaEE 7 Developer User Guide book for Packt Publishing. Please look out for it as it will hit the shelves in late Summer / early Autumn of 2013. Finally, don’t be afraid to get in touch to ask any question on my talk and presentation, JavaEE 7 and development testing.

See you all at ACCU 2013 in Bristol, next month or perhaps further ahead to JavaOne 2013, San Francisco.

+PP+

 

Untitled

PS: A pleasure shout out to Aslak Knutsen and David Blevins from Red Hat JBoss team for their hints and tips on this talk.

Some Captured Tweets:

Markus Eisele ‏@myfear 2h
#devoxxuk @peter_pilgrim about #Arquillian and #JavaEE7 pic.twitter.com/CSv2rb5LTr

Holly Cummins ‏@holly_cummins 3h
‘The cloud is perhaps the heaviest container there is.’ @peter_pilgrim #DevoxxUK

Aslak Knutsen ‏@aslakknutsen 3h
http://yfrog.com/od34253901j Mocks are the old way of testing EE, it’s time to move on. @peter_pilgrim #Arquillian #DevoxxUK

Steven Van Impe ‏@sipofjava 3h
Attending “Test Driven Development with Java EE 7, …” by Peter Pilgrim (@peter_pilgrim) at #Devoxx.

Dan Allen and Aslak Knutsen retweeted you
20h: 13:30PM Weds, Test Driven Development with JavaEE 7, Arquillian & Embedded Containers http://www.devoxx.com/display/UK13/Test+Driven+Development+with+Java+EE+7%2C+Arquillian+and+Enterprise+Containers … #DevoxxUK “Let’s go UK!

Dan Allen and Aslak Knutsen retweeted you
20h: 13:30PM Weds, Test Driven Development with JavaEE 7, Arquillian & Embedded Containers http://www.devoxx.com/display/UK13/Test+Driven+Development+with+Java+EE+7%2C+Arquillian+and+Enterprise+Containers … #DevoxxUK “Let’s go UK!”

adoptajsr retweeted you
20h: Thanks to @aslakknutsen and @dblevins for a very insightful #JavaEE7 discussion around the hack tables #DevoxxUK

 

Can’t Change; Won’t Change

January 31st, 2013 1 comment

I have called this piece: Can’t Change, Won’t Change. It is about what I found in recent years working in the financial services industry, in particular inside investment banking. I witnessed Agile adoption inside these organisations. Sad to say, it did not happen. Instead, lip service was paid to say SCRUM, for example. A lot of banks talked the game of Agile with a big “A”, but in truth their efforts was in a very small “a”. Daily stand-up meetings were actually, in fact, sit-downs. They did not less than 15 minutes, typically, but were regularly overtaken by database integration and production issues, project management tasks, and ran for almost an hour, whilst the whole team was wasted by business as usual matters, which most of the team did require the whole team to be present. Agile adoption was a complete waste of time, because banks did not have time for user story boards, nor did their employees or contractor really want to stick paper and/or cardboard tickets onto any type of board. The heart was not in it to begin with. There was a lack of space for even for user story boards. It was impossible to stick papers to glass windows and the modern building architecture. Their game was just to rely heavily on JIRA or TRAC, there was a distinct lack of motivation, opportunity or innovation to extend the electronic task board beyond the machine. In the end, they  continued to fail in any way to get close to a self-organising team. Even if there was buy-in from the senior management, sometime leading by authority could have helped, but there was somebody in the lower management that torpedoed any attempts for better agile adoption. In the end, there was no chance to practise agile software development with a big “A”; and if you wanted to try your hand at pair-programming and pragmatic test driven-development then the answer was a resounding not a hope of a chance, ever. Therefore continual improvement was at stand-still.

I have found out now that if you really want to learn how Agile with a big “A” is done, then step away and outside of an investment banking environment as I have done this year. My advice is to find organisations that do practice what they preach and not dream, where there is true transparency and integrity. In the past few years, it has become more important that developers and designers have some experience of Agile techniques and not just lip service. It is sad, but true. I can change and definitely I want change.

Agile Software Developer Terminology for New Programmers

December 21st, 2012 2 comments

This is a post for new developers, young, inexperienced or old and retraining into information technology.

Recently, I had a discussion with many engineers at one of those many London user group nights about how there is so much new stuff that we have to explain to people new to programming. One person had to coach a graduate developer on writing unit tests. Another person had to explain the reasons why dependency injection is better than dependency lookup.  I can recall similarly stuff, being able to gently and concise explain why we should have unit tests in the code, and why we need them.

Here is my current matrix of terms:

Term Description
YAGNI You Are Not Going To Need It – The issue hare is that far more code is written than necessary to solve or deliver application functionality. 

Classic symptom: Added unused finder methods to session beans in Java EE

DRY Don’t Repeat Yourself – writing code that has lot of duplication across methods, classes, packages and package object. 

Classic symptoms: Copy & Paste coding in unit tests and repeated metadata in entity and the front end

KISS Keep It Simple Silly [or Stupid] – a mantra to describe writing only code to solve the function problem instead of writing a less complicated codeAlso see Occam’s Razor.

 

Classic symptom: Too many abstract layers in a software application

WET Write Every Time – the antithesis to DRY, where code is deliberately written that repeats lots and lots of time in different classes, packages, and functions. 

Symptoms: Deciding to do things your way and instead of collaborating with the other developers and finding some common ground.Classic antidote: DRY, Unit Tests and Code Refactoring.

WETTT Write Everything Ten Thousand Times – the hyperbole colloquial version of WET
R3 Rules of Three – This is not the proprietary operating system of the same name, or the classic 1980′s arcade game, or either the description of a maxed out pimp-my-ride Volkswagen Golf; but the idea that when ever you have three duplicated parts of code in a method, function or classes then it is time to refactor the duplication in to single method. See Rule of Three computer programming. 

Related to DRY and WET

 

Class Symptom: Ignoring the code repeats because of time pressures, or the Scrum master says no, don’t do it in this sprint.

DBC Design By Contract – the idea of building a service from a contract first. In Java you write the interface as simply as possible and then secondly worry about the implementation class.

 

Interfaces are easier to refactor around and because you can plug different implementations into the interface you get higher cohesion and lower coupling.

 

Classic Example: JDBC specification since version 1.0. There are tons of implementations for different relational databases including MySQL, Postgres, H2, Derby etc.  Every Java programmer knows how to code against JDBC because that they don’t have to fight with an different implementation, which vary, because the DBC implied it will do the right thing most of the time.

 

Also related to standardisation of application programming interfaces.

BDUF or BUDF Big Up-Front Design – a problem with many large corporate institutions that sometimes require a 100 – 1000 page document full of business requirement before any software construction gets the green lightSome poor architect or business analyst will have spent weeks investigating and chatting to the business about the requirement, only for the development team to say the document is practically worthless.

 

Antidote: Get the technical lead and some key developers talking with the business and the analysts and the customer. Ideation sessions everybody!Symptom: Waterfall methodology and aspects of the investment banking IT culture

 

Antidote: Unknown, lots of people how tried to bring “Agile” with both a big A and small A to many of these institutions with some success and failure

Pink Book Describes the book with a Pink Cover called Extreme Programming Installed by Ron Jeffries, Ann Andersen, and Chet Hendrickson. I do not recommend this for new starters unless for reference, since the Pink Book is now rather old, 2000, there are other more recent Agile development books and courses that help new Java developers.
YOLO You Only Load It Once [If Ever] – this is related to fact that you want to have a single source of truth in an application system. This is problem of mis-architecture, where someone has not thought the functional requirement through enough.

 

Classic Example: Shopping Cart Service EJB – you only ever want one implementation of the pay-point in an application, albeit you will have many pay-point providers (credit and debit card third parties and PayPal)

 

The If-Ever part is YOLO and YAGNI added together. You are not sure of the another part of the system loads the data, so you decide to keep the component. (You probably want to put a logging client on the YOLOIF thing so that you can effectively decide to chuck the component if nobody has used the function in 12 or 18 months time.)

 

Digression: If you have find data that is constantly being uploaded to serve a web request then perhaps it really needs caching and not YOLO.

Spike A quick exploration of coding in Sprint in SCRUM methodology, which is also time-boxed inside a single sprint, usually. In a Spike you are probably are looking an new API, like a cloud service or user interface API like JavaFX or similar and basically you explore if the function can implemented relatively well in the new API.In short, you are trying to build some confidence in a new area before committing yourself and other resources to it. Spikes are usually contained and protected from the flow of the critical path and restricted to a time length. See SMART goals. Once your team has gained confidence and knowledge in the new “thing” then reasonable estimates can be made.

 

Classic Examples: Adopting a build system – moving from Apache Ant to Maven; moving from Subversion to Git; Adopting a new open source library

TDD Test Driven Development – often conflicted as not being fully explained as a change of discipline and mind.”You are only ever doing one of these four things: writing unit tests, writing production code, refactoring unit tests, and refactoring production code; and never doing more than one at these previous at the same time.”
TFD Test First Development – builds on the ideas of TDD and then extends the discipline to writing unit test code before any production code.”Once you have a brand new unit test written completely, then you make sure that new unit test(s) actually fail in order to switch over to writing production code ensures the the new test passes.  After you have done that, you refactor the tests. Run all tests for all the green bars. Refactor the production code and runs the tests for all the green bar.Repeat: Go back to the start; write a new unit to that will check validate operation of the next function for the application. Repeat with the same formula as above.”

 

Velocity This is often misunderstood as a very basic measurement on the Return-on-Investment for SCRUM/XP software development and it has nothing at all to do with financial services, budgets and/or reporting. The creators of SCRUM/XP now disuade velocity as a ROI indicator at all.

 

Velocity is the number of story points completed per team per iteration. To the SCRUM/XP  experienced: Velocity is equal to the aggregated units of work completed over aggregated time intervals, which implies you measure each progress of tasks in two or more sprints.

Story Point For each user story in the sprint or task, predict  how hard it is to implement by using unit of reference. 

Story points are usually written in Fibonacci numbers: 0, 1, 1, 3, 5, 8, 13, 21, 34, 55, 89, 144Every agile team in the world has a definition of a user story unit point.Teams decide on the backlog items in order to come up with predictions and these joint predictions every member of team go to decide what should applied to the next sprint.

DTSTTCPW Do The Simplest Thing That Could Possibly Work – Related to Spike and KISS in many ways. If you are pressed for time and some trading systems developers in investment bank are then this is your working life. 

DTSTTCPW certainly invites team collaboration and effective sound-boarding from other developers and members of the team, otherwise you are asking for trouble.

VoC Voice of the Customer – This is a term from SCRUM methodology, but I am about 20% unsure about this one; I believe 80% of the time to mean a proxy, a placeholder, for the real customer, the person who understands the business requirement and will of the customer. Because the true user is unavailable for some reason due to authority, culture or organisation, or even geo-location. 

Some people have amusing called this abbreviation, the Voice of Reason, especially when they do not enjoy working with the customer directly.

Unit Test In Java programming, a Unit Test is a Java JUnit framework test class or TestNG framework test class that specifically verified and validates a single function of work in an application 

A unit test requires a target, which can be a Java Class, a Service Bean, Managed Bean or something implements the said functionality.

 

Unit test are often seen as low-level fast and efficient tests.

Functional Test A functional test is a larger test, which can also be a unit test, designed to test packages of classes or sub part of the overall application infrastructure. Functional test validates if the application meets one of the customer’s external requirements on performance, results and efficiency.

 

Symptom: a functional test is not necessarily a unit test, and not all functional tests are acceptance tests.

Acceptance Test An acceptance test is the same as a functional test in name only. Acceptance tests are those where the customer wants to see the validation pass in order they sign of the implementation. 

Symptom: If the customer is disastisfied with the application at demonstration time, then at least the one of the acceptance test is broken. Add one in the next sprint.

SOLID A set of five principles:Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation and Dependency Inversion.
Single Responsibility Principle An object class, a service bean, web service, a function or procedure should have only one single responsibilitySymptom: It is hard to write unit test for complex object, because it doing WETTT
Open Closed Principle Open for extension and closed for modificationIt means you can subclass the object, but the object is encapsulated by not allowing an outside object to gainfully change the internals. 

Symptom: leakage in object implementation, hard code dependency, and not working with Java interfaces (or interface like constructs i.e. Scala traits and mix-ins)

Liskov Substitution Principle Idea of swap-ability and is expressed as a Design By Contract (DBC).I can swap in another object X which is an implementation of T if that objects is a type of T and the overall application works.This is the basis of mocking objects, mocking implementation frameworks; testing in general; proxy remote objects, persistence capable objects; application server and lifecycle monitoring situations; plug-and-play and restartable applications. I could go on, but I won’t.
Interface Segregation Principle A service interface that does only single specific functional thing is better than a service interface that does several different things. 

Symptom: Failure to adhere to the KISS principle. In days gone, the non standard C++ String libraries where everybody threw in the kitchen sink of methods for any operation that one would want to write that manipulated a C/C++ String (char*)

Dependency Inversion Principle Idea of not hard-wiring a direct relationship to a dependent into object.In Java EE world, you would use a dependency injection container such as CDI to inject different managed beans into a service bean. 

Dependency inversion also should mean in my humble opinion given up on managing the life-cycle of service components and beans. The lifecycle is managed by the application container, the cloud provider or whatever it is you are using.

 

In another school of thought: every application is managed these days, whether it is the operating system, a virtual machine or web container or mobile platform (iOS and Android). This is the way forward.

Design Patterns A classic book on Design Patterns by Erich Gamma et Al. 

Ask your local technical leader to lend you his or her copy of the book; and if they don’t have a copy then that really sucks. Tell them to give you a personal training budget and buy the book yourself!

Glad to be of service to all my readers.

Merry Xmas and Happy New Year 2013!

+PP+

PS: I, once, had a notebook and file with a lot more of these terms with or without explanations. If I find anymore abbreviations and terms that I will add to this blog entry.

NightHacking Tour with Stephen Chin

November 20th, 2012 Comments off

On Monday 19th November 2012, in the evening, I interviewed for the final episode of the Nighthacking tour by Stephen Chin, who is an Oracle Evangelist for Java, Chairperson of the JavaOne Program committee, and also a Java Champion a.k.a @steveonjava.

We talked about ScalaFX the open source Domain Specific Language and Scala library framework for JavaFX 2.x. I showed off my version of the JavaOne 2011 demo in Scala. It is called VideoCubeDemo.scala. We actually started to fix a bug in the demo. We checked into version control a quick fix that helped and pushed that to Mercurial.

I also talked about my upcoming reference book for JavaEE 7, which will be published by Packt. I demonstrated some of the example Context Dependency & Injection code that will feature in the book. I showed off JBoss WeldDeltaSpike and Arquillian framework. We discussed some of the other upcoming features of Java EE7 like JAX RS and WebSockets; and also how CDI could be used outside the container in a JavaFX application.

Many thanks to SkillsMatter for hosting us, in particular Wendy Devolder and Nick Devolder; and extra special medal goes to Ami Partridge for being very helpful, staying late into the evening to help us get this live stream out to the public with wired ethernet cables, router boxes, WI-FI and tea.



Video streaming by Ustream

Hosted by Skills Matter, the company behind the Scala Exchange and Grails Exchange.


SkillsMatter 2012

 

+PP+

Building OpenJFX 2.2 Again

October 31st, 2012 Comments off

Here is how I build the OpenJFX 2.2 on both Mac OS X, because the semi-official Getting Started instructions on the OpenJFX site are a bit of out-of-date.

Find a folder for your project, create a folder:-

mkdir -p ~/open-jfx-2.2

cd ~/open-jfx-2.2

Using Mercurial, clone the project folder from the Master change-set:

hg clone http://hg.openjdk.java.net/openjfx/2.2/master

cd master

Copy the existing JavaFX runtime JAR into a special folder. I am using JavaFX bundled in Oracle Java SE 7 update 9. We create the folder structure and copy the JAR into it.

mkdir -p artifacts/sdk/rt/lib

cp ${JAVA_HOME}/jre/lib/jfxrt.jar artifacts/sdk/rt/lib

ls -l artifacts/sdk/rt/lib
[/code]

Now clone the RT sub tree using the Mercurial

hg clone http://hg.openjdk.java.net/openjfx/2.2/master/rt

cd rt

Edit the properties file common.properties, and modify the debuggable property near the top of the file (e.g. linenumber 15 or so)

# COMMENTED OUT: javac.debuglevel=${jfx.javac.debuglevel}
#javac.debuglevel=none
javac.debuglevel=lines,vars,source

Now we can clean the distribution:-

ant clean

Afterwards, we should be able to compile and build JAR for the existing distribution.

ant dist

Look inside the dist folder for the results

peterpilgrim@Peters-MBPRD.local [686] > ls -l dist
total 6888
-rw-r--r--  1 peterpilgrim  staff  3523332 30 Oct 11:54 openjfxrt.jar
peterpilgrim@Peters-MBPRD.local [687] > 

+PP+

Categories: Apple, Development, JavaFX Tags:

Silicon Valley Code Camp 2012

October 16th, 2012 Comments off

After the exertions of JavaOne 2012, I was very glad of the relative warmth, wide-range green, autumn plucky country-side feel of Los Altos Hill. On Saturday, 6th October and partially Sunday 7th I was down at Foot Hill College for another dose of the Silicon Valley Code Camp.

For people in Silicon Valley, a weekend after JavaOne, and for a free event, this is training and education that is most affordable. The companies sponsoring SVCC including Microsoft, Box, Dice.com and others make it all possible.

 

DSCF4158
This is Peter Kellner being the Master of Cerenomies and reading the raffle-ticket winners

 

DSCF4152
This photos was taken during the speaker’s dinner late Saturday evening. Van Riper [R] and Kevin Nilson [L] organisers of the Valley Java User Group

 

DSCF4161
Wider focus view to the Foot Hills Campus, which is very well equipped for IT education, I thought.

 

 

DSCF4162 Another stunning view and memory of SVCC. What you cannot see is that the whole college on undergoing reconstruction, there are building works, trucks, pile heaps all around the campus as it is revamped.

 

DSCF4151
Saturday lunchtime. For October, it was rather warm during the day, the atmosphere definitely collegiate, relax and friendly. It was rather cold during the evening, bring a jacket and layers after 6pm!

 

DSCF4176
One lucky raffle-ticket proudly takes and loft over his head the XBox Console that he just won at the SVCC 2012! Am I regretful that I stopped running the JAVAWUG? In those moment like that one was, the easy answer is yes, because to see the joy of accomplishing something just by attending is priceless. However, an SVCC event is unlikely come to the UK any time soon, because we Brits need to adopt that Californian attitude of “What’s the worse thing that could possibly happen?”

 

I was very happy with the turnout for my talk on Saturday: Leveraging Java EE7 and the Cloud with the JavaFX, Room 4305. In the end, I talked for 35 minutes, and the rest was demonstrating JavaFX 2 to the attendees. A smaller audience than JavaOne, but nevertheless they appear attentive and appreciative.

The follow day, I bumped, into Dave Nielsen, of CloudCamp fame, whilst he was given an interesting talk about cloud computing. My ideas about PaaS being standardised next year, were way off, I learnt. There is so much disruption and innovating in Cloud, in his opinion, Dave Nielsen, reckons standardisation is more like two years into the future. Dave Nielsen is one of the member organiser of the OASIS CAMP, an effort to standardise cloud services.

 

DSCF4141
Microsoft brought there own XBox black Mustang muscle car, polycarbonate trim and folds, custom modifications were fitted by the infamous West-Coast Customs, yet another “Pimp My Ride” production. This particular car had a digital LCD dashboard, two screens, it was coupled with a Nokia smartphone app with the ability to remote start (disabled), a projector was installed into the boot and also featured two separate XBox console complete with controllers. Of course, the boombox sound was out of this world.

 

DSCF4146
Code Camp #svcc2012

 

IMG_1288
I started reading Joshua D. Sureth’s Scala in Depth book, which was the only book that I bought during JavaOne 2012. I used to buy lots in previous years, too much to read in so little time. Now I restrict myself to one, if any.

 

+PP+

JavaOne 2012 Report 3 Analysis & Conclusions

October 16th, 2012 Comments off

The Conference

This year’s conference, in my opinion, was the best that Oracle have produced in the three years that it has taken over the stewardship of Java. It was great for technical content. The positives were that similar sessions were arranged to be close together in the same hotel, in other words tracks were co-located. This was markedly better than 2010, when I remember rushing from building to building to get some particular session.

( Read the earlier section of the report Part 1 and 2 )

 

IMG_1129
The Bi-Plane from Moscone West

 

Oracle chose to give only 40% of the technical session to its own employees. The result was that we the happy consumer could choose a lot more sessions, however sometimes quantity is rather not quite a good as quality. I share Adam Bien‘s observation that perhaps this was tad too restrictive and Oracle were a bit hard on themselves. The quality of the engineers, designers and architects on Oracle side is really good and usually the Oracle teams have internal know-how for the rest of us, which we need to know, as they are working on critical future projects to do with any of the Java edition, SE, EE and ME. I would also want this percentage to 50% Oracle and 50% external speakers. Compare this percentage against the other tech conferences such Apple’s WWDC and Google’s I/O, which have good company speakers. I should throw in there were no marketing talks that I can bear witness to, which is fantastic.

I can only speak of the JavaFX, Rich Media track in conference, as a program reviewer, the technical content was great. I suspect that for the other tracks, Core Java, Java EE and Cool Stuff and other tracks, the reviewers in those areas, were equally transparent, ethical about what they thought and chose as a decent material for JavaOne. In my opinion, this a conference for the people and by the people, and they deserve to have the investment in flights [expensive], hotels [really expensive] and energy and time [priceless] returned in the greater measure of satisfaction. The sum of outputs has to greater than the sum of inputs for JavaOne to really work.

In terms of the people who did turn up to JavaOne, I felt that this was landmark year, were not only I, but other Java Champions (Frank Greco, New York Java User Group), noticed that there were lot of young Java developers out and around. When I say young, I also qualify it that to not only youthful, but also including new inexperienced oldies too. This is good thing for the increasing talent in the global community of Java engineering. We will always need good engineers, who are enthusiastic about learning the Java platform. The influx of the new was so peculiar that many failed to notice and recognise the Father of Java, walking around the Hilton San Francisco, on Wednesday 3rd October.

Community Keynote

In fact, I thought I had seen James Gosling too, from about 75 yards away, in profile only, just momentarily, and I dismissed it as  a figment of my imagination. I was pleasantly surprised and amazed when James Gosling came up on stage on the Thursday community key note. We should have all guessed, because his face was featured on the September 2012, digital edition of  the Java Magazine. James Gosling came up to the stage and talked about the Liquid Robotics software, waves, low-level level volume, guaranteed 100% data storage on Glassfish servers, and cloud services he had developed over the last year or so. James Gosling said that he reviewed many cloud computing offerings for a possible PaaS solution, and in the end, explained why  he chose JElastic. He chose this PaaS solution, because it supports GlassFish, virtualisation, scaling up-and down and clustering on demand.

Bruno Souza immediately stepped in to help with the tee-shirt throwing. He gave James Gosling the tee-shirts that he had collected to take back to folk in Brazil. We should make tee-shirt throwing a proper feature of the next JavaOne, especially if James Gosling is back.

Stephen Chin became the new Program Chairperson for JavaOne 2013 and Beyond. I believe that I already mentioned how amazing this was. JavaOne now has a really fantastic community-aware person. I have every confidence that the level of the technical sessions will remain at the high standard, and I can even see that those sessions will improve.

Martijn Verburg also did a very good job explaining the Adopt-a-JSR project at the keynote. It seems like a laudable approach to get Java engineers outside of Oracle and in the wider community to help implement some of the standards.

Call For Improvements

Where there any sore points? Yes there were some that I observed.

As an oldie, I can remember the great JavaOne conferences of 2005 and 2007 at the Moscone Center. In particular, the mega humongous party to celebrate Java’s tenth birthday in 2005, which was my second time at JavaOne ever. We only need to get JavaOne back to Moscone Center or the West, which probably is not going to happen.

On the JavaOne home page, the most important tools, Schedule Builder and Content Catalogue were located in the Fat Footer. These tools needs to the above-the-fold. Please explain these web design principals to the principal web site designer. The content catalogue should also show the speakers, the full name. Many talks are attractive because of the speaker who is delivering them, for example Mark Reinhold for Jigsaw, Brian Goetz for Lamda in JDK 8 and Martin Odersky for upcoming Scala 2.10 features.

The speaker room is tiny, in the Hilton San Francisco, consequently I spent very little time in it, except to grab coffee to get the endorphins charged up. Were there speaker preparation rooms available in the other hotels, Parc 55 and Nikko? I did not check when I was there. This would be important if the track you are presenting, e.g Mobile or Java ME was co-located in the other hotels. Also I thought they could have  supplied some more edibles, sandwiches or more snacks.

Oracle were really lucky with the weather this year, because the open area, Buzz Cafe, sponsored by IBM was a pleasant space for the odd tipple of beer, roasted coffee and to get some air. What if it had rained?

The Duke’s awards, this year, were held in the Buzz Cafe and open area. It should have been part of an official keynote. The winners deserved the entire group of attendees to be there, to bear witness, in order to respectfully receive such prestigious and rare awards. In fact, we could have one additional keynote session, may be Oracle can claim some of that 10% time back that they gave up. We need to dedicate a morning or afternoon keynote to this achievement ceremony, especially, now we have such a glut of young developers attending JavaOne for the first time.

Some technical sessions were poorly attended I thought. I am quite sure on Wednesday in one of the Imperial Ballrooms A or B, and not in my session, there were only 6 to 10 people watching a speaker talk. We have to do a little better in talk selection, and attracting some good speakers to JavaOne. I think that the cost of JavaOne may be the main prohibitor. I would like to see a much longer lead-time for this, say by a couple of months, so that speakers can take advantage of the earliest flights and hotel deals possible. I would also like to hear from the developer community and what you think are good ideas for JavaOne 2013, so that if I am involved as one of the program reviewers again for JavaFX, Rich media tracks, that I am serving the best interests.

 

DSCF4026
The Mongo DB stand at JavaOne 2012

 

Future of the Java

The future of Java is basically in your own hands. From my perspective, it is good see that Java is growing and there is still interest in advancing the entire platform forward. The key brands to look out for me are JavaFX 8, Java EE 7 and of course the growing adoption of Scala in the workplace.

Oracle produced some figures, graphs and statistics showing that businesses are adopting Java SE 7 since it was released earlier last year [28 July 2011], people have switched over, and that Java SE 6 is on the wane. Henrik Stahl,  senior director of product management at Oracle, posted a blog entry mention the statistics from Jelastic, quoted adoption was 79%, which matches their internal indicators. This can be positive for the possible adoption of Java SE 8, which will have lambda functions and more functional programming concepts. It is taking a long time to change, but I believe we are getting there with the Mother Language, as the other alternative JVM languages remain attractive for those businesses and developer willing to get more productivity and not be left behind hind with legacy application and infrastructure. I want to personally see job advertisements changing from “Scala, JRuby, or Groovy are high desirable” into “Scala, JRuby, or Groovy are desired”.

A clear break for user interface development on client Java is called for, concerning JavaFX and new media APIs. There are many people who depend on Swing, SWT, Adobe Flash / Flex and even Microsoft SilverLight for their UI. I will leave out the businesses that have already decided that Web platform and HTML5 are only UI for their products. JavaFX represents a sea change for Flash and SilverLight, it means that once again, you can build the entire application, client and server side, from metal to UX nuts using Java, if you so want to architect that way. This is fantastic if you are starting in mythical world of greenfield, development which every recruiter will try to sell to you that their client is offering, and we know in reality is that it never is, quite, the case. The bath water is the Swing framework from 1998, because the API was built with immediate graphics and rendering, and the babies are the application built squarely on Swing that the business is using now. It is going to be frightfully hard to do, cruel even, some poor architect will have to come to the conclusion, JavaFX and some sort scene-graph is the new path. There is no such thing as dirty job done cheap, but hey somebody has to inform the business that the UI code and application is in serious danger of becoming out dated. A transition from the old UI world to new is called for. Those young developers from JavaOne walking the floor, enjoying the demonstrations, FX and taking it all in, the 3D and rich media, including my very own video fracture demo that I repeated again, I really envy the sort of exciting applications that those fertile uncontaminated imaginations are going to create in the next few years or so.

The new idea is no longer the Java Applet that runs inside a web browser. The Java Plugin is history and Java Web Start is error prone and broken. Instead of deploying an application with an Applet or Plugin, you will be deploying your business application, the UX part of it, in the future to an application store. The application store may be a commercial one or might be a private implementation solely for the use of your employees and staff inside the big corporation. Getting JavaFX and Java to work in the forthcoming Microsoft Application Store must be a given, because it represents a clear competitive advantage to Microsoft in its battle with Google and Apple, when Java applications can be distributed by Windows Store. Modularisation of Java is going to be crucial as are Mark Rheinhold’s architectural idea about offering a series SE profiles, of ever increasing usefulness and package, until Jigsaw and Java 9 is here.

Will these young developers be willing to apply for Swing application developer job writing Java SE 6 in 2015 for some investment bank in the city, the financial district, the extreme majority, quite absolutely not? I could be even more crueler, but I think I will stop now and put the chalk down.

 

DSCF4040
Ben Evans [holding the mic] is talking about Adopt-a-JSR program

 

Shout Outs

In no particular order, whatsoever:

  • Mark Stephens, IDR Solutions
  • Betrand Goetzman, Consultant et Développer Web 2.0
  • Valérie Hillaware, iText PDF
  • Hans Docktor, CEO, Gradleware
  • Peter Walker, COO, Gradleware
  • Sidney Allen, StackMob
  • Peter Van de Voorder, RealDolmen
  • Dr. Olaf Grebner, Unternehmer
  • Gerritt Grunwald, Canoo
  • Ix-chel Ruiz and Andres Almiray, Canoo
  • Arvinder Brah, Navis
  • Dierk Koenig, Canoo
  • Wolfgang Wiegend, Oracle, Sales Consultant Fusion Middleware
  • Branko Mihaljevic, Hujak, Croatian Java User Association
  • Matija Tomaskovic, Evolva, Croatia
  • Fried Saacke, President of the Germany Association of Java User Groups
  • Frank Greco, New York User Group, USA
  • Cecilia Borg, Senior Manager, Engineering, Oracle
  • Arun Gupta, Glassfish, Oracle
  • Simon Ritter, Java Evangelist, Oracle
  • Jim Weaver, JavaFX Evangelist, Oracle
  • Yara Senger, SouJava, Brazil
  • Bruno Souza, SouJava, Brazik
  • Todd Castello, countless JavaPosse Round-Ups
  • Mark Heckler, Oracle
  • Sharat Chandler, Principal Productor Director and ex-JavaOne Program Chairperson, Oracle
  • Stephen Chin, new JavaOne Program Chairperson, Oracle
  • Ed Burns, Specification Lead for JSF, Java EE 7, Oracle
  • James Ward, Heroku
  • Jonathan Giles, JavaFX SDK team,Oracle
  • Michael Heinrichs, JavaFX SDK team, Oracle
  • John Yeary, Greenville JUG
  • Victor Klang, Typesafe
  • Fred Simon, Artifactory, JFrog
  • Shlomi Ben Haim, JFrog
  • Jasper Potts, JavaFX, Oracle
  • Richard Bair, JavaFX, Oracle
  • Carl Dea, Software Engineer, Author
  • Cameron Purdy, VP Product Development, Oracle
  • Nandini Ramani, VP Product Development, Oracle
  • Gail and Paul Anderson, Book Authors
  • Paul Deitel, Book Author
  • Peter van de Voorde, RealDomen
  • George Saab, VP Java Platform Development, Oracle
  • Csaba Toth, my regular JavaFX talk attendee
  • Adam Bien, Java EE book author, rock star and Java EE 6 consultant
  • Brian Goetz, Lambdas in Java 8, Oracle
  • Anton Epple, Netbeans
  • Mark Reinhold,  JDK Architect, Jigsaw in Java 9, Oracle
  • Luc Duponeel, ScalaFX committer, get that code generation in there please
  • Martijn Verburg, Adopt-a-JSR, London Java Community
  • Danno Ferrin, Groovy, OpenJFX Hacker
  • Mike Lehmann, Senior Director, Java EE, Oracle
  • Ryan Cuprak, Enginuity
  • Tori Wieldt, Oracle
  • Mattius Karlson, Swedish JUG, JFokus
  • Stefan Janssen, Devoxx, Belgium JUG
  • Dick Wall, JavaPosse
  • Van Riper, Google
  • Carl Quinn, JavaPosse
  • Kevin Nilson, Java Champion
  • Kirk Pepeerdine, Performance Tuning Expert, Java Champion
  • Heinz Kabutz, Java Language Expert, Java Champion
  • Jevgeni Kabanov, ZeroTunraround
  • Geetjan Wielenga, NetBeans Dream Team
  • Roger Brinkley, Java Spotlight Podcast, Oracle
  • Stephen Colebourne, Java Champion
  • Nichole Scott, Oracle
  • Regina Ten Bruggencate, Java Champion, JDuchess
  • Henrik Stahl, Oracle

Apologies, if I left you out. See you next year, San Francisco, Sunday 22 – Thursday 26, September 2013.

+PP+

 

DSCF4078
Java Client side desktop lunch with Jasper Potts [L], Richard Bair [R] is looking directly at Stephin Chin in the background, sitting to next Richard Bair with his right hand touching his left hand and watch is Sven Reimers

 

 

IMG_1219
This was supposed to be a clear view of Eddie Vedders from the Grunge Band, Pearl Jam, performing at the Oracle Appreciation Event

 

DSCF4082
Jonathan Giles at the Desktop lunch, which he organises with Stephen Chin, every year since 2010.

 

IMG_1176
Mac Book Pro Retina Display keyboard

 

IMG_1262
Of course, this conference fell on anniversary of Steve Job’s death – Someone wrote “SJ, please use TimeMachine and come back!”

 

 

 

+PP+

Silicon Valley Code Camp 2012

October 8th, 2012 Comments off

The Silicon Valley Code Camp is a free event organised Peter Kellner and others every year in October. The SVCC talkes place at Foot Hill College, Los Altos Hills, California. It is now in its seventh edition, which in my opinion extraordinary.

This years unofficial attendance was about 3800 participants, over range of technologies. It is not just a Java conference, the SVCC embraces native programming languages like C++; web development through JavaScript and Dart; the JVM platform with  Java, Scala and Groovy;  Microsoft technologies, Silverlight, C# and DotNet; and non-development sessions such how to find start-up funds, cloud computing and even how to recruit the best team in the valley.

What astounds me is that this is all available free to attendees, the sponsors pay the hosting, hiring and the obviously for food and beverages. This is training and education for free, albeit the speakers are not trained professional educators, but mostly from my witness, they do know what they are talking. To submit a talk here, you just volunteer your services. It is a decision, can I make the time and effort to lecture or speak about a topic that is interesting for attendees? If you can do that, then it is good chance to change the world. After all, it is the learning experience, in my opinion, it is chance I feel to give back something to community that somebody gave in the past to me.

Here are my slides to my talk Leveraging Java EE 7 and the Cloud with JavaFX, which took place on Saturday 6th October at 3pm

The attendance was smaller than JavaOne, but I am not disappointed in that at all, the smaller the audience size, the more intimate it is, the chance to get to know and ask questions about the developers. Why they like Java? What are they hoping to achieve? From these question, I was able to tailor the presentation slightly to be more about JavaFX than JavaEE.

Java EE 7 is now repositioned from Moving to the Cloud to HTML5 Web Sockets and RESTful services. It is draft specification and you can download the latest document from the JCP.org under JSR 342, which probably needs an update.

I met several members of the community including:

  • Van Riper
  • Kevin Nilson
  • Andres Almaray
  • Ixchel Almaray
  • Csaba Toth
  • Chris Richardson
  • Peter Niederwiesen
  • Dave Nielsen

 

+PP+

ScalaFX – Working Configuration for MacOS X Lion, Java 7 Update 5

July 26th, 2012 Comments off

Here is a complete verbatim build.sbt for ScalaFX that works on MacOS X Lion and Java SE 7 Update 5:

// Important - Set the JAVAFX_HOME environment variable to the root of your JavaFX installation for this script to work

// You can also set your scala or java home if necessary like this:
// javaHome := Some(file("/Library/Java/JavaVirtualMachines/1.6.0_24-b07-330.jdk/Contents/Home"))
// scalaHome := Some(file("/Users/Sven/scala-2.9.1/"))
// javaHome := Some(file("/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home"))

javaHome := Some(file(System.getenv("JAVA_HOME")))

name := "ScalaFX"

version := "1.0-SNAPSHOT"

organization := "org.scalafx"

scalaVersion := "2.9.2"

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"

unmanagedSourceDirectories in Compile <++= baseDirectory { base =>
  Seq(
    base / "src",
    base / "demo"
  )
}

// set the Scala test source directory to be <base>/test
scalaSource in Test <<= baseDirectory(_ / "test")

// testListeners <<= target.map(t => Seq(new eu.henkelmann.sbt.JUnitXmlTestsListener(t.getAbsolutePath)))

// append several options to the list of options passed to the Java compiler
javacOptions ++= Seq("-source", "1.5", "-target", "1.5")

// append -deprecation to the options passed to the Scala compiler
scalacOptions += "-deprecation"

// define the statements initially evaluated when entering 'console', 'console-quick', or 'console-project'
initialCommands := """
  import System.{currentTimeMillis => now}
  def time[T](f: => T): T = {
    val start = now
    try { f } finally { println("Elapsed: " + (now - start)/1000.0 + " s") }
  }
"""

// libraryDependencies += "com.oracle" % "javafx-runtime" % "2.1"

// set the main class for the main 'run' task
// change Compile to Test to set it for 'test:run'
mainClass in (Compile, run) := Some("scalafx.ColorfulCircles")

// add <base>/input to the files that '~' triggers on
watchSources <+= baseDirectory map { _ / "input" }

// disable updating dynamic revisions (including -SNAPSHOT versions)
offline := true

// set the prompt (for this build) to include the project id.
shellPrompt in ThisBuild := { state => Project.extract(state).currentRef.project + "> " }

// set the prompt (for the current project) to include the username
shellPrompt := { state => System.getProperty("user.name") + " (SBT) > " }

// disable printing timing information, but still print [success]
showTiming := false

// disable printing a message indicating the success or failure of running a task
showSuccess := false

// change the format used for printing task completion time
timingFormat := {
    import java.text.DateFormat
    DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT)
}

// disable using the Scala version in output paths and artifacts
crossPaths := false

// fork a new JVM for 'run' and 'test:run'
fork := true

// fork a new JVM for 'test:run', but not 'run'
fork in Test := true

// add a JVM option to use when forking a JVM for 'run'
javaOptions ++= Seq (
  "-Xmx512M" ,
  "-Djavafx.verbose"
)

// only use a single thread for building
parallelExecution := false

// Execute tests in the current project serially
//   Tests from other projects may still run concurrently.
parallelExecution in Test := false

// add JavaFX 2.0 to the unmanaged classpath
unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_HOME") + "/jre/lib/jfxrt.jar"))

// publish test jar, sources, and docs
publishArtifact in Test := false

// disable publishing of main docs
publishArtifact in (Compile, packageDoc) := false

// change the classifier for the docs artifact
artifactClassifier in packageDoc := Some("doc")

// Copy all managed dependencies to <build-root>/lib_managed/
//   This is essentially a project-local cache and is different
//   from the lib_managed/ in sbt 0.7.x.  There is only one
//   lib_managed/ in the build root (not per-project).
retrieveManaged := true

/* Specify a file containing credentials for publishing. The format is:
realm=Sonatype Nexus Repository Manager
host=nexus.scala-tools.org
user=admin
password=admin123
*/
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")

// Directly specify credentials for publishing.
credentials += Credentials("Sonatype Nexus Repository Manager", "nexus.scala-tools.org", "admin", "admin123")

publishMavenStyle := true

publishTo := Some(Resolver.file( "file",  new File( Path.userHome + "/.m2/repository" )) )
# End

Java 7 up to Update 5 already includes JavaFX 2.1. Therefore there is no need to explicitly install in the jfxrt.jar inside a Maven directory. However, I am unsure how to link ScalaFX with JavaFX 2.2 beta and 3.0 code from the OpenJfx repositories; and how the platform toolkit with those codebases for Mac OS X explicitly loads native libraries at initialisation.

On a new Mac OS machine, especially Lion, you will definitely want to re-enable Java to run inside web browsers. You might also want to prefer to use as a default the Java SE 7 from Oracle instead of the Apple JDK 6 release. Fire up the Java Preferences App. Open a terminal and execute the following command at the Bash shell prompt.

> ls -lF /Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences 
-rwxr-xr-x  1 root  wheel  39072 18 Jul 02:55 /Applications/Utilities/Java Preferences.app/Contents/MacOS/Java Preferences*
> /Applications/Utilities/Java\ Preferences.app/Contents/MacOS/Java\ Preferences  

Re-enable JRE to run inside all of your installed web browsers: Firefox, Chrome and Safari. Select Java 7 Runtime Environment with the mouse, drag it to the top of the list. Check that Java 7 is now the default.

> /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

You can add this call to your ~/.bash_profile script, so your Java environment is automated every time you fire up a terminal command.

export JAVA_HOME=`/usr/libexec/java_home`

export PATH=${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:[whatever your path was before>]

Finally, the java_home program can dump a list of your installed JREs.

macosx [248] > /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.7.0_05, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
    1.6.0_33-b03-424, x86_64:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_33-b03-424, i386:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
macosx [249] > /usr/libexec/java_home -X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<dict>
		<key>JVMArch</key>
		<string>x86_64</string>
		<key>JVMBlacklisted</key>
		<false/>
		<key>JVMBundleID</key>
		<string>com.oracle.java.7u05.jdk</string>
		<key>JVMEnabled</key>
		<true/>
		<key>JVMHomePath</key>
		<string>/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home</string>
		<key>JVMIsBuiltIn</key>
		<false/>
		<key>JVMName</key>
		<string>Java SE 7</string>
		<key>JVMPlatformVersion</key>
		<string>1.7</string>
		<key>JVMVendor</key>
		<string>Oracle Corporation</string>
		<key>JVMVersion</key>
		<string>1.7.0_05</string>
	</dict>
	<dict>
		<key>JVMArch</key>
		<string>x86_64</string>
		<key>JVMBlacklist
        ...
</plist> 

+PP+

Custom Ordering Scala TreeMap

July 12th, 2012 1 comment

How do you get custom ordering in a Scala TreeMap?

Well this puzzled me for a while. The answer lies in the world of implicits and receiver type converters.

In a nut shell, a scala.collection.immutable.TreeMap is a SortedMap. If you look at the documentation for TreeMap, you will see it takes an Ordering[T] as an implicit argument.

Normally when you declare a TreeMap, say inline, it will use the default Ordering object like so:-

scala> val dtm = TreeMap( "a" -> 1, "bc" -> 2, "def" -> 3 )
dtm: scala.collection.immutable.TreeMap1 = Map(a -> 1, bc -> 2, def -> 3)

If you want to change the ordering of the keys, for example, instead of the ascending order by String content, into, say, a descending order of strings length then you need an Ordering type.

scala> object VarNameOrdering extends Ordering[String] {
         def compare(a:String, b:String) = b.length compare a.length
       }
defined module VarNameOrdering

Now you can use the second argument list in an explicit fashion like this:

scala> val tm1 = TreeMap( "a" -> 1, "bc" -> 2, "def" -> 3 )( VarNameOrdering )
tm: scala.collection.immutable.TreeMap1 = Map(def -> 3, bc -> 2, a -> 1)

We pass the object to the TreeMap, which is rather similiar to a Java Collection Comparator object without the boilerplate instantiation. The keys of the TreeMap are now ordered by String lengths. We add more elements and the map will stay ordered.

 val tm2 = tm1 + ( "food" -> 4 )
cala.collection.immutable.TreeMap1 = Map(food -> 4, def -> 3, bc -> 2, a -> 1)

However, a word of caution, one needs to be careful and remember that maps are usually implemented as hashes.

scala> val tm3 = tm2 + ( "z" -> 5 )
tm3: scala.collection.immutable.TreeMap1 = Map(food -> 4, def -> 3, bc -> 2, z -> 5)

Surprised? You should be.

Another way to sort a map is just to get access to the keys and sort.

scala> dtm.keys.toList.sortWith ( _.length > _.length )
res3: List1 = List(salad, def, bc, a)

scala> dtm.keys.toList.sortWith ( _.length > _.length ).map( k => ( dtm.get(k).get ))
res4: List[Int] = List(10, 3, 2, 1)

scala> dtm.keys.toList.sortWith ( _.length > _.length ).map( k => ( k, dtm.get(k).get ))
res5: List[(java.lang.String, Int)] = List((salad,10), (def,3), (bc,2), (a,1))

This may well be a better solution, as you have not lost a key in flight! Considering how data is going to be stored is a major decision that needs to be taken early. You can always decide how to write projection of that data much later.

Finally, it is interesting to see the parallels between Java and Scala

scala> dtm.keys
res6: Iterable1 = Set(a, bc, def, salad)

scala> dtm.keys.toList
res7: List1 = List(a, bc, def, salad)

PS: I can safely say I have used Scala professionally today in financial enterprise.

Categories: Development, language, programming, Scala Tags: