Thursday, July 2, 2009

Want to make good use of your expensive developers?

1. Make your environment trivial to set up and use
2. Use VMs and replicate your environment at the drop of a hate

Best Hibernate Tutorial

Of all the hibernate tutorials I found, this one was the best bar none.

http://www.metaarchit.com/articles.html

Note, you are going to need to modify your jar files. Pulling down the Hibernare Core current release isn't suffficient.

This tutorial is for people who have java experience and time with the IDE.


Friday, March 27, 2009

My brief life as a software integrator

Perhaps of the most challenging jobs I had aside from being a farm hand, was being a software integrator. For months, I had the chance to work as a full time software integrator. My job has consisted of taking highly coupled software and putting it into many, many different operating environments using dynamic and non backwards compatible dynamic apis as well as hand woven security measures like Single Sign On.

There are the top things that I learned:
  • How unsexy but important good CM is
  • Benefits of well documented code
  • How to read log files extremely well
  • I hate java's Spring configuration files
  • How to use the holy grail of integration - remote debugger.

What I liked about software integration:
  • It is very challenging

What I disliked:
  • Changing source code makes problem dynamic - you have to relearn everything with a new release.
  • Finding a needle in the haystack when you have a very poor stack trace.
  • If it doesn't work, it is your fault.
  • If it isn't in when it is expected, it is your fault
  • If customers don't like it, it is your fault.
  • If it works, it is the actual core developer who did a good job




Tuesday, March 10, 2009

Redirectingin Tomcat

This is the best way to direct to another URL in the Tomcat Container.

1. create a folder in webapps folder

2. create index.jsp with this content
<% response.sendRedirect("http:www.cnn.com"); %>

3. Restart Tomcat!

Done


Thanks Nick!

Tuesday, February 24, 2009

Cam Studio vs Wink?

Which one is better?

http://debugmode.com/wink/

http://camstudio.org/


I vote for Wink because it found it pretty easy to edit the frames and add audio. The files were also much smaller with this software, which was a definite plus. I think that CAM had both AVI and Flash, but you had to record in AVI or flash mode.

Wink was flexible because I think that it let you do both.

I also like Wink's loading feature for the a presentation. The little bar showing percent loaded was nice.

Overall, Wink wins out if you want to do a quick and easy presentation. If you want a more detailed trial, please look somewhere else!

Sunday, January 25, 2009

Thread Safety in Java - Part 3 Condition Objects and Better Ways to do Synchronization

Ok, we are going back to part 2's scenario. We have SGT Lock managing the mortar team but he also is flexible enough that he can control the air power. Right? You are the program (Platoon Commander) and your squads are running your missions (threads)....

They are out there, when all of a sudden, squad X runs into trouble. They call SGT Lock and say "Hey, we are going to take over the enemy bunker, but we need mortars."

SGT Lock: "Sure, no problem. I locked it up for you! No other squad can touch it."
Squad5: "Thanks Reentrant!"

Lots of fighting.... bullets, mortars, etc...

Squad 5 " SGT Lock, the mortar team is great, but we want to try something really cool. Can you get the team to fire their mortars after the bunker gets reenforced?"

SGT Lock: Umm, sure, I can lock up the mortar team for you and will tell them to wait when it gets loaded up with bad guys.

Squad 5: You the man!

SGT Lock: Ummm, yeah, no problem, but I have a question? What happens if no enemy troops fill the bunker? Now you have tied up my mortar team.

Squad 5: "I don't care, I am trying to do my mission"

SGT Lock: Roger roger, but sounds like we need to talk to the platoon commander....

Squad 5: Yeah, you are probably right. Maybe he has thought of this already? He is a bright guy...



As the platoon commander, you take a break from polishing your shoes to answer SGT Lock's new question. It is a good one. What happens when a squad and resources have to wait for a condition?

Being a smart guy, you have built in a militaristic condition into your thought pattern. You tell SGT Lock that when a squad has to wait for something to happen, they just need to call back to SGT Lock to hold our mission and start firing when they need it.

SGT Lock: "Ok Squad 5, I spoke with the LT, you just need to call me up when you get stuck. I will tear off a sheet of paper with your order on it and save it. When it the troops fill the bunker, give me a call and I will take out your order, have the team dial it in, and then start firing. There won't be any mix ups.

Squad 5: "That makes a lot of sense. We don't want to tie up the resource when other squads need it."

