Quantcast
Channel: raphael.vogel
Viewing all articles
Browse latest Browse all 11

Writing a betting pool application for the Soccer World Cup 2006 (Part I)

$
0
0

What happens on the 9th of June this year ?

Yes it's the opening of the Soccer Wold Cup in Germany. Since I like soccer and computers, I decided to build a small betting pool application using our own software. The whole project will be split up into 4 weblogs with the following topics:

  • Part I: Explaining the architecture and the features of the soccer betting pool application
  • Part II: How to build the Business Object (BO) layer of the application using CAF (Composite Application Framework)
  • Part III: How to connect the BO layer with the User Interface (UI) layer
  • Part IV: How to build the UI with Web Dynpro for Java
Technology decisions
If you look at the technologies in our J2EE server it is quite obvious that Web Dynpro is the right choice for the UI layer, but looking at the business and database layer we have several possibilities:
  • For the DB layer we can use object relational persistence like EJB-CMP or JDO and for relational persistence we can use OpenSQL/JDBC or OpenSQL/SQLJ
  • For the business layer we can use EJB-Session Beans or normal Java Classes in combination with the DAO (Data Access Object) pattern
  • We can integrate an open source framework like Spring or Hibernate
  • We can use CAF (Composite Application Framework)

So I had to make a decission. First of all, I'm not a fan of EJB 2.x (to complex, multiple classes and XML for one bean...). Second I wanted to have object relational persistence and didn't want to write to much code. And last but not least I wanted to use SAP technology.

So my decission was to try it with CAF

Functional requirements
The betting pool application should have the following features:
  • To make a prediction, users have to register themselves before accessing the application
  • After login they have the possibility to make predictions for one or all matches
  • The user can change their predictions up until the match has started
  • For each exact prediction of a match result, the user will receive 3 points. If they only predict the right winning team, they will receive only 1 point
  • The user can see a rank list with the gathered points of all other users
  • An administrator must be able to enter the results after a match and must be able to create new matches (e.g. quarter finals)
Design of the Business Objects
The following picture shows the BO's and the relations between them.
image

Each Player can make multiple Predictions and each Match can have multiple Predictions, but a Prediction belongs exactly to one Player and one Match. A Player has an unique ID, a firstname, a lastname and the points they have gathered for a correct prediction. A Match has the name of the teams, the goals, and the time and date of when the match takes place. The Prediciton entity has the two predicitons for each team and references to the Player and Match entities.

Restrictions
Did I mention, that this should be a small application? Therefore I made some assumptions:
  • Since each registered user only writes on his own Prediciton records, no DB transactions or other locking mechanisms are implemented. I also assumed, that only one Administrator is allowed to change or create match data at the same time
  • Permission checks based on role concepts (J2EE or UME roles) are not implemented
  • There are no security checks on the business methods
  • The error handling is quite basic.
  • In the Web Dynpro UI I concentrated on the basic features. It's up to you, to add enhancements to adjust your UI. For example I did not implement the input validation for an entered prediction. This application should be seen as a starting point for your own enhancements - have fun
  • I take no responsibility for any errors, so if you plan to use this application within your company, playing with real money, do not complain if something goes wrong ;-)
Prerequisites
  • To follow the examples you must install the Sneak Preview Edition of the Java Stack for NW 2004s. You can download it here
  • Basic Java knowledge. I will not explain what's an instance variable or how to use the Comparator Interface to sort objects in a list etc.
  • Basic knowledge of the SAP Netweaver Developer Studio. You should know how to open a new perspective or how to organize imports etc.
  • Because it realy is a lot of work to describe every click, it is possible that I sometimes just write "open the Component Controller and insert the following code in the wdDoInit() method". I try my best to describe every step, but you know....

What's next?
In Part II of the weblog series we will start with the creation of the DB and Business Layer using CAF Core. If you already want to dive into CAF the following links give you additional information about CAF. Keep in mind that I'll only use CAF Core functionality for my application. This means I'll not be using Guided Procedures (GP) or CAF UI patterns

Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>