Tuesday, August 18, 2009

Readling List

XtraDb:

http://www.mysqlperformanceblog.com/2009/08/13/xtradb-the-top-10-enhancements/


Mysql performance blog

http://www.amazon.com/gp/product/0596101716?ie=UTF8&tag=perinc-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0596101716

Monday, August 17, 2009

Pro JSF and Ajax by Jonas Jacobi and John R. Fallows

Read On: 8/17/09
Rating: 7 /10

Pros:

  • I liked this summary of other applications and which component of MVC they target: Examples of frameworks are Struts (an open source controller framework);
    TopLink and Hibernate (model frameworks); and Tiles, Tapestry, XUL, and ADF UIX (so-
    called view frameworks).
Cons:
  • Can be hard to read
Questions:
  • Why do so many frameworks model navigation these days?

Comparing Web Frameworks: Struts, Spring MVC, Webwork, Tapestry & JSF

Read on: 08/17/2009
Rating: 2/10

Way outdated, by the time I got my hands on it. No fault of the authors it was made in 2005.

Pros:
  • Concise
Cons:
  • Its just a bunch of slides

Beginning Spring 2 by Dave Minter

Read On: 8/17/09
Rating: 8/10

Pros:
  • Very good introduction to Spring
  • Clear explanation of IoC and dependency injection
  • Made a strong case for using Spring for all applications
Cons
  • Would of liked more Spring annotation examples.
  • The database example could of been expanded. In particular I wasn't sure what the purpose of the DAO's were.
  • I would of liked a more detail on Spring MVC

Friday, August 7, 2009

My desired Java technology stack.

This blogpost will be continually updated to list my favorite application stack for various projects. I welcome any comments to help me choose the best tools that will make me most productive.

Web Container
Currently I'm biased for tomcat its easy to setup and administer and I haven't had any problems with it.

I'm having good success with also using apache with mod_proxy_balancer as a load balancer mechanism. Still need to investigate how to make the apache instance not be my single point of failure.

I do not like glassfish. For a project a couple years ago we went with that and the app is still buggy and crashing a lot. Granted its probably more of the apps problem EJB 2.0 without a lot of other kruft but glassfish didn't impress me.

To consider:
I want to investigate JBOSS again. I used it in college and I wonder if features of JBOSS would be compelling enough for me to move off of Tomcat.

Possible reasons to consider JBOSS
  • uses tomcat, and you can configure it to run with almost no features but tomcat, but still have the ability to use enterprise class features at a later date.
  • Heard about their shard memory cache, this could be useful for some of my applications

Display Technologies
I don't know. I've tried GWT, JSF, JavaFX, JSP/JSTL. Nothing seems like the best technology here. I seem to spend most of my time writing the front end of the application which is the part i least enjoy.

What I'm looking for ideally is an easy to use set of components to layout without much fuss. Any suggestions? Note I'm not looking for something like struts, which as far as I understand it, helps with navigation.

Configuration
Spring, looks like a good standard way of handling application configuration.

Javascript Libraries
Need to investigate and choose between:
  • tablekit
  • jquery
  • fabtabulous
  • anything else?


Database
Mysql enough said, although I would use MSSQL in a heartbeat again but you can't beat the price of Mysql.

Need to investigate scaling, and replication of Mysql that is the next big task I need to tackle at work.

ORM
After EJB 2.0 hell I swore off ORM's, but using the Google Appengine I've grown found of JPA. Just started looking at Hibernate JPA. Early impressions: I like it!

Anyone else want to recommend something?

Current ordering of choices:
  • Hibernate JPA- using javax.persitence classes to not tie into a vendor.
  • Straight JDBC

XML Parsing
SAX/DOM/JAXB? I don't really know yet

Sunday, July 26, 2009

JavaFX - Peg Game.

JavaFX is a technology from SUN ( recently taken over by Oracle ) that competes against Adobe Flash and Microsoft Silverlight.

This article shows how to build a simple JavaFX program to play the 'Peg Game'.

The Peg game is played with a triangular piece of board with 15 holes in it. One hole (usually the top) is left open and golf tees are placed into the other 14. The objective is to hop over the pegs, removing the hopped peg, and in doing so remove all but one peg from the game.

Here it is in action: http://turnbasedgames.appspot.com/lastblock/Last_Block_Standing.html



To create this game I have four files:

Main.fx
TriangleBase.fx
GameSquare.fx
Util.java

Main.fx consists of:

package javafxapplication1;

import javafx.scene.paint.Color;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafxapplication1.TriangleBase;


/**
* @author Lars Vogel
*/
Stage {
var rect: Rectangle;
var circ: Circle;
title: "Last Block Standing"
scene: Scene {
width: 500
height: 500
var myString = "Last Block Standing"
var gameInstance: TriangleBase = new TriangleBase;
content: [
gameInstance,
Rectangle {
x: 50,
y: 300
width: 50,
height: 15
arcHeight: 2
arcWidth: 2
stroke: Color.BLACK
strokeWidth: 2
fill: LinearGradient {
startX: 0.0
startY: 0.0
endX: 0.0
endY: 1.0
stops: [
Stop {
color: Color.ORANGE
offset: 0.0
},
Stop {
color: Color.DARKRED
offset: 0.3
},
Stop {
color: Color.ORANGE
offset: 1.0
},
]
}
onMouseClicked: function(me) {
gameInstance.restart();
}
}
Text {
fill: Color.WHITE
font: Font {
name: "Arial Bold"
size: 12
}
x: 55,
y: 315
content: "Restart"
}
]
}
}

