Wednesday, December 23, 2009

Some useful JSR-168 resources

While trying to figure out the essentials of portlet development, I found few useful resources on this topic:
Here goes a mindmapped extract of those two:

Thursday, December 17, 2009

Using Spring in server side of GWT

Thanks to this post, I was able to use Spring in my GWT-RPC services. Though, I had to fix it a bit - use autowireBeanProperties instead of autowireBean (otherwise my services didn't get populated).

Saturday, November 7, 2009

Relational storage using JAXB, JPA and HyperJAXB

Let us imagine a situation when you are writing an application sitting on the ESB, or providing a web service enabled interface. In both cases you will probably end up having some XML Schema describing your data transfer format. Also, good chances are that you will have to have a RDBMS schema, too. Usually both are designed, implemented and documented separately. But when you write your application from scratch, you have a unique possibility to seriously reduce amount of work need to be done. Here I want to share some of my ideas how to achieve this.

Few variants are possible. You can start with DDL, generate JPA-annotated beans using Hibernate Tools for example, and then annotate it with some JAXB stuff (or use something not requiring annotations at all, like XStream). You will be able to get an XSD using some JavaBeans-to-XSD tool (like you have in IBM Rational tools when generating WSDLs for given beans), or just generate a bunch of sample XML files by marshaling some test data and use any modern XML editor to generate XSD by example. But I must warn you that the XSD will be rather ugly, because usually you don't have too much control over the whole process, that's why the proper tooling is vital for success. Nevertheless, this approach is quite common and supported by many powerful tools, such as my favorite IBM Rational Software Architect 7.5.

From the other hand, you can start with some UML and generate Java Beans, then put all the necessary annotations (both JAXB and JPA) inside. But you will have to do a double amount of work fixing the beans structure and hardcoding annotations for both technologies. Once again, you will need to fix the resulting XSD manually, that's for sure.

What I prefer to do is design the data layer entirely in XSD (which maps to Java classes in a more natural way than DDL), then generate Java beans using JAXB or something similar, enrich it with JPA annotations and generate DDL as the result. Sounds pretty nice, but there are some problems, particularly at the JPA annotations stage. The major one is that you lose flexibility in XSD changing, because after each change your beans will be generated again and you will lose all your precious annotations (yes, you can keep JPA configuration in XML, but this approach has its own drawbacks, and it's beyond the scope of this post anyway).

Fortunately there exists a tool which reduces (and in some cases can even eliminate it at all) the amount of the manual work at the JPA stage. It is implemented by Aleksei Valikov and called HyperJAXB 3 (version 1 is outdated and version 2 supports Hibernate instead of pure JPA). It is more-or-less a plugin set for XJC, adding JPA annotations to JAXB-generated beans. It is distributed as an easy to use bundle containing everything (including build.xml) to start converting your XSDs to JAXB + JPA enabled Java Beans.

Here comes the concepts of relationships and keys. The problem is, when not specified explicitly, HyperJAXB creates an autogenerated integer ID for every entity, which is not always what you really want to get. Let me explain. I want to automate not only the data schema creation, but also the API to access data. For example, when there comes an XML from the client, I don't want to check if the same piece of data is already present in my DB (in fact it can be a hell lot of work to do, especially when some complex, deeply nested XML structures are considered). I want the intelligent middleware to merge it automatically with the existing data. But it won't happen by default, because of the autogenerated IDs, which are always issued new. So, if you will try to persist the same XML twice, it will put two copies in your DB, which is probably not what you expect to see.

To fix this behavior, you need to explicitly specify the meaningful IDs for your entities. With HyperJAXB you can specify it directly in your XSD by marking some of the entity fields with the special XSD annotation in the same way you document your schemas (For details please consult HyperJAXB documentation. Yes, you still can't use the XSD uniqueness constraints support because it's a bit too hard to parse by XJC-like tool). Same is true for the relationship options – for example, you can define one-to-many with all the possible JPA attributes, so it's quite flexible in case you need it.

So far, so good. Things start being complicated when you have compound IDs (and I think it happens really soon in the real life applications). Fortunately HyperJAXB gained support for IdClass few weeks ago. But here comes another problem of “cascading” IDs – when you have a complex primary key (in entity A) used as a foreign key in another entity (B), which at the same time is a part of its (B's) primary key. We had a brief discussion on this topic with Aleksei (BTW, I want to say THANKS! for his great instant support for HyperJAXB and related stuff), and it seems to be too hard to implement in the foreseeable future due to some limitations of XJC extension mechanisms. So, the only way out is to tweak generated beans manually. Well, I think it is something like 20% of the job, and another 80% is done automatically.

So, in the end the results are pretty sweet. You design your data structure as XML Schema (which itself can be generated based on XML samples). Then you put some metadata (mostly ID information) inside to make sure it is complete. Now you run HyperJAXB against your XSDs and fix the generated Java Beans in case you need to handle some “complex” situations. Then, using one of the tools (either Hibernate Tools or OpenJPA Mapping Tool) you get DDL in a matter of seconds. After that you are able to (un)marshal your entities in a single line of code using JAXB, and load / merge them from / to any RDBMS in a single LOC using JPA. That totally eliminates all the serialization and storage-related code, reducing complexity, improving reliability, bla-bla-bla :)

P. S.: I must warn you that there are some issues when using this approach with different JPA providers. I've tried both Hibernate and OpenJPA and they seem to be not really compatible with each other for anything but the most trivial models. It worth a separate post and I'm not going to explain it here, just to make it short: I prefer OpenJPA over Hibernate nowadays, because I find it less restricting in defining relationships and complex IDs. Also, from the tooling point of view, those are pretty close.

P. P. S.: HyperJAXB functionality is growing rapidly, so I won't be surprised to see the majority of the issues mentioned in this post addressed in the upcoming releases. I wish this project good luck and can't wait to see it gaining popularity in the JEE development community.

P. P. P. S.: Code samples and / or detailed tutorial will come later, because it is a considerable amount of work and I'm pretty busy nowadays. Though, if you have any questions regarding the aforementioned approach, please feel free to ask.

Monday, August 17, 2009

Very Simple RESTful Web Services in Python

I was trying to find something for easy implementation of web services in any CGI language. Firstly I considered PHP. A lot of negative emotions, nothing really simple and a wasted day. Perl has some better support for the stuff, but I've chosen Python (mostly because I've got less experience in it and wanted to give it a try).

Python has a CGI-like standard called WSGI, which makes Web Services implementation much easier. But still not that easy, as I want it. So, spent a day writing my own "library", which you can find here, hosted on Google Code. Now you can write RESTful Web Services like this:
@url_pattern("/users/${username}/plans/${year}", ['GET', 'PUT'])
def get_plans (username, year, request):
return "Inside get_plans('%s', '%s')" % (username, year)
I'm gonna use it to implement a very first version of Pomodoro Server. Some brief impressions:
  • Python is very easy to learn and has a lot of great metaprogramming capabilities, very similar to Ruby. Great language, it's a pleasure to code it!
  • Python's documentation is just awesome!
  • Some Web Frameworks provide the similar functionality, but it's painful to install and comes with a lot of other heavyweight features, such as MVC and ORM.
  • Google Code is a nice place to host your projects, though there are some limitations (for example, wiki is very basic and not compatible with anything else).
Update: I've just found a similar thing in Java, defined in JSR-311: JAX-RS - Java API for RESTful Web Services and implemented as Jersey. Just a short sample from its tutorial:
@Path("/users/{username}")
public class UserResource {
@GET
@Produces("text/xml")
public String getUser(@PathParam("username") String userName) {
}
}
Update2: found a very similar solution for Python called Bottle. Sample code:
@route('/hello/:name')
def hello_name(name):
return 'Hello %s!' % name

run(host='localhost', port=8080)

Wednesday, August 5, 2009

DSL Killer Application

Now I want to point at a really mind-blowing tool called JetBrains Meta Programming System. You see, some time ago to implement your own Domain-Specific Language it was necessary to develop a grammar, implement a parser (or use such tools as GNU Bison for example) which normally operates in XML SAX manner and finally do something with the results obtained. Nowadays these new tools enable you to do virtually all this stuff in kinda type-safe way. It strictly watches at all your manipulations and alerts violations.

The whole process somehow resembles XDoclet and XSLT a bit, but it's much more reliable, because of the advanced IDEA editor, which takes into account all the necessary constraints, disallowing to misprint something. Still (due to verbose syntax) logical errors at source generation stage are highly possible. Good news is that you can use the whole power of modularity in this process to reduce such risks. Maybe the most striking thing about it is that its own language to define grammar and generate artifacts is also a DSL implemented in the same environment!

You can download JetBrains MPS here for free and try a tutorial. It will take some time to get used to the tool's UI. Its strangeness is in fact that there's a pretty complex tree representation behind a text you see on the screen, and it contains a lot of meta-information displayed as special markup signs, different colors, etc. So you shouldn't think of it as of a plain old source code anymore (to see what I'm talking about, just look at XML files inside a simple test project).

