Friday, June 24, 2005

One holiday, please! Comin' right up!

Yeah yeah yeah .. We're going to Rumania!! yeah yeah yeahhhh

Later!

Thursday, June 16, 2005

C# type delegates in java

Well - if you like me ever wanted something much like the C# delegate or a pointer to a method, in java - this might be for you. Its not quite there, but this is as close as I could come... Written in notepad on a cloudy evening..



import java.lang.reflect.*;

public class Test
{


public void objectCallback(String parameter)
{
System.out.println("objectCallback("+parameter+")");
}

public static void instanceCallback(String parameter)
{
System.out.println("instanceCallback("+parameter+")");
}

public void add(int val1, int val2, Delegate delegate)
{
int result = val1 + val2;
try {
delegate.delegate(new Object[] { String.valueOf(result) });
} catch (Exception e) {
e.printStackTrace();
}
}


public static void main(String[] args) {
System.out.println("Test start");
Test test = new Test();
test.add(3, 3, new Delegate(test, "objectCallback"));
test.add(3, 3, new Delegate(Test.class, "instanceCallback"));
System.out.println("Test end");
}


public static class Delegate
{
private String methodName;
private Class clazz;
private Object object;

public Delegate(Class clazz, String methodName)
{
this.clazz = clazz;
this.methodName = methodName;
}

public Delegate(Object obj, String methodName)
{
this.object = obj;
this.methodName = methodName;
}

public void delegate(Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
{
if (object != null) {
Class objClass = object.getClass();
Method method = objClass.getMethod(methodName, mapArgs(args));
method.invoke(object, args);
} else if (clazz != null) {
Method method = clazz.getDeclaredMethod(methodName, mapArgs(args));
if (Modifier.isStatic(method.getModifiers()))
method.invoke(null, args);
else
throw new NoSuchMethodException("Method "+method+" is not static on class "+clazz);
}
}

private final static Class[] mapArgs(Object[] args)
{
if (args != null) {
Class[] cArray = new Class[args.length];
for (int i=0;i<args.length;i++) {
if (args[i] != null)
cArray[i] = args[i].getClass();
else
cArray[i] = Object.class;
}
return cArray;
}
return null;
}

}

}

Tuesday, June 07, 2005

Agility for the numb

Where to start? well - having just read this I actually first wanted to copy-paste a few paragraphs to get you, the reader, to think about the concept behind an agile approach towards software development. Well I soon found myself out of space on this blog-entry, so I decided not to, but really - you ought be reading the above linked PDF.. Its "Good Stuff"(TM)!

Anyways, looking back on my career and at the projects in which I have participated I can honestly say not many of them have been following an agile methodology. I have no doubt in my mind some would have been better of, if eg. FDD or ASD had been chosen.

I think the single most important reason for projects to "fail" is not knowing when the project is successful. Not knowing when your project is successful is guaranteed to never get you there (whereever that might be) - so I say, if you beyond any doubt are able to define the criteria for success before you start the actual implementation, the rest is a matter of principles and choices (even of methodology). This also applies to the tasks currently at hand (which might be part of a larger project).

Thursday, June 02, 2005

Configuration management / Microkernel

Not so long ago I started using Commons Configuration for most my configuration needs. Even though I dislike some Commons (especially Commons Logging) packages I really do like the Commons Configuration package. Its neat and the XMLConfiguration is indeed useful. Well - anyways, I've been a strong believer in microkernels (or atleast the idea behind the microkernel pattern), but sometimes this leads to each "kernlet" having to configure itself and what about re-configurations of a running system? (perhaps simply by changing the value of a node in an XML config file) What if we had a microkernel capable of reading a "master" config file, describing which "kernlets" should be started and each kernlet was infact a javabean. Then by using the java.beans package and all its goodies, kernlets were able to be notified when-ever a property changed and they were able to veto a property-changed-event if such an event was not wanted at the time being. Hmmm.. throw in some JMX capabilities too and you might just have yourself a sweet kernel...(now dont scream JBO$$ kernel, please!! *pfft*)