Results tagged “Frameworks”

Yes, there has been silence for some time. Cause of that are the upcoming exams this weekend in lectures which awesomeness-level lies below that of a rotting potato.

Nevertheless, there has been some progress. I finally decided a name and hoster for my project which I've been pondering now for almost two semesters at University. And with some traces of proudness I finally present you the

Contours Framework

To admit, the hardest part was really to find a proper name for it, which should hint a bit into the direction of the topic without colliding with other projects. Another earlier try was "Shapes" but there are already several projects around with that term in their name and which are probably more popular on search terms than my project will ever be.

In more details, the project is about creating a framework which allows Java application developers to create a file-reader for arbitrary binary files which then allows easy access to the content data from the file. This is done by providing a custom file-description language in which the structure of the file can be laid out. Then this format description is taken by the Contours framework which produces all necessary Java code for a file reader for files of this structure. This reader can then be easily be integrated into the own Java application.

I know, it's not a very common problem this addresses and there are other preferable ways for most similar problems. But I needed something which makes it easy to follow changes in file formats without the need to regenerate and review large parts of existing Java code. Furthermore when I'm dealing with more than one or two different formats, the maintenance of several different readers written by different people gets unhandy quite fast. And finally one of the goals was to produce code which allows high processing speed. When I started my project, there was no framework around addressing all of these points (and there still is none). Nowadays there are some available (one of them being Preon) but none of them seems to fit the performance requirement. And I've gotten already quite far when I discovered those, so I chose to continue with it and if it's just for learning purposes.

Nevertheless, the page is up, some content already present (notably the architecture description of Contours) and all source committed to the Contours SVN source repository. Feel free to have a look at it and if you have any comments, comment here or raise an Issue (when I come around to enable and configure that part of the project properly).

|

In the last few weeks I've got the chance to look into the sourcecode in a lot of different modules of the product our department is working on. The more code I had a look at the more a certain insight was forming in my head. What I saw when I looked at the different parts of the sourcecode from a lot of different people is, that it's cruical for the maintainability of code to know the advantages and possibilities of the frameworks you're working with. Otherwise you're going to reinvent the wheel over and over again. And I recognized many different wheels in this code.

We're working with Java here and among our used frameworks is also the Apache Commons. It's a framework which greatly eases the solving of common problems every Java developer faces every day. To give examples I'll focus on working with collections here. The Java framework itself has already some convenience methods available when working with Collection classes in the their generic interface classes (like Collection, List, Set or Map) but the Commons Collections Classes provides further methods which cover many day-to-day operations with their xyzUtil classes (see CollectionUtils or ListUtils for examples).

A lot of the operations I came across in our code deal with creation and manipulation of different collections, transforming from/to arrays, intersecting or summing them and so on. Lots of loops and different ways to solve always-repeating problems. With the utility-classes and methods from the frameworks we're using a lot of these sourcecode-parts can be reduced and simplified from up to a few dozend lines to just a few ones or in a lot of cases even a single line.

Not only does this reduction aid the readability and comprehensibility of the code it also makes it more robust as most of the framework-methods are already for example null-safe and thus take the burden of null-checks from the developer. And less code is easier maintainable than endless pages of difficult logic. Of course, the usage of frameworks also requires the developers who get at it later on to have at least a little knowledge of these but the invested time to get familiar with the framework almost always pays off manifold.

PS: Another extremely useful utility class in the Apache Commons is the StringUtils class. Just have a look at the impressive convenience methods in its interface and I bet there are many methods in there which you immediately could use at some places of your code.

|

1

Archives