Thursday, 18 May 2017

Getting Started: Introduce Coding Using Swift Playgrounds on iPad

Swift Playgrounds is an application for the iPad built by Apple to help developers learn how to write Swift applications.
Swift Playgrounds is a revolutionary new app for iPad that makes learning Swift interactive and fun. Solve puzzles to master the basics using Swift — a powerful programming language created by Apple and used by the pros to build many of today’s most popular apps. [https://www.apple.com/uk/swift/playgrounds/]
Although the application is designed primarily for developers, it can also be used to help engage children in coding. For younger children, this does require adult supervision to help with explaining what the function does.

The session is designed for younger coders, for children aged 6 and upward it might be better to try the Hour of Code session created by Apple.

Getting Started

Session Time


Around 30 minutes

What you need


  • An iPad, probably Air 2 or newer. The graphics that render are quite cool, but require some power. I haven't tried it on an older device, but it seems fine on the Air 2
  • Download Swift Playgrounds from the Apple App Store
  • Download Learn to Code 1 as an in App download form the Swift Playgrounds app

Preparation 

  • It is worthwhile taking a look around the app and getting familiar with how it works. You don't really need any significant programming experience. The session will focus on moving an alien around the screen to pick up gems and activate switches
  • For younger children the trainer will need to help with reading skills and choosing the correct function. The functions are moveForward(), turnLeft(), collectGem(), toggleSwitch(). If you haven't come across the term function before, just think of it as an action the alien will perform
  • This session is really just a game, there's no programming loops just yet. These are for a different session
  • You will probably find you can run this same session many times, children really like the interaction and ease of controlling the alien

Controls & Leading Play

  • Controls are as simple as pressing the name of the functions (actions) that you need. To go forward twice pick the moveForward() function twice. Think of it like playing a step-by-step platform game
  • If the child says they're not sure what's next just run the program. The alien finishes up at the last instruction and then you can correct. Allow the child to make mistakes, this is really important and it's OK to not have the correct solution first time. They'll struggle later if this isn't done right from the beginning as the problems become more complex
  • Let them hold the iPad and control the pressing. You might want to have a small session where you show them first, but they will get more from being the one pressing the buttons


The screen has a description and extra instructions of what needs to be done. The code is the list of instructions at the bottom left. Run my code/stop is at the bottom of the screen. 

Lessons to Try

For a thirty minute session the following are probably enough to get started. I've also outlined some things to discuss and think about each lesson and a sample solution.

  • Issuing Commands
  • Adding a New Command
  • Toggling a Switch
  • Portal Practice
  • Finding and Fixing Bugs
  • Bug Squash Practice
  • The Shortest Route
Below are some sample solutions that we came up with:

In the next lesson we will look at how to make use of the Functions module and how to use that for teaching. 

Friday, 12 May 2017

Kids Code Introduction

In recent years my blog has been fairly empty, life in general has taken over most of my free time. We have two small children aged 4 and 7 months, who are hard work but a lot of fun. The way in which children interact with technology fascinates me, Emily is quicker at using the iPad than her grandparents! Inspired by Devoxx UK, I have decided to try get back into community work. 

For the last three years I have taught over 500 developers fresh from University how to code better and prepare for a career that is more than just hacking they may have done at Uni. Most of the trainees have significant experience coding and the rest have at least started their journey. Often friends who don't program ask "How do I get into coding" or "How would I got about writing an app". It's very difficult to explain what coding is to an adult, so how do you get this across to a child that is just learning to read and write?



The are many educational games and activities targeting children, particularly for basic math and letters. Seeing how excited my daughter got by playing these games it inspired me to look at ways I could teach her the basics of programming. I wanted it to be something that we could do interactively together and that she also enjoyed spending time on. Making things fun is important, regardless of age group. An engaged trainee that is following a narrative or story along with hands on experience is usually the most successful in retaining information. 

In the blog posts to follow I'll be writing about the mini-training session plans I am working on with Emily (4 years old). Like any good training there should be some objectives and an understanding of the trainee:
  • Make coding and thinking in a structured way appealing to children. The goal here is not for Emily to join a start-up or to get to 10 and be a computer genius. It's adding an extra layer of thinking and approach to problems that schools are just getting to grips with. 
  • Sessions are no more than 30 minutes, anything longer and a young child may resent the task. I've found that it's also OK if they want to go and do something else, just start the session again from the beginning (if they remember they'll usually tell you). 
  • Being able to read is not necessary, but will help. We started this process before Emily could read, and now she can recognise some letters. We work together on choosing the right function calls and code as we go. Initially I drove that, but now she is much more confident in choosing the right functions.
  • Is not always on a computer. Some of the sessions that I am planning are not on the computer at all, but will have tasks that related to designing and executing instructions. 
Below is a video from one of my first training sessions with Emily. We are using software on the iPad called Swift Playgrounds, which is designed to teach developers how to learn Swift. However some of the early content can be used to also teach children basic concepts in a fun game environment. This will be the subject of the first lesson plan that I will publish next week. This video is special to me personally as it shows that coding can be fun and rewarding, even from a young age. 


If you are interested in following the lesson plans please keep an eye on my Kids Code page for links and on twitter. Also please do comment or make suggestions, I hope you have as much fun as we are having. 

Wednesday, 4 February 2015

Pragmatic Functional Refactoring in Java 8

Java 8 is here! Now the honeymoon period is over larger companies and innovators are starting to use the new features. However, Java 8 isn't just another version of Java, it fundamentally changes how you are able to approach problems.

"Java 8 and functional programming is not just for beards" -- Raoul, and is now available to developers in general. Many business problems can be expressed in an easier way than in a declarative style of programming. It is a well known fact however, if there is someone with a beard next to you they probably are a functional programmer. 

The slide deck from JFokus can be found here, the session was also recorded by the VirtualJug in September last year.

The talk is aimed at making functional techniques relevant to programmers and takes the approach of introducing a problem and how it can be solved using functional techniques. The good thing about this style is that the emphasis on how to apply functional programming techniques is not bogged down in buzzwords or potentially confusing terminology. 

The talk starts out with a problem we often face as software developers. Initially we have simple requirements that over time change and if the code is not designed correctly or refactored when necessary can be unwieldily and difficult to maintain. The problem domain introduced is around invoices:
  • Filtering all customers of a specific name
  • Later we want to process different customers rather than a fixed customer
  • We also now want to separate out different functions with that company that may have a different suffix representing the type of activity carried out
  • We also now want to state whether we want the invoice included or not
The result is some fairly messy code:


From the messy code the talk goes on to look at how applying functional methods can reduce some of the problems. Introducing the Predicate interface from the Java 8 API allows a test for whether an invoice should be included. This simplifies the code dramatically as the test for inclusion of an invoice can be packaged up and passed into the method as a function. This is the core of how first-class functions work, allowing a function to be passed around as a first-class citizen in the language. The introduction of method reference is shown as an intermediate step, but we finally see our lambda solution that makes everything quite clear. As a Predicate is a functional interface the test can be passed in as a simple lambda expression. The intent of the code is now clear and considerably simplified:


Compositing functions together to create more advanced predicates is next on the agenda, introducing how more complex functions can be combined together using the and, or methods. Just as it's a bit weird to wonder how this is working, as a Predicate is simply an interface we learn a new concept Default Methods introduced in Java 8. The discussion finishes with a conversation about how pipelines can be used to chain functions together, where the sequence of application is important.  The example discussed is an E-Mail where first the content is created, followed by the spell check and the addition of the signature. 

The next topic for the pragmatic approach to refactoring is currying and partial application. Currying is a tricky topic to initially wrap your head around and involves taking an initial argument set and splitting them out, so parts of the overall logic can be reused as functions. The talk looks at how to refactor a conversation function to be used for converting common measurements such as temperature and mass. I like to think of the approach as at each step the initial argument set is locked down or partially applied. I definitely advise watching the section on currying, Richard and Raoul do a great job of explaining the concepts. Here is the example used in the presentation:


Mutability is problematic, specifically where developers make things mutable that would be far better modelled as immutable objects. Mutability can introduce subtle bugs where a developer takes a reference and updates an object - however it could be years before that actually manifests itself as a production problem and can be tricky to find. There are however some cases where you need to use mutable objects and this is fine. The key is to use the right design for the right requirements within your application. 

The talk goes on to cover Optional and how it can be used to help prevent NullPointerExceptions in chained code and provide the ability for a developer to provide default values or return a slightly different result. Another key benefit of Optional is the removal of lots of boilerplate null checks that can lead to issues around code readability. This part of the talk is extremely clever and introduces a practical case for the flatMap method on Stream to get at the contents of the Optional container. I actually heard several developers comment on how useful this was to them after the talk. 

The talk is a taster of the full course that is run by myself, Richard and Raoul  More information can be found on our training site, with public course running in Switzerland, United Kingdom and Sweden in the coming months. 


Tuesday, 3 February 2015

JFokus 2015 First Impressions

In the centre of Stockholm, on a snowy first week of February, is the start of JFokus 2015. When I say cool it's currently -2°C with a "feels like" -11°C. The conference is a three day event, the first consisting of tutorials, the second and third are traditional  conference session styles. 

I came unprepared for Stockholm, and for future reference (mainly for myself) packing the extra items is recommended:
  • A hat. Only the speakers get the cool JFokus red hats!
  • Proper shoes, the snow is amazing here. It falls and everything just continues on as normal. The only effort I have seen of any snow being removed was a guy shovelling it off the roof of Stockholm Central Station. At least there was a barrier around the target area, on the pavement.
  • A decent coat for when you're outside, a fleece doesn't really do it.
When I got to the hotel on Monday I felt very unwell, got an early check-in and went straight to bed. I missed the majority of the first day except a few beers with Raoul, Richard and Heather. The hotel bar was alive with conversations about the VM Tech Summit, which sounds to have proved popular with the attendees. 

Tuesday morning I got up and explored the hotel prior to the keynote starting. The hotel is next to Central Station, but navigating to it seems impossible. Almost everyone has a story about how they ended up in the wrong place or took about 6-7 different streets to get there. Waterside is a decent venue, with lots of space for the 1700 conference delegates.


The conference kicked off with a guy with a tape measure doing some robotic style dancing on the stage. My initial reaction was:
The "developer" was the joined by some other dancers to a pretty decent routine. The stage was then taken by Mattias Karlsson, sadly we did not get to see any of his dance moves. The main room is impressive here, with room for most of the delegates.


On day 2 I attended only a few talks.
I am planning to write up each of the sessions over the coming weeks, along with some sessions from tomorrow. 

Sunday, 3 August 2014

Teaching ClassLoaders, Reflection and NIO2

As a leader of the London Java Community and as a developer in several firms I have noticed one trait across Java developers. We are spoilt! We have nice APIs, abstractions, IDEs and build systems which means that often we don't appreciate some of the lower levels of what is actually happening within the Java ecosystem. Most people can get by without this knowledge, however in the situation that there is an outage or a problem and we simply have no idea why something has started to fail, it's not the best time to start reading up on advanced Java topics. 

Sometimes we think we have enough information, because in a topic like class loading it might be enough to say "It's how Java loads classes". In my opinion this lack of knowledge is fairly dangerous, so in the Advanced Java course I recently taught with Mallon Associates I wanted to build an example that would capture the attention of the delegates. It covers four topics that we may be forgiven for forgetting Java is capable of.

The topics that I was aiming to teach amongst others were:

  • NIO2 file watch service API
  • Classloaders
  • Compilation of code at runtime
  • Reflection
The example I came up with was the WatchingClassLoader. The WatchingClassLoader is a toy example which watches a folder for the arrival of a new file. When a file lands in the inbox it checks to see whether it is a .class file or .java file. If it is a .class file the class loader will load it, if it is a .java file it first compiles it and then loads the compiled version. The main thread also holds a loop waiting for input into the terminal, this allows the user to specify a class and see via reflection the methods of the now loaded class within system. As the class loader is hierarchical if it is asked for a class it doesn't know about it defers to the parent. It works with simple classes that are in the default package (i.e. no package) - though it could be extended to be smarter. 

WatchService


The WatchService is a neat API that allows you to register a Path to monitor for a particular file based event to occur. You can specify the type of event that you are interested in using the StandardWatchEventKinds class. Using the .take() method on the watcher blocks until that event occurs. In the final example this runs on a separate thread.

Class Loader


It is possible to write your own class loader in Java. By default the class loader in Java looks on the classpath specified when running the java command - but more often this is provided from your build system specifying the path to all the library jars your running application will require. Class loading is lazy, so a class is only loaded into the system when it is first required - this is why your code can sometimes run for years and then when it goes down a spurious code path you suddenly find yourself with a ClassNotFoundException.

Writing a custom class loader gives you the opportunity to change this default behaviour. Examples of class loaders might be that when a class is requested it is loaded from a remote network location or your class files are stored in an encrypted format and the class loader is responsible for decrypting the file. In this case I just want to load the class in from where I am watching for new files to be added. To create your own class loader you need to extend the ClassLoader abstract class.

At minimum you need to be looking to override the loadClass method and basically get a byte array of the contents of class file to load. From here you need to call resolveClass and defineClass to correctly load the class into the virtual machine. My system works by checking if the class aiming to be loaded is visible in the directory I am watching - otherwise it defers to the parent class loader to load the class. Class loaders are hierarchical in nature so this is an acceptable way of delegating upwards the loading of the class. The situation that this occurs in my mini example is when the user types something like java.lang.String into the console. A cutdown example of how to do this is below.

Compiling on the Fly


One feature that surprised many of the people who took my course was that it is possible to invoke the Java Compiler from within an executing Java process. ToolProvider allows us to get hold of the JavaCompiler and from there we can pass in a CompilationTask which contains the .java file we are looking to compile. This is best shown by example: 

Reflection


The final stage is reflection, which allows the user to look at the .java file or .class file they have added to the running system. In a demo this is the closest we get to the wow moment :). Reflection is the Java mechanism that allows inspection of a class at runtime. Most people are using reflection, even if they don't know they are doing so, as it is heavily used in frameworks such as Spring. In the example I just print out the methods as this is enough to prove the point, though on the actual course we use reflection for many other purposes including to invoke methods and generally prove what is possible. The simple snippet for allowing reflection on our classes via a custom class loader looks like this:

The Full Project


You can find the full toy example that you can run and play around with on GitHub. As this is a teaching example, there are plenty of places that this could be taken further - so I welcome any pull requests or tidy up to the code. It was actually something originally produced via live coding in front of the class, which has been a fairly tricky learning curve to get used to. That said now I wouldn't run a course without live coding, as it's where you get the most questions and although it's massively stressful it makes for a great session.

Saturday, 12 July 2014

Update and New Career

I thought it was about time I dropped an update onto the blog about why I've been quiet recently and what has been going on.

Early this year I decided to change career paths slightly and become a technical trainer. The highlights of my career as a developer have been to help others improve and learn from others in an informal supportive environment. I am now lucky enough to be able to do this full time designing new and fun ways of helping others learn Java, Python, C++ and .NET technologies. I work for my own company James Gough Ltd, with one primary client Mallon Associates. So far I've run ten training courses and had people booking onto my future courses, it's been challenging but one of the best things I've done. I have a fairly packed end to 2014 as I gear up for our 15 week training program.

As well as working on private training I have also teamed up with Richard Warburton and Raoul-Gabriel Urma. I am excited to announce will be offering public Java 8 courses with a focus on Lambdas and preparing Java developers for the changes that are right on our doorstep. Java as we know it is going to change, for years some developers have been dragging their feet with Java 1.4 style syntax and missing some key changes. An appreciation for the Object Oriented/Functional relationship is now required to both be able to design and build code that is succinct and solves the business problem in the best way.

This year is very busy with it being my first year in business and getting married so sadly I've had to put conferences on hold for a year, but I'm hoping that early next year I can attend jfokus.


Friday, 24 January 2014

Live Coding on Java 8 Date Time API

Yesterday I recorded a live coding session on java.time. Below is all the information so you can code along if you like:

The Video


The Source Code

All the source code is freely available on github you can get this running the following command:

The (brief) details for setting up the IDE can be found in the readme.

The Slides


Monday, 20 January 2014

Java 8 Date Time: Happy Martin Luther King Day

Today is Martin Luther King Day in the US. I had totally forgotten about this holiday until I saw a few tweets this morning about it. The interesting thing about this holiday is that rather than being on a specific day, it is on the third Monday of January.

As I'm currently preparing some JSR-310 material, I thought it would be interesting to share (and discuss) TemporalQuery - a new interface in Java 8 that makes it possible to write custom queries against the new DateTime classes. There is often a use case in business that an event happens that is unique to a particular domain, an example would be Futures market rolls of contracts or time periods of validity.

TemporalQuery allows us to capture the logic to perform an operation against a temporal class and return an object representing what we were querying. The interface is generic so we can choose what we return. This is a really neat design feature in Java 8 allowing us to externalise logic outside of the core API, but encapsulate the functionality as a data operation.

TemporalQuery is also a FunctionalInterface so it can be used as a lambda on a stream of temporals. In the example below we just consider one date. To find the next Martin Luther King day we can take the current date and perform the following:

LocalDate.now().query(new NextMartinLutherKingDayQuery());

The NextMartinLutherKingDayQuery is our implementation of a TemporalQuery:

Here are some things to note about the implementation:

  • In the private method I take a date at the beginning of January of the year passed. Using a TemporalAdjuster I manipulate that date to cycle it forward to where I want to be. TemporalAdjusters add more power than just plusDays or minusMonths to allow us to work on more expressive situations with date and time. 
    • The TemporalAdjusters class has some really nice methods as used here, or you can write your own TemporalAdjuster if it doesn't exist. 
    • NextOrSame is useful for this type of operation where we don't know what day we are on, but if it's the day we are querying we don't want to advance the day. We use it to iterate to the third Monday of the month of January in the year in question.
  • I then use a the Period class to find out from the date passed whether Martin Luther King Day has passed, or it is today. If it has passed I return next year's date, otherwise returning this year's date. Period is a nice abstraction so I don't have to start subtracting millisecond values etc - yes we've all seen it. 
If you're interested in playing around with this I suggest downloading the latest Java 8 beta and having a go. 

Happy Martin Luther King Day!

Saturday, 18 January 2014

User Group Visit to San Francisco

Why am I in San Francisco? 

Is it:
  • A micro brewery pub crawl?
  • The fact it's almost 20°C tomorrow?
  • To attend a Brazilian BBQ in January? 
These things are certainly going to be a nice bonus of being here, however that's not the main reason. I'm here representing the London Java Community at Oracle's big annual user group leaders convention. The purpose of the conference is to bring leaders of a variety of different Oracle user groups together to discuss best practices and drive improvement of communities and involvement for all those concerned. Particularly this year the topics I am interested in and will be participating in are:
  • Using social media - I'm particularly interested in discussing handling negative discussion and feedback via this extremely public forum.
  • Turning members into leaders and growing speaker talent. This has been an active stream in the LJC and Trisha Gee and team have been doing a fantastic job of running workshop and helping people gain the courage to make that first talk. 
  • Gamifiying your user group experience and improving user group content. I'm mainly interested in this because I get motivated by badges and awards for certain things. I think it could put a fun spin on how we run certain events in the LJC.
I plan to blog about interesting conversations and what comes out of these themes over the course of the week. The summit will only be the beginning of the discussions and I look forward to seeing more about what our members think to some of the ideas and which may work for us. 

When discussing any kind of conference and benefits of conferences I always say that it doesn't have to be a specific talk that motivates you but a catalyst to change. All the major turning points in my career have been down to ideas gained at conferences. It will be interesting to be involved in a non technical conference across a range of different products, experiences and backgrounds. 

I have very kindly had partial sponsorship from the LJC and the JCP Program Office to be here this week and I can't thank them both enough for the opportunity. 

I am now a JCP Executive Committee Representative

Why are the JCP helping to sponsor my visit here? After 3 years of working on JSRs with the London Java Community with the LJC JCP committee I have now stepped up my involvement and represent the LJC directly with other JCP executive committee members. I am attending my first face-to-face meeting at the end of this week. I'm really thrilled to be working with so many fantastic organisations and individuals to help maintain and form standards within Java. As the meeting has official minutes it's unlikely I will post anything further. 

Wednesday, 27 November 2013

Contributing to Java

I have just written a post on contributing to Java for the London Java Community's JCP Panel. You can find the full post here:



Sunday, 24 November 2013

The LJC Open Conference 2013

Yesterday I attended my 5th LJC open conference, and as always it is one of my favourite times in the year. Most of the major conferences have been and gone and people are winding down ready for Christmas. However, the combined knowledge and enthusiasm of the community doesn’t reflect this slower time of year. 

This year I got a lot more involved with helping in set up and planning board activities, as well as giving a talk on TDD primer. The session board looked like this first thing in the morning:


There are roughly 5 streams of topics at the conference, what interested me was the focus on development of people skills and testing of code - there was definitely a strong feel of craftsmanship in the air. 
  • Core Java
  • Java EE/Application Servers
  • Testing tools and processes
  • Community and soft-skills
  • Workshops
The slides I gave for my talk are below, it's based on a longer talk I gave at JAX London. The idea was to give people who haven't tried Test Driven Development before some guidance in getting started and what some of the pitfalls can be. Sadly I had a Mavericks and projector based issue, which meant I lost about 10 minutes of the talk. However, the show must go on so I covered the first slides without a project whilst the hero of the day John Stevenson fixed the projector. Minstrels will write songs about this day...


Test Driven Development Primer LJC Open Conference from jpgough

I got some good feedback on the talk - I need to refactor the examples in the slides a fair bit, this will be done when I put the information I presented at JAX into a blog series.

I also went to a talk on testing with Spock. It's not usually something I'd be particularly interested with it not being core Java, however it was interesting to see a different take on testing. I quite liked the way you can be verbose in your tests and get a lot of boilerplate you require in JUnit for free. The final talk I went to was on progressing your career without losing technical focus. A lot of people looking for mentorship and guidance at a senior level on how to remain technical. It was a good session, but only touched on a few issues in the time - it looks like something that could be run as a bigger round table.

It was great to catch up with old friends and people I've worked with in the community over the years, especially now I am not in London as often. It's also helped me start to focus on my own learning plan for next year. It's always a motivating weekend and if you didn't get chance to go this year I can't recommend it enough. As always thanks to the sponsors IBM for a great venue and beer from Zero Turnaround and some dodgy car salesman Simon Maple for organising the event.



Tuesday, 3 September 2013

Leaving London and keeping in touch

At the beginning of the beginning of the year Megan and I had our first child Emily and moved to Bedford. This sounds more severe than it actually was, the commute down from Bedford to Kings Cross is only around 40 minutes. It's been a busy 6 months since then working on multiple projects with Stackthread, getting promoted to Vice President at the firm and as you can imagine not too much sleep.

As a family, we have decided to take a step which will involve us spending a lot more time together - but sadly means that I will be leaving London as a work hub. Having just completed major project milestones at the bank I work for, I decided it was time for a change of roles and found an exciting opportunity in Milton Keynes. From a personal perspective this also cuts down a 2 hour commute (each way to Canary Wharf) to 20 minutes, and reduces my outgoing costs on expensive rail tickets.

This has left me with many decisions to make about what projects to keep working on in London and how to keep in touch with specifically the London Java Community and the London Java Community Process Committee. For now, I'm not going to make any rash decisions and see how things pan out in terms of time available and what I realistically commit to. With ever limited time, I am trying not to spread my contributions too thinly and want to ensure that whatever I do chose to work on in the next few years has a solid impact.

Currently, I next plan to be in London on:

  • 29th-30th October for JAX London.
  • One Saturday towards the end of November for the LJC Open Conference

JAX London 2013 - TDD: The Benefits are more than just the tests

An introduction to my talk at JAX 2013 - also published here.

Back when I first started my career as a developer following University I was unleashed with little training in best practices, development methodologies or what to expect from the uncertainties in real world development. Before I could start to learn all these things I was quickly placed in my first job. The type of role I was placed into was fix problems and develop new features - with only guidance relating to the specific tasks at hand. There was no training on industry best practices, which underpin the quality of the software as professionals we strive to deliver - my own development languished.

Several years on, in my own time and through quizzing various industry leading technologists like Sandro Mancuso (at JAX London 2012) and Martijn Verburg (at numerous beverage centric establishments) I started to discover my personal points of improvement. I realised that there were steps I could take to improve the approaches I had in my toolbox for software problems. I took a look at my peers and people that were applying for job roles. Many listed Test Drive Development (TDD) as something that they used on a regular basis. I very quickly realised that a lot of people claim to practice TDD, but either don't do this at all or write integration tests rather than unit tests, as well as other ideas about what TDD is.

My talk at JAX London 2013 is designed for developers who have been too busy to appreciate the less obvious benefits of TDD, particularly the side effects and task breakdown from a cognitive perspective. The session will cover the basics of TDD, the use of mocking and how this helps break up the coding complexity using code and architecture examples. I will also convey my own experience of converting to TDD along with the benefits I have realised and how to convince developers who don't want to test the approach has merits outside of just high test coverage. The talk does not aim to sell TDD, but instead present facts and experiences that I have gained over the last year so developers can form their own opinions.

From taking these steps myself I produce code closer to the requirements, more maintainable code that is able to respond quickly to changes and my colleagues can look at the code and tests and quickly understand what is going on. Conferences are often the catalyst for personal improvement, and people interested in this space but haven't had time to explore it themselves will get some good practical advice on how to get going and what to expect.

Wednesday, 27 March 2013

My First Devoxx

Venue and kick off

I've walked past the venue many times, but had never realised it was even there (standard London). The space feels huge, with plenty power points, great wifi and crap coffee. Perfect for a great conference venue. The space isn't just space, it's been well planned and thought out to enable a fantastic community feel and corridore track. The venue is nothing without setting the right tone and introduction for the rest of the conference, which is what the keynote delivered. Conferences without keynotes and setting expectations really don't ever get going. Right from the beginning Dan Hardiker made it clear that the most important part of the conference was the attendees and helping attendees to find something at the conference to help them improve as a developer. The conference was also supported by a code of conduct, everyone is safe and knows the expectations here. This is also supported by the number of keen volunteers and organisers who have done a fantastic job of making the event in London bring in the community feel of Devoxx.

Keynote

The keynote by Kevlin Henney bolstered the standard that is expected for speakers at Devoxx. The keynote "The Programmer" was thought provoking about how we see ourselves as professionals and how can draw comparisons between our experiences and other professions. It also explored different types of programmers and how their approaches to problems can be ineffective given the cognitive performance of humans. From the keynote I've taken away that I need to revisit my approach to development and time management, especially with my recent promotion. I also took away the fact I really need to work on one presentation and make it the best it can be rather than lots of smaller presentations. I've got an idea in mind which I am planning to submit to JAX London and Java Zone, not saying it will be even close to this - but a new standard is set!

Talk Highlights and Takeaways

I could write a blog post on every talk that I've been to whilst being at Devoxx, but I'll try and put together my thoughts and the talks that these have come from. Hopefully, if you're interested, you can then grab them from Parleys.

Are some of the people that are jumping to functional programming being immature in their choice? Jumping because it's the Justin Bieber of technologies and OO sucks (awesome quote Sandro). This was a great talk about OO principles and good quality design. It certainly matched a few talks I have given recently about "Is Object Oriented Programming Still Relevant" and why it is important to strike practical balances between OO theory and design.

There have been a few references to "You do write at least unit tests right?" - and I'm quite sure that the people that are at this conference do. However, how do we approach the rafts of developers that are not at conferences that don't write tests and believe that good design, software principles and tests are not conducive to being more productive? 

Charles Nutter's talk on invoke dynamic has taken a concept that I'm vaguely familiar with and got me thinking about how practical this could be to day-to-day Java developers. The one usage I've been thinking of is dependency injection without the need to do reflection. I need to think about this some more, but I'm also wondering if this could have an impact with not requiring to define dependency hierarchies - and effectively lazily load these or parts of these as required. This definitely needs more beer talk time.

Richard Warburton gave an excellent low level discussion of hardware features and how applications can struggle or thrive under certain conditions. I was glad it came with a disclaimer that these techniques won't be for everyone, as there is usually so many other things you can optimise before you'd get down to this level of crazy!

My thoughts have long been out on whether JavaScript is a complete solution for some of the more powerful products you can build in Flex and action script. Angular JS provides food for thought that there is a decent supporting framework to study in more detail. The main benefit seems to be a framework that supports a good separation of concerns and with that the testability that is required by large organised code bases.

I attended a few decent short talks on Mutability Detector and docx4j, both of which I wouldn't have been interested in a full talk, but was good to get an introduction as will potentially use both of these in the future.

Final Thoughts

  • Devoxx really is a community conference prepared and delivered by the community.
  • The atmosphere and friendly nature is something I've not seen outside of the LJC Open Conference at a large event in the past.
  • Thanks to all the organisers and volunteers for a fun and informative few days.
  • The conference is only just beginning, I must have only seen around 30% of what I wanted to see at Devoxx and now need a few more days to catch up with everything else on Parleys.
  • I've learnt a lot about Java, wider technologies and approaches to a wide range of technical problems and challenges. I think this conference would have been useful to developers of all levels.

Monday, 11 March 2013

Devoxx London 2013, What I'm Excited about on day 1

It's been a while since I last wrote a blog post! A lot has been going on since last years conference tour. The main thing has been the birth of my first child Emily, who is now 2 months old and growing well. As well as that I was promoted at work and have moved into a house in Bedford, what that does is I now have more time to write as I will be spending more of my life on a train.

Sadly, I did not have time to get my act in gear to get a submission in for Devoxx UK, however I have managed to obtain a ticket and am very excited about the event. I plan to write a few blog posts at and about the event as I don't have any talks to prepare. It's an amazing difference to be going to my first technical conference as a delegate, and in this stress free environment I'm excited about what I can learn and contribute to the conference. Conferences have had a positive impact on my career so far. The conversations I had with Sandro Mancuso, Ben Evans, Kirk Pepperdine, Richard Warburton and Martijn Verburg and others have shaped the products that I have been working on and my approach to technology. You simply don't get this from the average day, and you have to come out of your environment and comfort zone to improve your technical skills and appreciate new points of view. If you're in London Devoxx is simple the best opportunity to do this until JAX London in November.

I thought I'd highlight some talks that I'm very interested in that I think will be awesome (this doesn't mean I'm not interested in others, but these I will definitely attend)

55 New Features in Java 8

Looking forward to this one as although I've been involved in a few projects related to SE 8 it will be great to learn what's coming next. After seeing some interesting statistics on Java 7 uptake recently it will be interesting to see how many people make the direct jump from 6 to 8.

Banking, How hard can it be?

The title says it all really, and for anyone that's ever worked in banking I imagine there will be something in this talk that can be related to. I'm specifically interest in how companies are approaching more modern processes and techniques for benefitting their business and the success they have had with this.

Functional is cool, but do you know OO

Sandro is one of my favourite speakers and has had a positive influence to the way I approach problems. Recently I've run several sessions on "Is OO still relevant", so I'm hoping this will challenge my view point and maybe I will learn something about this functional programming business!

Performance Testing Java Applications

I've actually never seen Martin give a full presentation, and its always been in an informal setting I've spoken to him in the past. Often baseline performance of even non performance based systems is something that can easily be overlooked. I'm interested to understand more about how to even begin approaching systems where performance is a key business driver.

Hitting the limits of your hardware with Java

I've spoken to Peter once before at the London Java Community developer sessions and again was amazed to have access to an expert developer. At the time we were talking about ways to improve OpenJDK, some of the ideas and explanations behind his thoughts were excellent.

I think that actually just about confirms my 1st day and the first thing I've noticed is the schedule is quite narrow in terms of choice. However, I'm struggling to pick sessions because there's so many I want to go to. Several conferences I have attended have almost too much choice. The content committee has done an awesome job of making my life difficult. Not being able to chose what to go to is awesome, looking forward to sharing what I'm thinking about day 2 shortly.

Tuesday, 4 December 2012

Can Flex/Flash ever be considered a RESTful client?

One of the most relevant discussions in software development today is what will be the future of client technology? There are several platforms that as a business you might wish to deliver content to:

  • Web
  • Desktop
  • Mobile/Tablet
  • E-Mail report delivery
  • The next big thing....

You can potentially solve the problem by using HTML 5 with JavaScript to deliver to all platforms. However, this may lack the native feel you might want your application to have. This isn't really the point of the post, my main point is one considering the architecture of server side components. Given that it is likely that we will want to deliver content to multiple systems over time, my goal would be to make the client as thin as possible and have the majority of the business logic on the server side. There are exceptions to this and it does depend how rich you want to make your client side solution.

REST is rapidly becoming a natural choice for the situation where you want to deliver content to multiple clients. Flex is in some circles considered a legacy technology, and in others a lot of people have bet their business on it. The issue with Flex and the compatibility with REST is it has only two modes of operation: Success and Failure. It is possible to dig further into the failure to find the exact HTTP status code. The problem is on failure you can't access the body of the message, so if you're sending a reason for the failure back to the client there is no way to capture this in Flex. The problem is discussed briefly here. If you have to start wrapping everything in success to get at the underlying error, you defeat one of the purposes in having REST in the first place. Another forum post on Adobe informs us that this is a browser/plugin issue, as the Flash player cannot actually read the body of the response.

Given this constraint can Flex ever be considered a REST compatible client? Does it have a place in a world where the expectation is many thin clients for content delivery?

Friday, 5 October 2012

Highlights From Java One 2012

Highlights From Java One 2012

When my talks were first accepted for Java One 2012, I never imagined I would feel like this at the end of the week. Currently, I'm a mixture of so burnt out I can barely walk yet so full of adrenaline I don't want to sleep. As a technologist this week has been the highlight of my career. This post will detail a few of the highlights of the week for me.

Keynote and Lunch with James Gosling

If someone had told me I'd be sat having lunch with James Gosling after participating in the Java One community keynote I would have branded them insane. However, that's exactly what happened today. With my friends in the London Java Community we had a panel session discussing a flag ship initiative we have been working on known as Adopt-a-JSR. The keynote was so far from corporate it was refreshing, it was all about community for the community. 


We saw key technical companies participate in the initial panel, us and then a crazy robot chasing down Oracle executive Georges Saab on stage. Then something special happened, James Gosling entered the stage. He was talking about his new development at Liquid Robotics. The best part about his appearance was James was back amongst a community of developers that have a high degree of respect for him and his work with Java. I found his presentation a highlight of innovation that is ongoing in the industry. After the keynote I headed over to Stephen Chin's Java Desktop lunch. We were sat at the same table as James and discussed details of the UI that he had built and demonstrated during the keynote and discussed some of the problems that data heavy systems would cause web based applications. What a great note to end Java One on.

Java FX

Java FX has been technically the most exciting product of Java One for me. It really starts to represent the revival of Java on the desktop. Although Swing has lived on over the last few years, how many people have really wanted to do this? Java FX simplifies a developer's ability to rapidly create flexible and maintainable user interfaces. Scene Builder also provides an abstraction away from code, so you can now have a design team that builds the basic CSS and component layout and the development team adds the functionality on top. 

At Java One myself and Ben Evans presented our toy project visualising garbage collection in Java FX.   One other highlight of the week was when I met Jim Weaver near the exhibition hall. He asked me if I'd like to come over to watch him give a demo. Within about 15 minutes I was stood at the front of the demo grounds giving a presentation on I'm new to Java FX and this is what I've built. Thanks Jim! That said it was great fun and all the Java FX team are really fun people to hang around with. 


My challenge for our next JUG meeting is to get a Java FX example running on the Raspberry Pi. Hopefully the Pi will arrive before then, if not I'm really looking forward to sharing everything else about Java FX back in the London Java Community.

Adopt a JSR

Adopt-a-JSR is a global initiative that was kicked off in London to help make the JCP (Java Community Process) relevant to Java developers and increase their participation. Adaptavist's Dan Hardiker had the following to say about the project:
Jax - What in the development world (project or otherwise) is really interesting you at the moment?
Dan - The Adopt-a-JSR programme ran by our own LJC, is one of the most important initiatives I've seen in a long time. It puts developers back in the driving seats helping to steer decisions on important areas of the language they live and breathe.
From attending Java One it was clear to see that although we have managed to reach senior members of the community there are still many members of the Java community that are not aware of the program or the aims. A second interesting point was that many of the developers attending our sessions are not members of Java User Groups. In order to address these points we are going to look at how we can be wider reaching to developers that are not members of JUGs. Recording sessions and broadcasting them to the wider community is going to be part of the strategy we look at to address this.

JSR-310 - New Date Time API

In the background to Java One we have been working hard with Oracle and Stephen Colebourne to address the final design decision of JSR-310. A lot of hard work is going into this JSR behind the scenes and at the end of some fairly heated debates we are looking to be on track for Java 8. If you're reading this and you still want to help, we are making a push for people to help us with the following:
In our continued efforts to evaluate and improve the Threeten Date/Time API for Java 8 we were discussing the effort of porting code from existing APIs. Does anyone have open source examples of code which they wrote against the existing java.util.Date or Calendar that you felt was overly complicated? I have some code myself, but I'd really like to hear from you if you have stuff that's open source and available for hacking on.
If you can help please feel free to drop me a tweet @JavaJimLondon.

Embedded

One final point that really excites me is robots! There has been a taster of Java running on embedded hardware, we've also seen some really cool demonstrations of Java FX running on embedded hardware and a Raspberry Pi. This is what I'm going to be playing with over the next few months, along with Java FX to try push the bounds of what is possible.

Thanks

A big thanks has to go out to Sharat for organising a fantastic Java One, this year really had a community feel about it. Thanks to all the speakers and the content committee, it's been awesome!

Sunday, 30 September 2012

Highlights From Java One: Day 1

Java One - San Francisco



Today was my first day at Java One, and my first international conference. It has been an immensely fun day with loads going on.

8.15 AM - First talk of the conference - ours!

The first session we attended was our talk titled "The bluffers guide to terminology". The talk walked through terminology that complicates our industry, and made observations on how business, technical and academic domains are complicated enough without additional terminology. We walked through the different sections explaining terms and simplifying them so everyone could understand. For 8.15am the audience were very engaged, and it was clear that this was something everyone could relate to. We concluded that you have to be very careful when picking terms to represent your domain model objects in software development. You need to think about having a suitable abstraction that is clear as to what it represents in the domain, but doesn't complicate the domain further.

Winning an award

For the last 18 months, myself and colleagues from the London Java Community have been working on two key initiatives - Adopt a JSR and Adopt Open JDK. Today we were awarded with a Duke's Choice Award for the hard work we have put in inspire the community to be more involved in contributing to the future of Java. It was very exciting to see the LJC's name on the big screens at the Java One keynotes. Although winning an award was not something we set out to achieve, it is an honor. It has inspired me to carry on pushing on the initiatives we started and to use Java One as an opportunity to encourage global participation. It's also got me thinking about a future initiative, but for now that will remain top secret.


Technical Keynote

I'm still processing some of what was in the keynote, but my initial reaction is how excited I am about Java on the desktop. Having experienced the pain of Swing and context switching between .Net and Flex as alternatives, I can really see a future for Java on the desktop. That wasn't all however, we actually got to see Java FX running on a Raspberry Pi and other embedded devices. There's actually an embedded version of the Java One conference scheduler deployed around the hotels! This has really steered my interest for the conference as I'll be looking to attend a large number of Java FX talks this week at Java One. We also have our talk on visualising the Java GC model on Tuesday, which will go into building an application from the beginning in Java FX what we have learnt about the technology and how to use Java FX as a teaching and visualising technology from a slightly different perpective to grids and graphs.

Party

The day ended with collecting the Duke's Choice Award and a party in the street next to the hotel. Most of us have now returned to try and shake the jet lag before a packed day tomorrow.

Wednesday, 12 September 2012

JavaFX Help: Too much animation at the same time!

I am currently working on building a Java memory model teaching tool in JavaFX, the project is available on GitHub. Whilst building the user interface I ran into a performance issue, which is easily worked around using JavaFX. This post gives the detail to the problem and how to easily resolve it.

In the memory model we have several memory sections made of memory blocks. In our application we represent each memory block with a StackPane. This has a Rectangle object at the bottom and a Text object on top of this to represent the current generation that block is in.

A block has three states it can be in:
  • Free - nothing has been allocated here yet.
  • Alive - the block holds some active memory.
  • Dead - the memory in the block has now died and is awaiting garbage collection.

We have potentially several threads that are running against the model allocating and killing memory. The challenge is animating each of the state transitions on the UI. A picture shows the animation in action:


The code segment that we used for the transition is as follows (there might be a better way to do this):

     FadeTransition fadeOldBlockOut = new FadeTransition(Duration.millis(10), view);  
     fadeOldBlockOut.setFromValue(1.0);  
     fadeOldBlockOut.setToValue(0.0);  
     fadeOldBlockOut.setCycleCount(1);  
     fadeOldBlockOut.setAutoReverse(false);  
     fadeOldBlockOut.play();
  
     FadeTransition fadeNewBlockIn = new FadeTransition(Duration.millis(1500), view);  
     fadeNewBlockIn.setFromValue(0.0);  
     fadeNewBlockIn.setToValue(1.0);  
     fadeNewBlockIn.setCycleCount(1);  
     fadeNewBlockIn.setAutoReverse(false);  
     fadeNewBlockIn.setDelay(Duration.millis(1));  
     fadeNewBlockIn.play();   

This code was added to the view object. However, once you get multiple of these firing the application will quickly start to hurt itself to keep up with the transitions required. Having read Java FX Pro 2 I quickly realised that I had taken the wrong approach. Large amounts of updating graphics, especially timeline style animation, does not belong on the main application thread. Thankfully JavaFX has an easy paradigm to resolve the issue.

I created an Object that implements Runnable, which would take the memory block I want to animate in the constructor and perform the logic above:

 class CustomMemoryBlockViewTransition implements Runnable {  
   private final MemoryBlockView view;  
   public CustomMemoryBlockViewTransition(MemoryBlockView view_) {  
     view = view_;  
   }  
   @Override  
   public void run() {  
     //...  
   }  
 }  

Once you have your Runnable defined (you can also do this as an anonymous inner class) you can simply call the Platform to run the animation at a later point. The Platform keeps a queue of activities submitted and will execute these in order.

 Platform.runLater(new CustomMemoryBlockViewTransition(this));