Triangle Base:
/*
* TriangleBase.fx
*
* Created on Jul 23, 2009, 10:55:02 PM
*/

package javafxapplication1;

import javafx.scene.control.Control;
import javafx.scene.Group;
import javafx.scene.Node;

/**
* @author avalanche
*/

public class TriangleBase extends Control {
public override function create(): Node {
return group;
}

var group: Group =
Group {
content: [
]
};
public function buildContent() {
insert GameSquare{ SquareId:1 x1:50 y1:0 hasTee:false} into group.content;
insert GameSquare{ SquareId:2 x1:40 y1:20} into group.content;
insert GameSquare{ SquareId:3 x1:60 y1:20} into group.content;
insert GameSquare{ SquareId:4 x1:30 y1:40} into group.content;
insert GameSquare{ SquareId:5 x1:50 y1:40} into group.content;
insert GameSquare{ SquareId:6 x1:70 y1:40} into group.content;
insert GameSquare{ SquareId:7 x1:20 y1:60} into group.content;
insert GameSquare{ SquareId:8 x1:40 y1:60} into group.content;
insert GameSquare{ SquareId:9 x1:60 y1:60} into group.content;
insert GameSquare{ SquareId:10 x1:80 y1:60} into group.content;
insert GameSquare{ SquareId:11 x1:10 y1:80} into group.content;
insert GameSquare{ SquareId:12 x1:30 y1:80} into group.content;
insert GameSquare{ SquareId:13 x1:50 y1:80} into group.content;
insert GameSquare{ SquareId:14 x1:70 y1:80} into group.content;
insert GameSquare{ SquareId:15 x1:90 y1:80} into group.content;
}

public function restart() {
delete group.content;
buildContent();
println("performing restart");
}
postinit{
buildContent();
}

}

GameSquare:
/*
* Node.fx
*
* Created on Jul 23, 2009, 11:12:07 PM
*/

package javafxapplication1;

import javafx.scene.control.Control;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafxapplication1.Util;
import java.util.HashMap;

var clickedSquare: GameSquare= null;
var gameSquareMap = new HashMap();

public class GameSquare extends Control {
public var SquareId: Integer;
public var squareColor: Color = Color.GREEN;
public var x1: Number;
public var y1: Number;
public var hasTee: Boolean = true;

var rect: Rectangle =
Rectangle{

fill: bind squareColor;

height: (20 * 2)
width: (20 * 2 )
translateX: (x1 * 2 )
translateY: (y1 * 2)
stroke: Color.BLACK;
onMouseClicked: function(me){


// first click, and I have a tee
if (clickedSquare == null and this.hasTee == true) {
println("setting clickedsquare");
clickedSquare = this;
clickedSquare.setIsClicked(true)


// second click, and I don't have a tee
}else if(this.hasTee == false and clickedSquare != null) {
// Find square we jumped over.
var hoppedNode = Util.getHoppedNode(clickedSquare.SquareId, this.SquareId);
if (hoppedNode != -1 ) {
var hoppedSquare = gameSquareMap.get(hoppedNode) as GameSquare;
if (hoppedSquare.hasTee) {
// hopped square is now empty
hoppedSquare.setHasTee(false);
this.setHasTee(true);
clickedSquare.setHasTee(false);
}
}
clickedSquare.setIsClicked(false);
clickedSquare = null;
} else {
//invalid remove marker for first click so user can try again.
clickedSquare.setIsClicked(false);
clickedSquare = null;
}

}
}


public override function create(): Rectangle {
return rect;
}
function setIsClicked(arg:Boolean) {
if (arg==true) {
squareColor = Color.BROWN;
}
else {
setHasTee(hasTee); //set to proper color;
}
}

function setHasTee(arg:Boolean) {
hasTee = arg;
if (hasTee == true) {
squareColor = Color.GREEN;
} else {
squareColor = Color.RED;
}
}

postinit {
this.setHasTee(hasTee);
gameSquareMap.put(SquareId, this);
}
}

Util.java

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package javafxapplication1;

import java.util.HashMap;
import java.util.Map;

/**
*
* @author avalanche
*/
public class Util {
static Map connections = new HashMap();
static {
connections.put("1,4", 2);
connections.put("1,6",3);
connections.put("2,7",4);
connections.put("2,9",5);
connections.put("3,8",5);
connections.put("3,10",6);
connections.put("4,6",5);
connections.put("4,11",7);
connections.put("4,13",8);
connections.put("5,12",8);
connections.put("5,14",9);
connections.put("6,13",9);
connections.put("6,15",10);
connections.put("7,9",8);
connections.put("8,10",9);
connections.put("11,13",12);
connections.put("12,14",13);
connections.put("13,15",14);
}
static public int getHoppedNode(int x, int y ) {
int lowest = Math.min(x,y);
int highest = Math.max(x,y);
Integer value = connections.get(lowest+","+highest);
if ( value == null )
return -1;
else
return value;

}

}


(This article is a placeholder, I'm going to come back and comment later)