14.04 2010

Creating an application from zero to done: Day 3

I worked about two hours extra yesterday on the project when I got home. The goal, as I said, was to draw the mock-ups for the two other ‘add’ screen, Player and Result. I did that, and actually implemented the Player mock up along with half of the Result mock up. It went quite fast as the foundation was done. I finished the ‘Add Result’ -view on Wednesday morning in the next three hours. That is probably the most complicated view my software will have. At this point I had all add views done and only need views to view data anymore. As I had no real persistence I decided to close the GUI project and start working on the domain project.

First look on db4o

db4o is a data storage framework that works in an object oriented way. The instruction text looked very promising. You don’t need any annotations or XML configurations and it will accept any object for persisting. Basically you just do this to store something:

ObjectContainer db = Db4oEmbedded.openFile("path/to/my/file/");
try{ db.store(myObject) } 
finally { db.close(); }

That looks very easy. Almost too simple to be true. But it was that simple. I had persisted my first objects with only three lines of coding. I downloaded db4o (with maven), read up on how to use it and implemented the store and ‘list all’ functions for all my entities in three hours. Very nifty! The only downside with db4o I see right now is it’s licence, which is GPL, which means that I have to decide to either publish all my code as open source or find an alternative to db4o before I publish my project in any way (i.e. make it freely usable on the web, give it to friends for personal use etc.). Got to think about what to do.

I also worked along with the GUI project by making a page to view information about the players in the system. It’s basically just a table with all players in the system and when you choose one, you’ll see an info grid on that player. Now it still only shows the name of that player. I’ll make similar views on tracks and rounds tomorrow and a nifty home page showing info of the logged in user. Then there is just some polish and adding a graph or two left. Probably will make it in time. Maybe.

I’ve clocked somewhere around 28 hours on this project with an additional four of five hours on the course doing something else than the project (introduction and such). I’m starting to notice that the 11-12 hour days are starting to wear me out but my inspiration in this project, and the inspiration to succeed will still push me forward through the last day of coding.

Comments
13.04 2010

Creating an application from zero to done: Day 2

Day 2 started of fighting with Maven. Setting up the web project was not as straightforward as I would have hoped. First step was to find how out how to use the Vaadin archetype to generate the project. The archetype doesn’t seem to be in the main maven repository and I had a hard time figuring out where I can add new repositories to m2eclipse, and which repository exactly to add. I got it finally right with a lot of trial and error and it generated me the dynamic web project with an start-up application and Vaadin jar etc. That was just the beginning of my problems. Next up I had the problem that eclipse’s WTP didn’t accept my project and I couldn’t deploy it directly. I got WTP to recognize the project as a web project by adding natures to .project file and finally adding the Java and Dynamic Web Module project facets. After getting it deployed on tomcat I noticed that my web.xml generated by the archetype was empty, and I had to copy it in from another project. The final issue I had was that WTP didn’t deploy the Maven Dependencies, which contained the Vaadin jar, so I had to manually modify the .classpath file. It was a bumpy road but finally I got a grey page on the screen with a button saying “Click Me”. I probably should make a tutorial for myself how to set up a business logic project and a Vaadin project at some point, because that is basically what I need when I start something new. But now it’s time to get into the coding!

As I got the architecture right I started cranking out the code quite fast. First thing I did was to create a static page that looked exactly like the mockup I drew yesterday. With that finished I had the basic layout with header and content, and placeholders for my main parts of the application - Home, Add and View.

I also had the time to finish of the view for adding new tracks in the system. That’s one of the three view’s of the ‘Add’ part. The two others are basically the same and I already got the mechanism done to send messages back and forth so it should implementing the rest of that part should go quite fast. The view sends the data to a front controller now, which sends it forward to a service on the backend. The service does nothing at all for the moment. I’ll probably make those when all the ‘Add’-views are done.

So two days behind, two still in front of me. I worked on this project for about eight hours today. I got the data model, tests, the GUI template and one view done. I still got left about six views, persistence, doing graphs, theming and some final touch-up here and there. It’s a lot to be done but I guess it is doable. I think I’ll draw the views for adding players and results still today, and start implementing those tomorrow. I hope I also get the persistence somewhat done tomorrow.

Home screen

Add track screenshot

Comments
12.04 2010

Creating an application from zero to done: Day 1

As I might have mentioned earlier on, I’m still a student at Åbo Akademi, working to get my master’s degree in computer science. The studies have not really moved forward in the pace I would have hoped, since i have worked almost full time for the last two years. I’m trying to get my last courses done this semester so that I can then start, and focus on my final thesis.

I got a chance to take a intruging course this period. My school and my workplace was organizing a one week intesive course in Vaadin! The course itself is a walk in the park for me as I been working with Vaadin full time now for over two years. It is an introduction course where you are supposed to make a basic application with the framework. The example application coded live on the presentation of day 1 was a RSS reader, and the course participant’s projects should be of the same magnitude. As I probably got about five of that size projects already done, and when it isn’t really a challange for me, I decided to make something bigger.

I got interested in golf last summer and got me a bag of clubs of my own this spring. For that reason, and that I’ve been wanting to test out new Java frameworks, I decided to start doing a golf result tracker software. This is a total overkill for the course but I get to do something I think is fun.

For the backend I decided to go with Maven for package and dependency control and db4o for the database, along with JUnit for testing. As a seprate project I’ll do a Vaadin frontend with at least two addon components found on the newly released Vaadin Directory, ChameleonTheme for making a custom look & feel, and VisualizationsForVaadin to plot some graphs. I think this set of complexity is about what I will be capable of doing in the four days (Mon-Thu) we have time to code on it. Vaadin is in a different project so that I can add alternative GUI’s to it sometime in the future, if I end up with a decent application. An Android and iPhone app would be handy when being on the golf course!

Today I started looking at what features I want to support in the project. I decided to limit it to adding and viewing of players, tracks and scores. With this small featureset I have still room for some feature creeps. I went on defining a data model and basically coded the first version of all entities all the way. It resulted into seven different entities. I also did some user-handling and password encryption for safe data storage at one point when I accidentally got a little carried away. After defining the fields for the entities I started doing unit tests, and added the getters and setters to the objects along the test writing as I noticed which ones is actually neccessary for the applicaiton (for example a lot of setters are not allowed to be called after initialization and I prefer to have less code and no unused public methods). My project has only entities and tests and no entry point to the application itself. Only dependency injected so far with Maven is JUnit. The code base is still only 355 total lines of code, with 54% of it being tests. 93.7% of the code is being tested with only some catch clauses and such still being outside the coverage. This information is gathered with the plugins ECLEmma (for code coverage) and Metrics (for metrics, duh!) for Eclipse. Moving on from actually coding, I started with doing some mockups of the user interface. I used Balsamiq to do them, as it is really fast and it is free to use online. I did five mockups which is about a third of what I need. These focused on the main screen of the application and adding a new track to the system.

I’m starting to somewhat get a picture of what the application will include at this point. Tomorrow I will probably start with setting up a project with Vaadin and fiddling around with the main layout of the application. I’ll probably draw a couple of mockups and alter the business logic too as I will probably find some points that could have been done better.

Mockup of the main screen

Comments
2 of 5