søndag den 17. juni 2007

Second Life

Just entered Second Life and watched a video about it.

I must admit its sounds intriguing.

I dont' want to describe it here, you can to the website and read about it. What is interesting is that soon it will be able to feed xml and html into second life.

That will be amazing.

Everything is Miscellanous

This is really a good philosophical 'Talk', I'll give it a brief thinking through.
http://video.google.com/videoplay?docid=2159021324062223592&q=tech+talk&total=878&start=0&num=10&so=0&type=search&plindex=1

In contructing computer systems I have discovered that categorization itself can be a constriction, that ultimately can lead to severe problems.

For an example in java you have inheritance. As a rule in new generations of development processes everything should be refactorable with the least amount of effort. How can you then defend defining some objects parents, from which all attributes are set in stone. This really emphasizes the problem of the fragile base class. I have seen this sometimes and I have'nt really made any really programmed on any system of a size where changing the baseclass would cost more than a few days of work.

So the definition of anything by it's mere name or conception is fundamnetally flawed in programming. Instead it should be defined by its behaviour. This is generally enforced in the java language, so I can't help wonder why the Class inheritance construct is still is use.

In short, never think you have completely defined anything in you domain. Use interfaces always. Don't extend anything! Always assume that your definition of something will change.

Currently I'm tackling problems with an old system, which really was not designed for the features it now supports. One problem is that in the system a 'Product' is very well defined. So well defined, that changing its structure is basically a rewrite. The product should instead have been defined through interfaces. So a function changing a products price would use it's interface to that extent. A 'pricable' interface perhaps. Define it by behaviour!

Human Computation

In this 'Talk' Louis unveils to the viewer his actually implemented tools for what I might call 'Making work fun'. Something I recently experimented with in using elements of a game in combination with an actual workproces.

In my current employment I have this task of optimizing the flow of a editing images for real estate sales.

How can I make this process feel like a game? - well first you'd have to watch the 'talk' : http://video.google.com/videoplay?docid=-8246463980976635143&q=tech+talk&total=878&start=0&num=10&so=0&type=search&plindex=0

I think I would first try to apply one of the game structures.. maybe the 'synchronous' approach. Have 1 worker edit the actual image and another verify it. This is how the process actual is implemented already. A worker edits the image to fulfill some specifications. Say make the sky appear blue, remove anything unwanted in the picture and so on. Then the QA guy looks at the image and comes with corrections of sorts.

So, the worker gets paid for any image that can be used. He gets rewarded for some effort, with is a common gaming element. Although, how do we make this achievement more interactive and most important FASTER.

Well, one thing we could do is have the QA and the worker, player 1 & 2 if you will, work synchronously. But having 2 employees for a task that can be solved by just 1 is very expensive, therefore we would rather eliminate the QA as a postion and give that task to each of the workers.

By eliminating the QA per se, we can have double the output, but this puts strain on the actual control of the work, because the workers are on the same level and authority is gone. Instead we HAVE to rely on the workers not to 'cheat'. Well this is not a big problem in this case, since in the end, the customers can really easily fulfill the QA task, we just have to have a means of backtracking to the workers involved.

I have to find a concrete implementation of something similar, the ESP game is too simple to use as a model, not that it's no ingenious, it HAS to be simple, because any 1 should be able to do it.

Now we have requirements for the players, that are:
1. has to have skills with photoediting
2. can read/write english and communicate with her peer

In a scenario, the two workers would work on 1 input each parralel, but the tasks would not take an eqaul amount of time to complete, so there's our first problem to be solved. How do we align the proces of each worker and make sure that QA becomes an interactive/dynamic task done by the workers in one effort.

I'll have to research this some more.

Tech Talks

I've just started discovering the rich world of online seminars, when I was introduced to google tech talks.

I must admit, the guys doing these seminars are great inspiration to me.

One thing I started out with was trying to watch seminars that I could use for something. So I started seeing some seminars on test-first development for an example. Quickly though, I ran out of interesting seminars on that topic, but still wanted more.

My couriousity was tingled by the great seminar people who know how to motivate for any lecture. Though a possiblity for gaining knowledge on topics out of my interest, I tried out some new ones.

In this blog I will probably comment on most of them.

søndag den 10. juni 2007

Getters and Setters are evil

