RSS
 

Archive for the ‘Development’ Category

Transactional code blocks in Java

11 Oct

Recently I read about a feature available in the .NET frametwork 2.0 or later that allows you to write transactional code blocks: that is, code blocks in which you can execute some actions or change the state of some objects and then, if something goes wrong, have the entire changes reverted to the initial state. The objects are taken to the state before the start of the transactional blocks and any other changes you performed are rolled back. The article is here.

Reading this got me thinking about how can I implement this in Java. I formulate the problem as it follows:  “How transparent for the user can one implement transactional code blocks?”. Please note that I don’t say “Can you…” but “How transparent…”. I believe that allowing any amount of stress for the user, you can implement anything. The question is, how transparent and easy to use can one do it. Read the rest of this entry »

 
 

Developing Swing applications with Eclipse and Netbeans

19 Aug

I recently worked on some personal projects that required Swing development. They were some desktop applications and some Java applets. For the development, I used primarily Eclipse, because I like the IDE and I am very accustomed with it. However, for the Swing development, I didn’t wanted to write the code by myself. Therefore, I had to either search for a Swing plugin for Eclipse or revert to some other solution (read IDE) for developing the Swing parts. Here is the combination that works for me very well. Read the rest of this entry »

 
 

Some links about OAuth

10 May

In the project that I am currently working I am implementing the OAuth protocol, in order to have the client and the server authenticate and exchange access tokens, before allowing the client to get access to the protected resources. Currently we are developing only the 2-legged model of OAuth (since we don’t need the resource owner authentication and permission allowance), but it is very likely that in the future we will switch to the 3-legged model.

Here are some links that I gathered regarding the OAuth authentication and authorization method.

For the first steps, here is a nice presentation of the protocol. By far the RFC is the way to go in order to understand the protocol completely, since it provides all the details and examples about how OAuth works (honestly I didn’t expected to find an RFC that is both easy to read and complete in information). Also, the pages that are documenting the API from LinkedIn and Twitter have proven to be very helpful.

 
 

commons-logging: when to use it

18 Mar

Nowadays I see a lot of cases where the Apache commons-logging is the default library to use for logging, in combination with Apache log4j. The commons-library is implemented so that it discovers at runtime the actual logging library that you have in your classpath, and delegates all the logging calls to that specific framework. In other words, commons-library does not implement any logging functionality. Instead, it acts as a bridge between your application and the logging framework of choice.

However, as any dynamic mechanism, it is quite fragile. So fragile that it has been marked as “DO NOT ever use it”. You can read here and here about the problems that commons-logging is creating. Read the rest of this entry »

 
 

Can we come up with something better than UML?

17 Feb

Today I stumbled upon this article, taking a side on the problems that UML has and how a better modelling language should look like. I agree with the author of the article on some of the points expressed, but, besides the requirements that the MDD community has on the language itself, I think UML does a pretty good job for the rest of the (let’s say, more common) cases where the modelling concepts are used.

UML provides a set of notation guidelines that form the base for any kind of architectural or design discussion. Sure, the specs of UML is quite large, and trying to read everything from cover to cover is a daunting task. But all this information is required only for the cases that are covering the entire field of models that need to be created. However, in many cases only a subset of the diagrams is required, and even for those diagrams, only a part of the notations is used. Read the rest of this entry »

 
 

Custom protocol handlers in Java

21 Oct

In the project that I am currently working on, we are using Groovy and the Groovy Script Engine. This class has a constructor that accepts a path (relative to which it resolves the scripts to execute) or a list of URLs. Well, the class works pretty nice with files, loading the scripts from disk, executing them, and also watching them for changes (this is actually why we are using this class as startpoint for Groovy).

After a few days, we got to the need of taking the scripts and putting them in the database. We wanted to make Groovy load somehow the scripts from the DB, and execute them. We also wanted to keep the nice feature with looking for changes and reloading/recompiling/re-executing the script each time it is found to be modified. Read the rest of this entry »

 
 

Unit testing guidelines

19 Sep

While developing a product, an important part of the development process is writing unit tests. These (in most cases, small) units of code create the safe net that will protect you when making changes, refactoring code or implementing new features. Since we are humans, and prone to mistake, we need at least this kind of system to make sure that the changes that we just performed do not brake the system, and do not have unknown or hidden side effects in the other components of the product under development.

Therefore, here are some of the guidelines and practices that I found very useful when writing unit tests (in my examples, I will use JUnit, but the these guidelines stand up for any other unit testing framework): Read the rest of this entry »