SGT Lock: "Ok, everytime a Squad uses the mortar team, they will send blackberry messages to signalAll with the words "Hey, we used the mortar team" and we are done.

SGT Lock continues.... "All squads waiting for a condition to be fulfilled with the mortar team will have a chance, but we have to be fair. Squad 5, when the command signalAll() happens, I will talk with you directly. Check to see if the bunker is full yet. If it is, give me the fire command. Otherwise, you will just have to await() a little longer"

Squad 5: "Geesh, this means that I am dependent on the other squads to do what they are told. I hope that they are kind and considerate enough to notify us. I hope that I make sure to call await() too!"

SGT Lock: "Yeah, I hope so too. I think that you were trained and programmed to think about all of the different conditions that you need to consider. "

Squad 5: "Does all of the this locking, signaling, and awaiting take a lot of time for us to communicate?"

SGT Lock: " Sure it takes a little longer for use to communicate, but it better that we are accurate when we are sending explosives dangerously close to your position!"


Squad 5: "Yes, thats true. SGT, no to be a pain, but I think I can see a time when this could be messed up. What happens if everyone is waiting for troops to fill their perspective bunkers. No one calls signalAll() and we just sit and twiddle out thumbs?

SGT Lock: "Yes, that is a very good question. That could happen. Hmmm, I need to talk to the LT again!"

As the LT , you tell SGT Lock "Oh boy, I need to look at my manual. They last thing they taught us was how to get out of a deadlock situtation. I need to think about it"

As you flip through your camo "guide to concurrent military operations for dummies" , you read about something else the squads can call. When a squad is done with the mortar team, they can just yell "signal". At that point, SGT Lock pulls the first paper on his stack and gives them control. Hmmm, interesting, but what does this buy me? Not much for now. The system can still be deadlocked.

LT to all: "Squad 5 brought us a really good question about deadlocking. I will have to address this later on. I do want to take this opportunity to talk about how we can simplify all of this synchronization. Meet at my hooch at 2200. "

2200 Sharp

LT: Look, the good SGT Lock has done a lot of work to take care of things like how squads are to handle using different resources. This is kind of messy. I thought that it would be good to review a few things.

LT: "Ok, so if you have squads out there and they need to us the mortars, you , SGT Lock don't need to get involved at all. Instead, the mortar team can use some of their old regs to manage this stuff. Yes, that is right, the mortar team needs to dust off manual 1.0 and know that every squad's request can be completely synchronized from the start.

so, it would look something like this:

public void synchronize fireMortars(Coordinates iCoordinates, int iFireDuration, Target iTarget){

while(iTarget.isABadTimeToAttack()){
wait();

attack(iTarget);

notifyAll(); // Yeah, this lets everyone who is waiting for a good time to
//attack to be unblocked and able to try again.
}

}


There are some problems, our original scheme of using reentrant locks and conditions allowed us much finer control! This is really nice when doing high volume high performance military operations. This is for a high functioning platoon like us.

When we are kid of kicking back or working with a new squad, we are going to stick with the synchronize method as much as possible. It is not very inefficient, but it works with little confusion. The good news about this is that when you use this operation, I can easily look at the message traffic because it is standardized. It makes it easy for the folks back in washington to critique our operations and be true armchair quarterbacks. (Washington = Someone debugging the code). They can tell us when we are messed up much easier than when we try to create our own reentrant locks and our own conditions.

Since we are a new platoon, I will give you another lesson here in the future that will make us even better.

One final point that I want to point out... locks are kind of strange. Everything we have has a lock on it. Our machine guns, grenades, and knives all have locked. They are locked for use or unlocked, and loaded. Hence the term "lock and load". When the gun is locked and loaded, it is ready to be used. I know that this is confusing, but the Mortar team has a lock associated with it. It is either locked or not.

Some old school military folks used to call mortars with this command. We will not do this because it is pretty creepy.

public MortarUnit {

Object militaryLock;

public MortarUnit(){
militaryLock = new Object();
}

synchronized(militaryLock){
attack();
}

}

Saturday, January 24, 2009

Best SVN tutorial for Linux

This is one of the best tutorials that I found. Took me a couple of minutes to create a project and hook netbeans into it.

http://systhread.net/texts/200607subver.php

Only one problem: I think that there was an error with this line:
cp -Rp * /tmp/myproject/trunk

I skipped it and it worked fine.


I looked at using this Web Based SVN manager but decided against it because of the overhead associated with a remote installation. The tool can be found here: http://svnmanager.sourceforge.net/