Saturday, December 12, 2009

Tallinn Google Technology User Group

Starting the Google Technology User Group in Tallinn!

Google Groups
tallinn-gtug
Visit this group

Friday, November 20, 2009

Demotivator: Functional Programming


Thursday, November 19, 2009

Demotivator: Java 7 Closures


Sunday, November 15, 2009

Re-inventing a wheel: Implementing your own rules engine - Part 2. The rule-monkey project.

As Rools doesn't seem to be active but I'd like to make it usable by my Java apps, I'm starting the new project at Google Code, the rule-monkey. The aim is to tune the Rools engine for being usable within Java apps.

Re-inventing a wheel: Implementing your own rules engine - Part 1. Ruby Rule Engines.

Java is my primary language for application development and Ruby is the language I'm really looking at as to an alternative for application development in some cases. Even more, JRuby is the language that is perfect to be used in Java application design for some pieces of the functionality as it integrates with Java very well.

For building the business rules functionality into the Java application I think Ruby is a very reasonable choice as its metaprogramming features are very useful for creating a rules DSL.

At rubyforge I came across one interesting ruby project - Rools, which code base is quite small but the tiny framework can do quite a good job for application development.
Rools is a pure Ruby rules-engine. Its goal is to abstracting business logic and program-flow. Rools is ideally suited to processing applications where the business logic undergoes frequent modification.
 An other interesting alternative is ruby-rules by Michael Neale.

As always, a work in progress. The aims of this are to produce a minimal inference engine that is usable from the get go (and growing into a fully fledged RETE engine for first order logic over time).

The both projects mentioned do not look very active but the code base is something that might give some inspiration. But I really liked the idea of Rools how the rule language is implemented. With some modifications to the dialect it will be very powerful for describing almost every aspect of the business logic in my apps. For instance, I would add an "else" function to the rule definition language, as sometimes the rules tend to have quite complex conditions and managing the rules without the "else" clause is quite hard.

Re-inventing a wheel: Implementing your own rules engine - Part 0. Introduction.

When you have faced a project, where you think it is relevant to use the business rules approach, you might think of using an available rules engine (like ILOG or Drools). But it also might me a case when integrating a ready rules engine is not that simple.

The choice is not between building a monolithic multipurpose business rules engine or hand-coding every part of an application. It is really about including business rule-based functionality into an application wherever this makes sense.

We can view the business rule as a statement, that asserts or constraints some aspect of the business logic in a program. And in the simplest case, the rules engine is a computer program that executes the business rules applying 'em to reason about the facts (i.e. data). A BRMS, to my mind, is a rules engine + tools.

Business rules approach is a viable alternative for implementing business logic within a specific application. Why building the rules in, and not using one central BRMS, which could be generic to every application? Well, to my mind, the generic tools fit not every application. Very often the software is very specific to the application domain, and it would make much more sense to implement the rule editors into the user interface so it would look more natural to the user who manages the rules.

Indeed, sometimes even the rule language dialect of the available BRMS products isn't perfect to meet the domain logic of an application. For sure, it all depends how do you design your domain model, but there are cases where you'd like your rule language be very specific to your domain.

In the very simplistic example, take a look on the simplistic interface of the Microsoft Outlook of defining the filtering rules. Very limited and minimalistic, but it does what it is intended to do and it is quite easy to manage. But if we talk about more complex financial application, the simplicity on the user interface side is very hard to achieve. This is where DSLs come into the game. Designing a good that would cover all the aspects of the business domain is hard. But to design a specific DSL suited for a single application should be feasible I think to any application designer.

In the upcoming posts I'd like to share some thoughts about designing such a functionality into the application using Java and JRuby symbiosis.



Saturday, October 17, 2009

Eclipse DemoCamp November 2009

During the month of November and early December members of the Eclipse community will be hosting DemoCamps in cities around the world.

Tallinn is on the list! :) http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Tallinn

Sunday, October 11, 2009

uCertify's PrepKit for SCJP6.0

NB! The blog readers are entitled to a 10% discount for PrepKit software, and the discount code is UCPREP.

I had a possibility to evaluate uCertify's PrepKit software again. The last time I have evaluated the PrepKit package for SCBCD5.0 exam. This time I have evaluated the package that is intended for Sun Certified Programmer for the Java Platform SE 6 exam preparation. The software itself could be downloaded from the uCertify website.