There are some alternatives to this environment, namely Microsoft Visual Studio Domain-Specific Language Tools and MetaEdit+, though I haven't tried any.

P.S.: Thanks to Martin Fowler's bliki for the link - it's a really visionary source of information! Here you can also watch his video on this topic.

Tuesday, July 14, 2009

Code City

Today I was reading a book about software metrics called "Object-Oriented Metrics in Practice" by Michele Lanza and Radu Marinescu. It's abouth things like "Design Harmony" and so on.

Some of the ideas are debatable, for example on page 46 they say:
...you cannot understand the beauty of a painting by measuring its frame or understand the depth of a poem by counting the lines...

...metrics can help to evaluate and improve designs, but those have to be meaningful metrics that are put in a context of design harmony...
But at the same time it's obvious that you won't see the beauty of the poem looking on it's grammar, syntax or verse structure (these are more-or-less analogues for software design metrics), without actually reading and understanding the sense. That's why my conclusion is that for creating a harmonious software design it's necessary (but not sufficient) for the metrics to be harmonious, too.

What I liked most of all was the concept of visualizing software projects as cities. The metaphor includes classes as buildings and packages as districts. It is implemented in a tool called CodeCity. Some results of its work can be seen on Richard Wettel's page, who actually wrote it. Here is just one of them:



Though, there are few things which I think can make it even better:
  • It would be great to see a color scheme based on the developers responsible for changes, for example, using svn blame (it can be useful for both "normal" and "timeline" views).
  • Building base should be Sqrt(NOA), not just NOA - it will look more realistic. It also should have an option to scale building height to Log(NOM).
  • Color scheme should be configurable - for example, it's hard to see some "outdated" buildings on the dark backgrounds.
Nevertheless, thank you very much for giving really interesting food for my mind :)

Monday, July 13, 2009

A way to stress-test GUI

What to do if you need to test the performance of your client-server application, which is not on the Web? For example, some kind of Lotus Notes one. The problem is - you can't even execute several Lotus instances on a single machine, so it's quite a tricky task to simulate multiple simultaneous users.

Virtualization is what you can use in this case. There's an example of working stress testing system consisting of Citrix XenApp terminal server running 10 Lotus Notes instances (eating 50 Mb of RAM each), and a load generator running IBM Rational Performance Tester (which is just a very advanced point-and-click thing), which can safely simulate 20 - 40 concurrent users.

Major bottlenecks of this setup are:
  1. RAM on Terminal Server (it's better to use 64 bit solution)
  2. Network bandwidth (at least 1 Gbit Ethernet)
  3. It takes much longer (up to 4 times) to implement and debug such test cases, compared to usual web testing scenarios

XML Appliances

I was surprised to find some hardware XML processors, called XML Appliances. They can do XSLT,validation, encryption and many more. Implemented as a separate network device it can be useful in SOA.

Sunday, June 7, 2009

Things we should add to our build process

I want to try some of these and see what happens:
  1. Use Sonar for tracking various metrics (it uses all well-known Open Source tools like PMD, Checkstyle, etc. and compatible with Hudson, which we already use in our projects);
  2. Use Cirr to document public API changes (to know when something really important has changed);
  3. Use Macker (btw, its' FAQ is really informative, thanks!) to keep dependencies between different modules under control. It first requires some modeling, after which it can break builds in case someone breaks convention;
Also, what I want to do in the nearest future is some kind of retrospective metrics analysis tool. It will consist of (maybe) set of shell scripts checking out revisions from Subversion repository, compiling code, running JDepend and others against it, applying some XSLTs to its results to combine it altogether into single big XML, putting it then into some kind of 3D storage (Revision * Metric * Module), like OLAP cube in order to analyse it. Theoretically, such tool can generate a great amount of information, and what's interesting is how useful it could actually be.

The idea was inspired by one of the reports on Software Engineering Forum 2009 (link in Russian).

TeamCity by JetBrains: yet another great CI solution

After some excitement about Rational Team Concert features, here comes another one about TeamCity, by JetBrains, the same company which gave us IntelliJ IDEA and ReShaper.

So, TeamCity is an all-included solution supporting tons of really advanced features, among which there are:
You can try and actually use it for free until your project is huge enough. It takes just 225 Mb to download and 3 minutes to install.

Friday, June 5, 2009

Nice short article about IBM Rational Team Concert

Here it is. Seems that RTC is even better than I thought... Among cool things mentioned, there are:
  • Support for Agile methodology out of the box
  • Original approach to SCM, based on the concept of "streams" (which are essentially branches)
  • Advanced build system, automatically collecting all supporting artifacts, such as change sets, fixed defects, etc.
  • A lot of great documentation (like Getting Started with Jazz Source Control)
What I can add from my personal experience, is that the Major Huge Advantage of RTC is that you get all these features integrated altogether out of the box. Installed it today on Windows 2003 Server - it took just 15 minutes (!) to install and configure a complete team collaboration solution. It normally takes few days to configure something like Trac + Subversion + Hudson, and even longer if you'd like to replace Trac with Redmine or Bugzilla on Linux, etc.

Client JavaScript data storage

Cross-browser data storage made easy using PersistJS. It supports a lot of different ways of storing data on client browser, falling back to plain old cookies, when necessary. The library itself is really minimalistic and standalone (opposed to Dojo Storage, for example). Also, it can be integrated with another lightweight runtime storage solution called "Taffy DB", which will enable almost SQL-like queries in JavaScript. Looks very nice to store some user-related info, session data, etc.

Sunday, May 31, 2009

Ultimate Pomodoro?

What is the major problem of using the Pomodoro Technique? I think it's a sharing one. You see, when you're "in the middle of a pomodoro", no one really cares - your team mates will go on interrupting you anyway!

So, you need to synchronize it somehow. Setting a single timer per team is a bad idea, for the obvious reasons. What I suggest to do is to invent some kind of a Pomodoro Server and track your current status there (team-wise or project-wise). Of course, the policy should be invented for all team members to check this status before interrupting another person.

Sample feature list:
  • Notification when required person's pomodoro has finished
  • Integration with your corporate favourite IM client as a plugin
  • Integration with popular issue tracking systems via plugins
  • Speach recognition to simplify items entry
  • Flexible hotkeys for all frequent actions to make things even easier
  • Statistics gathering to analyze and boost personal productivity
Hope to find some time to figure it out in a further detail... Frankly speaking, already tried some of the most popular open source voice recognition tools. It seems that either my microphone, or my English, or these tools, or its' settings, or alltogether are too bad to recognize anything but "one [pause] two". With 25% accuracy. Sigh...

Tuesday, May 12, 2009

About coding

I want to separate two different kinds of coding.

First is handwriting code from scratch, which is a good old not-reusable-bad-to-support approach. It gives me a great pleasure, because I know what to expect and when I solve a Task, it's clear what I've done to complete it. I mean, it's all so clear and predictable, that nothing can spoil your pleasure of getting things done. I used to code this way somewhere about seven years ago writting C++ utils in MS Visual Studio 7.

Nowadays, things are different. I'm developing Important Enterprise Java Applications, and the coding development sequence looks like this:

  1. Find an appropriate Library or Framework.
  2. Choose the one which either the trendiest one (in this case all your further actions will be more painful), or the wider used one (of course, in this case everyone will think that you're starting to lose your grip on modern hi-tech).
  3. Try it on some sample application (though, this stage will not give you any useful information at all).
  4. Try to plug it to your existing application, consisting of Frameworks, Libraries and running on Servers. Configure it (that's where you start hating both XML and lazy developers who suddenly appear not being able to write any meaningful documentation at all). That's where the vast majority of time gets spent.
  5. Fix all bugs and side effects brought by that all-new yet-another Framework. You won't be able to spot all of them fast enough of course, so this stage virtually never ends.

So, in this world the pleasure of getting things done is usually comes at step 4, when you finally manage to squeeze your brand new part into the puzzle. But that's not it - it has nothing in common with the first Predictable Big Pleasure, and this makes a huge problem for me. Somehow, programming (which is such an interesting and exciting thing in fact!) doesn't make me happy anymore - it became just a job.

And exactly that's why I'm really looking forward to start coding in Ruby, to see if it's that good, as they say.

Tuesday, April 7, 2009

web.xml security limitations

It appears that web.xml security is kinda useless in the real world - it has few severe limitations:
  • This will not work at all (several wildcards):
    <url-pattern>/stations/*/departure/*</url-pattern>

  • This will not work as expected, because only one security constraint will be checked (both constraints work separately):

    <security-constraint>
    <display-name>Station 14 constraint</display-name>
    <web-resource-collection>
    <web-resource-name>All station 14'th resources</web-resource-name>
    <url-pattern>/stations/14/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>STATION_14</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <display-name>View arrival constraint</display-name>
    <web-resource-collection>
    <web-resource-name>View arrival page</web-resource-name>
    <url-pattern>/stations/14/arrival/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
    <role-name>VIEW_ARRIVAL</role-name>
    </auth-constraint>
    </security-constraint>
Had to spend three days to figure it out :( Now I'm going to investigate Spring Security (AKA Acegi Security).

Friday, March 20, 2009

Mercurial vs Subversion

Mercurial is yet another version control system. According to its' book, here are the main differences to Subversion:
  • Mercurial is distributed, i. e. each Mercurial client has his own complete copy of repository, including whole history. That's the main difference to Subversion, which is client-server, so other differences can be considered as side-effects of this.
  • Merge is much better in Mercurial, which makes it easier to use branches (always a big pain with Subversion). This is really required, because it's the main mechanism of sharing code between developers.
  • Performance - Mercurial is in general somewhat faster.
  • Space - Mercurial is more efficient when consuming disk space.
  • 3rd-party integration - Subversion has more integration means, at least now.
  • Locks - Subversion provides locking mechanism, which is suitable for working with large binary files. Mercurial is not that efficient in this respect, also due to its distributed nature.
  • Import/Export - Mercurial is able to import and export data from Subversion, CVS, git and others. It makes it easier to migrate to.
A simple way to start with Mercurial (at least for Windows users) is to download TortoiseHg installer for Windows (all included).

Also, Bazaar should be considered as an alternative (here is a good article comparing and explaining those). Yes, Mercurial appears to be much simpler in install and more than 2 times faster than Bazaar for nearly all operations.

Complete stack of Redmine

When installing Redmine (which seems to be a nice alternative to Trac), I found a site where you can download complete stacks of different open source software, like LAMP, Trac, etc. Should be very useful when one needs a basic fast installation. Versions there are more-or-less fresh (i. e. 0.10.4 for Trac and 0.8.1 for Redmine).

Monday, March 2, 2009

Trac + Subversion installation on Windows

Here I'll describe a 20 minute procedure of Trac + Subversion (the latest versions) installation for 32 bit Windows (successfully tested under Windows XP and Windows 2003 Server). It's really simple and straightforward.

I assume the following directory structure (my project is called "rw"):

D:\projects
D:\projects\trac
D:\projects\trac\rw
D:\projects\repos
D:\projects\repos\rw
D:\projects\tools
D:\projects\tools\Python25
D:\projects\tools\svn-win32-1.5.5


Well, let's get started!

1. Subversion server setup

There are two ways to install SVN server. I tried both of them and both work fine, so it's up to you which one to choose.

1.1.1. Download VisualSVN server
1.1.2. Download SVN binaries (also see complete downloads list)
1.1.3. Download Python bindings for Subversion (at the same place)
1.1.4. Install VisualSVN to any location, set repositories location to d:\projects\repos (you can accept defaults for all other options)
1.1.5. Create a repository (you can use management console for this) named "rw" and check a special checkbox to create a standard folder structure (trunk, tags, etc)
1.1.5. Create a new user for accessing repository. Now you can browse it using this URL and newly created login: https://localhost:8443/svn/rw/

OR

1.2.1. Download SVN server from tigris.org (also see complete downloads list)
1.2.2. Download Python bindings for Subversion (at the same place)
1.2.3. Unzip SVN server to d:\projects\tools, optionally add its bin folder to PATH
1.2.4. Create a repository named "rw" (svnadmin create d:\projects\repos\rw) and create a standard folder structure (trunk, tags, etc) manually
1.2.5. Create a new user for accessing repository (modify D:\projects\repos\rw\conf\passwd and uncomment a line in D:\projects\repos\rw\conf\svnserve.conf). Now you can browse it using this URL and newly created login: svn://localhost/rw/
1.2.6. You can start the server like this: svnserve.exe -r d:\projects\repos -d

TODO: See how it can be tunelled through HTTPS, also see how it can be run as a service.

2. Trac setup

2.1. Download Trac for windows installer (see complete downloads section)
2.2. Download Python 2.5 installer (details here, if needed)
2.3. Download genshi installer for Python 2.5
2.4. Download setuptools (instructions available here)
2.5. Install Python, for example to d:\Python25
2.6. (Optionally) add d:\Python25 to PATH system environment variable
2.7. Install setuptools, genshi and Trac to default locations

3. Integration with Subversion (this solution is kinda ugly hack. I assume it could be achieved much easier, though I was unable to find how exactly):

3.1. Unzip svn-win32-1.5.5_py.zip to d:\Python25\Lib\site-packages
3.2. Unzip svn-win32-1.5.5.zip\svn-win32-1.5.5\bin to d:\Python25\Lib\site-packages\libsvn
3.3. copy d:\Python25\Lib\site-packages\libsvn\*.dll d:\Python25\Lib\site-packages\libsvn\*.pyd
3.4. mkdir d:\projects\trac\rw
3.5. Execute this: trac-admin d:\projects\trac\rw initenv, enter the project name and d:\projects\repos\rw when asked for Subversion repository location. Leave all other values default.
3.7. To test installation just execute this: tracd --port 8000 d:\projects\trac\rw

4. Setup authentication (see instructions)

4.1. Create a new file named trac-digest.py and fill it with code from this page
4.2. Create an administrator user (user "adm" with password "adm"): python trac-digest.py -u adm -p adm >> d:\projects\trac\rw\digest.txt
4.3. Give that user all permissions: trac-admin d:\projects\trac\rw permission add adm TRAC_ADMIN
4.4. Run this to test everything: tracd -p 80 --auth=rw,trac\rw\digest.txt,trac trac\rw

Now you should be able to see the Admin tab if you log in with "adm" / "adm" (see http://localhost/rw)

4.5. Adjust attachment limit in trac.ini:

[attachment]
max_size = 262144000

(it's 250 Mb)

5. Enable automatic ticket control via Subversion comments. See instuctions:
Download trac-post-commit-hook and trac-post-commit-hook.cmd from here and follow instructions in trac-post-commit-hook.cmd.
Place it to d:\projects\repos\rw\hooks and modify .cmd file like that:
SET TRAC_ENV=D:\projects\trac\rw

6. Update. Use Subversion authentication in Trac.
Using AccountManagerPlugin we can work with Trac users fast and easy. I'll describe the simplest and unsecure way of setting it up.

6.1. easy_install http://trac-hacks.org/svn/accountmanagerplugin/trunk
6.2. Go to Trac Admin tab and enable Account Manager Plugin and the following modules:
  • AccountManagerAdminPage
  • AccountManager
  • AbstractPasswordFileStore
  • HttpAuthStore
  • AccountChangeListener
  • AccountChangeNotificationAdminPanel
  • SvnServePasswordStore
  • AccountModule
  • LoginModule
  • RegistrationModule
(it will make your life much easier allowing not to login into that Windoze box to change some passwords).
6.3. Now you'll need to add the following line to [components] section of trac.ini (it will disable HTTP authentication):
trac.web.auth.LoginModule = disabled
6.4. Go to Accounts / Configuration (see left menu in Admin mode) and enter your passwd filename into SvnServePasswordStore box (i. e. D:\projects\repos\rw\conf\passwd)
6.5. Now you can login as adm (don't forget to add this user to your Subversion's passwd file) and add / remove Trac users via new menu items in Admin tab. The best thing about it is that now all your changes will be reflected in Subversion configuration, so this could be considered as the common place of manipulating users for your development environment.
6.6. IMPORTANT. Now you can't use --auth when starting tracd. So, my command line is simply tools\Python25\Scripts\tracd.exe -p 80 trac\rw

Now you can customize all the necessary settings, first of all authorization. Also there available a lot of useful plugins for Trac, see Trac hacks site. What I'm going to do next is install Maven proxy and Hudson continuous integration solution.

P.S. The best thing about this installation is that it can be done once and then packed into a handy (in my case 80 Mb) redistributable ZIP file and use it everywhere. The only issue in this case is that you will need to install Python anyway (because of some shared DLLs), but during installation you can choose the existing D:\projects\tools\Python25 directory and it won't override your changes.

Saturday, February 28, 2009

The Pomodoro Technique

Again, thanks to Henrik Kniberg's blog I've got a brief introduction to Pomodoro Technique, which is essentially a way to improve one's productivity. The PDF describing it is quite a simple one and is fun to read (for those lazy enough there exists a 5-minute guide too).

The sole idea of this technique is to split the work into fixed short time frames separated by breaks, plan it and protect it against interruptions. A set of simple yet efficient rules promises to make it work.

I was completely carried away by this paragraph, because it seems to be the thing I'm lacking most of all in my everyday work:
We can stimulate this ability to feel time in a different way by means of a series of exercises which serve to enhance consciousness of passing time among Pomodoro users. This different awareness of the passage of time seems to lead Pomodoro users to a higher level of concentration in performing the activity at hand.
BTW, the concept is thoroughly developed and there exist various tools dedicated to help using it, so it should be a fun thing to advance this technique, but I'm going to use it's simplest, hardware form. Yes, gonna try this on Monday! :)

Friday, February 27, 2009

Scrum and XP from the Trenches

Just finished reading a book by Henrik Kniberg. I found it really exciting and fun to read (at least, in Russian translation). Thank you, Henrik, looking forward to read more of your books :)

Short extract follows:

Wednesday, February 25, 2009

XQuery for mashups?

Consider this basic XQuery sample:
for $statement in document(https://www.sample.com/sample.xml)//post
let $comment := $statement/comment
where $statement/postedby = 'userBob'
return <quotebob>{$comment}</quotebob>
Nice, isn't it?

False language

I guess it's the most obfuscated programming language ever invented (and it's more-or-less useful, compared to Brainfuck for example). Meet False Language!
99 9[1-$][\$@$@$@$@\/*=[1-$$[%\1-$@]?0=[\$.' ,\]?]?]#
It's a program which prints all primes up to 100. It's so impressively smart, that inspired creation of K, F and Y programming languages, which in turn are... somewhat similar to J and Q.

Tuesday, February 24, 2009

Nice diagrams

Take a look at Treemap diagrams:



It's like a... well, upskirts view of the tree. Really cool Javascript for automated generation of these diagrams could be found here (it's a demo).

Wednesday, February 18, 2009

Grid Computing made easy with GridGain

I've just watched a 20 minute demo of GridGain usage for parallel computations. Looks quite impressive, at least easy due to Map-Reduce-like approach employed in a very simple form. Also it has a nice feature of transparent propagation of code changes between nodes, still it's not actually clear for me how they gonna manage changes in classpath, libraries, etc.

It seems that GridGain is not very popular (yet), at least I was unable to find a wiki article about it :) though I really sympathize its simplicity and wish them good luck.

Monday, February 16, 2009

Sun Web 2.0 tech is easy

Two following links describe how to achieve famous Ruby on Rails rapid development on Java platform using Sun tools - Netbeans and GlassFish. Among pros there are really fast setup, high performance (due to clustering) and flexibility (mix Java and Ruby):

Friday, February 13, 2009

Pushing data to browser

What will happen if a server don't close the TCP/IP connection after web page has finished loading? Right, it will wait until timeout, which could be quite a long period of time. That means we can use it to establish long-live connections (keeping them alive via some kind of polling) to provide server-to-client data push, events, bidirectional data streams, etc.

With AJAX such things became simpler, because no IFrames nor page reloads nor applets of any kind are necessary anymore. Instead nowadays we have Comet, which is an umbrella term for all such technologies, for example:
  • Bayeux protocol providing publish/subscribe model
  • BOSH for establishing bi-directional connections between client and server
Usually these things are combined with some kind of non-blocking IO on the server side in order to save resources there. For example, there exists integration with Grizzly.

The shortest way to read a text file

Check this out (in fact it retrieves complete web page):
new java.util.Scanner(url.openConnection().getInputStream()).useDelimiter("\\Z").next();
Thanks to CT Arrington's Weblog and Core Java Technologies Tech Tips magazine.

Update: one more short way, using Apache Commons IO:
FileUtils.readFileToString(file);

Some open-source Java tech for scalability

Some articles I've read briefly and don't want to forget:

Thursday, February 12, 2009

Nice IBM advertisement from 1975


That's not about James Bond. The rest of slides here.

Software transactional memory

I've never heard about such thing as STM, which is quite an interesting concurrency control concept, an alternative to more commonly used lock-based synchronization. It's usage could be found in Clojure programming language running under JVM, which I think makes both of these worth trying.

Though, it can't replace locking completely, well... because in fact it provides no locking :) So, some inconsistent states are still possible, therefore transaction locking should be used, which returns us back to Earth.

Wednesday, February 11, 2009

Tools for XSD-LDM-DDL roundrip development

There are some articles suggesting to use Rational Data Architect for XSD-DDL-LDM roundtrip development. It doesn't work. None of four RDA 7.0.0.5 installations I found in my department is able to import XSD into LDM, as this article suggests. It shows all the necessary dialog boxes, but in the end it does nothing. Just sielently does nothing.

Ok, maybe my schema is all wrong (maybe because it was not created by Business Modeler), still it's very simple and I see no reason why it shouldn't work. Also, it doesn't permit to transform LDM to Physical Data Model, so no DDL generation too... Ok, I guess it should work, but only after reading some Redbook about it.

I decided to give a short try to other ER modeling tools. PowerDesigner allowed me to easily create an LDM (it's called "Conceptual Data Model" there) and transform it to Physical Data Model AKA DDL in few clicks. Altova XML Spy was able to move between XML Schema and DDL seamlessly...

Both tools also provide a lot of useful additional functionality, which I'm going to explore and describe a bit later.

Friday, February 6, 2009

Trends

I asked Google Trends for the following stuff, and it gives some rather interesting results:
  • grid computing, soa, cloud computing
  • mainframe
  • java, c#
  • c++, c#, java
  • j2ee, microsoft .net
  • ruby, groovy
  • ruby on rails, grails
  • google
  • amazon
  • netbook, notebook
  • yahoo
  • scala, groovy
  • neural networks, artificial intelligence
  • wiki, blog
  • crisis, sex
  • hardware, software
  • netweaver, websphere
  • abap, sap
  • abap, netweaver
  • websphere, weblogic
  • ibm, oracle, microsoft
  • open source
Try yourself! :)

IBM Rational products I didn't know about

Finally I managed to find some time and go through the complete list of IBM Rational products. Here is a list of tools I found interesting and new to me:
  • Rational Host Integration Solution. It looks like an advanced screen-scrambler for existing [ugly] mainframe user interfaces, powered by Rational Host Access Transformation Services. They say it's done "without changing the existing applications". Kinda telnet2ws.
  • Rational Software Analyzer. This static software analyzer looks promising, it supports C++, Java and something else. What I'm interested in is 500+ code review rules for Java. I tried to run it against one of our projects, and it produces some quite impressive results. I mean, something I wouldn't notice in an everyday life. The major drawback is that the installation is >600 Mb, which is just too much for such a simple thing (I would prefer to have it just as a downloadable plugin for my RSA). Furthermore, Rational Software Architect which I use as a main tool already have limited support for such analysis (providing just 200+ rules).
  • Rational Business Developer. After reading this: "EGL (Enterprise Generation Language) compliments the breadth and depth of Java and COBOL technology with a simplified, more abstract development paradigm", I imagined an EGL editor with a radiobutton allowing to choose one of these: "Generate COBOL code", "Generate Java code". No COBOL please. Also they compare it with .NET for a task of retreiving data from IBM mainframe (!). In the end they claim something like "yep, we knew it would happen. Dotnet sucks, it doesn't work with mainframes". In fact, that PDF is the most exciting thing about RBD, and reading it somehow resembles watching Belarussian political news on government TV channel (that's exaclty the situation when one look is worth a hundered words).
Wheeew! To be continued.

JSF in RAD links

Here are just few good links found about how to easily implement JSF in Rational Application Developer. Haven't managed to read it yet, so posting it here just in order not to lose it:

Thursday, February 5, 2009

Habits and motivation

Recently I've read a short post by Chad Fowler about development of good habits in 20 days. In short, he says that it's easy to make yourself do something just for 20 days and at the same time that's usually enough for this activity to become a habit. I like his idea (it's so simple!) and already started gathering some good habits, mostly in the household area. Let's see and wait until March :)

Also I've looked through a Paul Gram's blog, which I frankly speaking dislike because of it's well, straightforwardness. He's an over-positive, super-optimistic, completely American businessman saying some quite obvious things trying to find some deep sense inside. Anyway, I found an interesting idea there too. Let me quote it:

If you start a new year off with massive success in the first month, it’s amazing how fast it can snowball and help propel you to your best year EVER.

I think that's a fresh idea and it's not too late to start something like that in mid-February :)

Wednesday, February 4, 2009

Tricky

I'm really intrigued by OSGi stuff. No, really, I can't understand what does it mean. They call it "technology" and "framework", but these words are so generic that it doesn't mean anything to me... I gave up and searched in Russian, and it didn't help either! It's very, very interesting.

UPD: Finally found an easy tutorial on it. They could have told "it's a megasophisticated way of using pluging" instead of "framework" :)

Tuesday, February 3, 2009

Simplifying JDBC in DSL fashion

I like these libs, which are way simpler to understand and learn (at least, for simple queries) and much more lightweight than full-blown ORM tools like Hibernate:
  • JaQu, though I can't figure out if it could be downloaded without H2
  • LIQUidFORM, which does its best to look like LINQ
  • And some other LINQ-inspired implementations for Java
To understand what I'm talking about, consider this simple example replacing all that verbose JDBC stuff:
Product p = new Product();
List soldOutProducts =
db.from(p).where(p.unitsInStock).is(0).select();
And yes, I wish you good luck, because I'm afraid, some cool features (closures, etc) which can improve DSL implementation in Java won't be included in JSE 7. That's why I'm looking at Groovy with increasing interest and can't wait to see good IDE support for it.

Update: they actually will include closures in JSE 7! Not looking at Groovy anymore :)

Monday, February 2, 2009

Functional Programming in Architecture

While reading an article about Functional Programming (it's in Russian), I've caught myself that RESTful web service is a kind of Pure Function, so REST is kinda FP approach :)

BDD is too repetitive?

I've got acquainted with Behavior-driven testing, though it still looks too verbose for me. The aforementioned article doesn't give the JBehave annotation "syntax" examples, which I don't like so much.

UPD: Thinking of our poor testers who were unable to document their functional tests, start suspecting that this is what they might have needed instead of using IBM Rational Functional Tester...

Thursday, January 29, 2009

Cool Groovy feature 2

I can't stop surprising by all that cool language features Groovy provides. I like learning them by example. This time it is calling methods asynchronously in Groovy, part two - using Categories. This is not that easy to implement (though it's easy enough) compared to methodMissing approach, however it lacks all that disadvantages of overriding handlers.

Briefly, it uses closures, and functionality provided by use keyword. I guess it could be improved to make the whole thing less verbose, but right now I have no time to think about it. Tried to do something similar in Java using AspectJ, but stuck due to Java syntax limitations due to absence of closures. Using anonymous classes here and there looks ugly and is not less verbose nor easier to understand than straightforward approach.

I wonder if some kind of closures can be implemented in Java using aspects. Haven't found the solution yet.

Tuesday, January 27, 2009

Some business rules resources

In the recent project we used Hirix XRules business rules engine (you would barely find any information on it anywhere, because it's an IBM internal tool), which appeared to be buggy and slow in our web environment. So, we switched to native Groovy code then and implemented all our rules (supported by more than 700 pages of very brief documentation) and underlying rules engine. I've spent about three months optimizing and polishing it, and in the end it has a very good performance, outperforming the initial solution by more than 100 times.

Why haven't we used some off-the-shelf product instead? Well, mostly because we lacked information, were limited in time and virtually all other resources. So now when I have time to investigate (the project is over), I found some neat stuff about it:
So, at the first glance, it seems that the vast majority of current BR tools have absolutely ugly syntax, too expensive or both. Seems I didn't manage to find the Perfect Business Rules Engine again...

Friday, January 23, 2009

Thursday, January 22, 2009

HTTPUnit in DB2 stored procedure

That was nightmare - running HttpUnit as a stored procedure (don't ask me why) on 8.2 was crashing db2fmp to heap dump. After two days tossing xercesImpl.jar here and there, I decided that was enough and upgraded DB2 to 9.5 Viper-2! Pretty cool XML support and a lot of other large-scale-supporting stuff, but all I need is stable interpretation of my precious stored procedure.

And guess what? It works! More or less... Xerces still unable to find something important inside HttpUnit, but at least no crashes. I guess it's because Xerces uses something internal as a classloader, that's why they have so many problems with shared libraries, etc. So, I've just put that nasty JARs here and there and everywhere (yes, that's not any kind of production system, just a learning application) and now it seems working fine. Well, I'm not sure yet, because it's quite a long-running procedure, but I will know for sure in about ten minutes.

Keeping my fingers crossed + +

UPD: Yes, it works finally. Also, I've found a nice article about HtmlUnit vs HttpUnit. Damn.

Wednesday, January 21, 2009

Artima Developer Spotlight Forum - Java Properties without Getters and Setters

Here is described an elegant way of implementing C#-like properties in Java (1.4+) using AspectJ. Nice try, though quite a useless one in a modern reflection-based Java world... Such things make me consider learning AspectJ in a more detail.

My first entry AKA disclaimer

Hello, I'm a software developer in a major Belorussian IT company, and I think that's all you need to know about me at the moment :)
Firstly, it was surprisingly easy to create that blog, thanks to blogger.com! I'm not a native English speaker (actually, I've born in ex-USSR country), so don't get confused with it please.
I think this will be mostly IT-related blog, where I'm going to collect my favorite links, articles, etc.