In my current employment I am a part of a project that is founding a new system, root up.

What I keep seeing myself doing is adding getters and setters allover my code, but only inside well-defined components. I ask you though, how well-defined must a component be to consider encupsulation for properties?

I have come to the conclusion, that each and every class is a component in it's own right.. so I should drop getters and setter entirely. Ouch, some refactoring to be done.. hmm how to accomplish it, I wonder.

Consider the case of Logging in. The usual way to go about this is to have a user obect compared to some stored data, and then doing some behind the scenes bullshit of connecting to this, and refering to that. What you essentially end up with is a function, like this


boolean login(String username, String password);


and it is placed somewhere on your mother of an application runnable.

Application{
void run(){
splashScreen();
//Hack info from the User and crack away
loginInfo = gatherLoginInfo();
login(loginInfo.name, loginInfo.pass);
}
}

That doesn't seem at all like OO programming though. One would expect this method to be a method of a User. Then the application would ask the user to log themselves in. So instead the implementation would be

User{
void login();
}

Application{
void run(){
splashScreen();
//we have a new User here
User user = new User();
//user, could you please log ourself in?
user.login();
}


Seems more accurately OO-like... right?

Some good reading:
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html?page=5

Comments can be bad and clutter code

Oh my heart bleeds for I have been deceived by my foulishness.
What I usually tell people when I can't understand their code is:
"Write lots of comments"

Which would solve the problem at hand, but maybe the problem is not my lack of insight, I should be able to comprehend most code, shouldn't I?

So instead lets take an example of some code I might misunderstand, an rewrite it so I could. I don't understand this(code segment randomly picked from http://www.google.com/codesearch):
You can look through it, or just press 'Page Down', to skip to the point.. it's hilaroius, trust me ^^

public static void main(String[] args) {
final int NUM_MSGS;
Connection connection = null;

if ((args.length < 1) || (args.length > 2)) {
System.err.println(
"Program takes one or two arguments: "
+ " []");
System.exit(1);
}

String destType = args[0];
System.out.println("Destination type is " + destType);

if (!(destType.equals("queue") || destType.equals("topic"))) {
System.err.println("Argument must be \"queue\" or " + "\"topic\"");
System.exit(1);
}

if (args.length == 2) {
NUM_MSGS = (new Integer(args[1])).intValue();
} else {
NUM_MSGS = 1;
}

Destination dest = null;

try {
if (destType.equals("queue")) {
dest = (Destination) queue;
} else {
dest = (Destination) topic;
}
} catch (Exception e) {
System.err.println("Error setting destination: " + e.toString());
e.printStackTrace();
System.exit(1);
}

try {
connection = connectionFactory.createConnection();

Session session = connection.createSession(
false,
Session.AUTO_ACKNOWLEDGE);

MessageProducer producer = session.createProducer(dest);
TextMessage message = session.createTextMessage();

for (int i = 0; i < NUM_MSGS; i++) {
message.setText("This is message " + (i + 1));
System.out.println("Sending message: " + message.getText());
producer.send(message);
}

producer.send(session.createMessage());
} catch (JMSException e) {
System.err.println("Exception occurred: " + e.toString());
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
}
}
}
}

- okay I'm dumb I know, I know. In this case, the code was actually substanially commented, I just left out the comments, because then I would have a case. I found that several lines of comment could be left out, just be refining the code a bit. So I put away the code in little neat sections, and then embraced a form of procedural glamour. I came up with this:

public static void main(String[] args) {
handleInputArguments(args);
connect();
}


Now I understand what it does.. hooray for me! And no time wasted for comments.

Spin-off'ed
Trailing through the Internet with the great firefox add-on StumbleUpon.. I actually stumbled upon something extremely interesting:

http://www.chrylers.com/top-ten-of-programming-advice-to-not-follow

It is nice to hear what seasoned programmers think of advice given to me by various colleagues.

Titles in software development

Why are so many titles popping up everywhere?
Programmer is just not good enough for us anymore.
How about 'Software Developer'?
'Software Architect'
'Software Engineer'

or real bogus titles that sound more like a job description:
'Software Qualtiy Assurance Team Leader'

I'll settle for software developer for now, although my current job entails a great list of different tasks. Lets try it out:
'Quality Assuring Software Architect Designer' - boo!