I really liked how the practice tests are organized and the way you can combine the tests while studying.
The GUI is quite intuitive and you can easily navigate within the software. It was even quite comfortable to use on my 10.1'' netbook's screen.

Study and learn

You can find the "Study and Learn" section on the main screen. This is where you can study the material broken into topics by the content, and this is where the not-so-nice facts appear when using this PrepKit.



First of all, the explanations for the study material look quite boring. Just see the next screenshot - it just text, not attractive at all, and probably it will not even engage the users to read it. I do not know what to suggest (I'm not a usability expert) but it seems that this is a challenge for a professional designer to make such screens "sing".



Another strange example of the studies section behavior is when you are given a test question with a code snipper, like this:







To see the correct answer for this question you have to move forward with the 'next' button, which is quite inconvenient. Instead, it should have a 'show answer' button for this particular question. IMHO, this a usability issue again.

Questions in PrepKit

This PrepKit contains quite a lot of tests, easy and difficult ones. This is good when you have a lot of questions inside the package, specially in case you have paid for this software.

But lets be more critical. My annoyance comes from the text in the questions provided by this PrepKit - a-la "Mark works as a programmer in...", "Stella writes a program for ...", "Joe works as a programmer for...". I'm asking you now - who the hell cares?!?! This kind of text takes ~10% of my time to read this question and gives no value to it. This should definitely be amended. Here are some screenshots showing this issue.

Here's the small example ..



Here's an other one ..



And here's what it will look like after you have completed the test and want to see the result:



Meaningless, isn't it? OK, not that negative :), but it could be better without such sentences.

An other frustrating thing is the bad-formatted code and strange naming of the classes/variables. Perhaps, this is due to make the questions look exactly like in Sun's certification exam? Here are some screenshots:






The negative examples aside, the tests are well-prepared and there's a variety of questions that will make you think deeper, which parts of the exam you need to learn more. For me the good example is the drag'n'drop-like questions:





Explanations

The explanations for the test a rather comprehensive, but sometimes you may find some mistakes, like this one:



The code snippet looks odd, doesn't it?

Overall it is a very good idea to the the user not only if his answer was correct or not, but also explain, why was it correct or why it was incorrect.

Summary

I'm very sure that uCertify's PrepKit software is a good choice if you are looking for a training materials for Java certification. Although, the PrepKit still has some flaws in it, still with the continuous improvement and a discount code (UCPREP) it is a good investment in your education.

Saturday, October 10, 2009

Ubuntu 9.10 Countdown

Sunday, October 4, 2009

My Complains To JMS

JMS is a mess! I do not understand, why it should be so complicated!?

Take a look at this example:

public boolean sendMessage() throws Exception {
      Connection connection = null;
      InitialContext initialContext = null;
      try {
         //Step 1. Create an initial context to perform the JNDI lookup.
         initialContext = getContext(0);

         //Step 2. Perfom a lookup on the queue
         Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");

         //Step 3. Perform a lookup on the Connection Factory
         ConnectionFactory cf = (ConnectionFactory) 
                                initialContext.lookup("/ConnectionFactory");

         //Step 4.Create a JMS Connection
         connection = cf.createConnection();

         //Step 5. Create a JMS Session
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

         //Step 6. Create a JMS Message Producer
         MessageProducer producer = session.createProducer(queue);

         //Step 7. Create a Text Message
         TextMessage message = session.createTextMessage("This is a text message");
         
         System.out.println("Sent message: " + message.getText());

         //Step 8. Send the Message
         producer.send(message);

         //Step 9. Create a JMS Message Consumer
         MessageConsumer messageConsumer = session.createConsumer(queue);

         //Step 10. Start the Connection
         connection.start();

         //Step 11. Receive the message
         TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);

         System.out.println("Received message: " + messageReceived.getText());

         return true;
      } finally {
         //Step 12. Be sure to close our JMS resources!
         if (initialContext != null) {
            initialContext.close();
         }
         if(connection != null) {
            connection.close();
         }
      }
   }

You have to make 12 (!!!) steps to send and receive the message correctly. I think that most of the steps could be amended so that JMS spec would provide some default behavior.

Luckily, you can write same code with Camel:

from("bean:myBean?methodName=send").to("jms:queue:exampleQueue");
   from("jms:queue:exampleQueue").to("bean:myBean?methodName=receive");