Apr 07 2009

Posted by coen under Programming, School

Lost in translation

I’ve been planning to blog again for some time now, but every time I had some spare time I had nothing interesting to write about. That has changed. In my short experience in working through projects, I noticed that sometimes there are moments ‘in between’. You know, those moments between milestones or something. Well, I’m in one right now, and it’s a biggie.

I sort of finished the backend of my model translation tool (It reads an Enterprise Architect Class Diagram [/buzzwordalert] ), and now it’s time for the client. The problem with that is that I always get bored when the interesting stuff is done. In this case, The Interesting Stuff is figuring out how the Class Diagram parts of UML fit together and how to translate that to usable interfaces so that it can be transformed into code.

Luckyly for me, another interesting part is coming up: I have to create an Eclipse plug-in that uses the backend and produce kick-ass quality Java code of it. And reverse engineering, ofcourse. Not that I’m willing to be a rival of any other tool like, say, for instance the Eclispe Modeling Framework. I just want to know how stuff like that is done and what problems are encountered while creating code for that purpose, and I secretly hope that I will be able to contribute to the EMF after my graduation internship because after reading only the beginning of the Eclipse Modeling Framework I’m very excited about it.

I also ordered a book on creating Eclipse plug-ins because I couldn’t find much of a tutorial so I’ll be reading a lot, the next couple of weeks. But until that time I am a little off my game here with translating models and all. Lost in translation.

5 Comments »

Feb 22 2009

Posted by coen under C-Sharp, Java, Programming, School

Modeling and code generation

At my graduation internship at Sogyo I am currently working on an interesting item: researching the currently available modeling and code generation tools, and see if there’s a way to provide integration between those. There probably are a lot of tools that can generate code, but I’m focusing on the Eclipse Modeling Framework, Visual Studio 2008 and Enterprise Architect. The reason I am doing this ‘research’ is because I believe that modeling should have nothing to do with the programming language the software will be written in.

As it turns out so far, Visual Studio provides a Class Designer tool, but that’s not as extensive as I’d hoped. On the other hand there are the DSL Tools which enables me to create a Domain Specific Language that provides the necessary functionality. In fact, one could create a DSL that generates Java code – or whatever language, but that’s an obvious property of any DSL.
The Eclipse Modeling Framework has way more functionality, but can – as far as I know right now – only generate Java code.
The third tool, the Enterprise Architect, is an UML modeling tool that also provides very basic code generation. Unfortunately I must say that I’m not satisfied at all with the generated code by the Enterprise Architect, and even less satisfied with the plug-ins they provide for Eclipse and Visual Studio. In the generated Java code, enums and interfaces are apparently ignored; in C# code, the namespaces are not created and class methods are generated but getters and setters are neither recognized nor generated (this also goes for Java).

So I have decided that I’m going to write at least an Eclipse plug-in that reads the model from Enterprise Architect and creates decent hand-written-quality code for the domain classes. And given time, I’ll also create a Visual Studio plug-in that does the same. After that, the next step would be to extend these plug-ins with functionality to generate persistence and GUI code. Another thing is that it should be possible to alter the code after it’s been generated and send the changes back to the model. I’ll incorporate that as well in the first version of the plug-ins.

That leaves me with a lot of work todo, so I won’t get bored the next couple of months :)

5 Comments »

Jan 17 2009

Posted by coen under PHP, Programming, School

php and ssha ldap passwords

Although the current semester is almost over, we’re still working very hard on our project (in Dutch), and today I finished a password reset function for users of the portal. The tricky thing for me is that the user passwords are stored in LDAP, so I had to figure out how to write to a LDAP database, and how to create a SSHA password hash in php.
I found that there is very little documentation about the ldap functionality in php, let alone how to create a SSHA hash. There was, however, one post on php.net where I found half of my answer: http://nl.php.net/manual/en/function.sha1.php#52365 . The only thing I had to change was:

// this
$salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand());
// into this
$salt = pack("CCCCCCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand());

So, the complete code now looks like this:

mt_srand((double)microtime()*1000000);
$salt = pack("CCCCCCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand());
$sshaPassword = "{SSHA}" . base64_encode( pack("H*", sha1($newpasswd . $salt)) . $salt);
// bind using the configged options
$ldap->bind();
$ldap->save($userDn , array("userPassword" => $sshaPassword));

So finally, the password reset functionality works and users won’t have to worry if they’ve lost their password.

2 Comments »

Jan 03 2009

Posted by coen under General, Programming, School, c++

2009

And there it is: the year 2009.
Thing is, I don’t really have a clue as to how to write this particular post, but there are a few things that I want to mention because I’m really really really excited about them :)
First of, I’m going to graduate this year, starting February 2nd. I plan to do that at Sogyo, and I’ve got a very cool assignment: I am going to do research after the available tools of code generation and DSL, and build proof of concept code in case the already available tools don’t suffice. Also, I think I will get my first Java certificate (SCJP).

Although these things all have a high nerd factor, I’ve a plan that can top that. In the summer holidays, I’ve decided to go to Hacking At Random, which will be in The Netherlands this year. I think that my friends and classmates (who also will be there) and I will have a *lot* of fun. As a matter of fact, I promise to show you some pictures afterwards.

While I’m thinking about it, my learning-by-cheating idea didn’t go as well as I thought: I didn’t finish that little project (but alas, that’s one of many). What did come out of it is Sentry. The Sentry core is actually nothing more than a library loader, but is has some nice features. Each plug-in (or library) can provide a number of hookpoints, where other plug-in commands can hook onto. Nice thing about this is that you can create a completely event-driven application, and anyone is free to create their own plug-ins. At this moment, I’m using it to create an IRC bot that is kind of able to control what’s happening in a channel and also to give my c++ knowledge a boost :) If you’re interested: you can take a quick look at my websvn subdomain, the repository is sentry_cpp, and it’s also possible to svn co it from the svn subdomain.

That’s all for now, happy 2009 y’all!

No Comments »

Oct 29 2008

Posted by coen under General, Java

learning by cheating

A long time ago, when I still was in high school, I sometimes tried to cheat my way out of some classes (like French, for instance). Of course, after a while, I got reasonably good at it, and that’s basically how I finished the course. I became more and more bold in other courses too, and after a while I got caught ( that was inevitable, of course).

Some time after I finished the part of high school we call ‘brugklas’, I came across a teacher who, to my surprise, encouraged using cheating notes. As I soon would realise, the man ment for us to create cheating notes before the exam, and not use them during one. That way, he said, you learn to summarize the things you need to study for that exam, and you’ll remember it, too.

The man was right. So, now that’s all behind me, I can use this story to do some cheating, while pretending to learn from it as well :) The cheating is about a trivia channel on irc. I’m writing a bot in Java that can parse irssi logfiles, and is also able to learn from the questions the trivia bot asks. The things I’m hoping to learn from this: How to simulate a human being that answers the questions (that means, among other things: do not answer every question correctly, but also that is makes some sense), and what is the nicest, most efficient way to learn questions; how do I determine the correct way to answer, etc.

So: $learning_by_cheating++

2 Comments »

« Prev - Next »