Saturday 27 October 2012

EXBERLINER, sharing everything

After spending a week on vacation in that perfect Utopia dressed in a dystopic outfit called Berlin (each time I go there I confirm it as my favorite place on this planet), I put a perfect end to the experience by reading the October issue (109) of EXBERLINER, the excellent English written Berlin culture and lifestyle magazine.

This issue is focused on technopolitics, so articles range from an overview of some outstanding Open Source projects being developed in Berlin, to an interview with Alec Empire (Atari Teenage Riot), passing by an interview to Germany's most famous net-activists couple, and an analysis of the first year of the Pirate Party in Berlin's parliament

One topic that keeps showing up in several texts is the idea of "liquid democracy" being pushed by the pirates. Leveraging the easiness of communication in our hyper connected world to increase people's involvement in state decisions does not seem like something much new, but what is new here is that they are really trying to implement it!

The interview with Anke and Daniel Domscheit-Berg touches many different points of interest, but I would highlight their musings about Grundeinkommen (basic income), leveraging technology to reduce the amount of time that people need to work daily, and the inevitable shift to a different economic paradigm ("Third Industrial Revolution")

As for the many Open Source projects mentioned, the winner for me is Wikidata, sort of a global knowledge database to be used among others by Wikipedia. Also, after seeing just the day before how one lady got fined in the tram due to her lack of a valid transport ticket (because of the "open doors" nature of Berlin's transport (same as in Vienna), it's tempting to want to try to save some money and it's also rather easy to forget about purchasing your ticket), the SchaffnerRadar (ticket inspector radar) Android App seems like pretty cool :-)

Well, not that it really has much to do with this post, but as it's related to Berlin... you can check here this album of mine about Berlin Street Art.

Saturday 13 October 2012

A few days in Poland

In early September I was lucky enough to spend a few days in Poland (Warsaw and Krakow) and I had a really great time there. As someone that every time he's preparing a new trip devours astonishing amounts of information about the place, I feel compelled to put my 2 cents in and share my impressions here.

Krakow was probably the most clear miss in my list of "fairy tale Central European cities", and same for Warsaw with regards to my list of "European metropolis", so, an obvious question is, why did it take me so long to set foot there (and more when I've already been several times in places like Vienna, Prague, Bratislava...)?

Well, I had certain reservations with regards to Poland since many years ago. I had heard and read quite awful things about how ultra conservative the country was, about the mass spread of far right scum (though common to most of Central-Eastern Europe, the Polish case seemed to be worse), crazy ultra-violent football hooligans, and a general "unkindness" towards foreigners (at least if they are not pale blonde well dressed people). All this had made me discard Poland as a target in many occasions, but in the last times I'd read quite different things that seemed to indicate that the whole country was moving in a new direction (church losing influence among younger generations, new punk bands, Blu murals in several cities) so it was about time to see for myself (even when documentaries like this by Ross Kemp and Stadiums of Hate made me doubt again).

As usual, don't expect a travel guide here, you have wikitravel and thousands of other resources for that (by the way, geolover is an excellent one I've come across recently), I'll write here about things that somehow I found interesting, but for many other human beings they'll probably be meaningless.

Warsaw

On the one hand this is a modern metropolis. You find large, wide avenues like Jerozolimski and Marzalkowska flanked by average buildings mainly from the second half of the last century (a few buildings seemed like a more modest version of the Socialist Realism masterpieces in Berlin's Karl Marx Allee). There's a good bunch of sky scrappers, some of them really nice (like ) and above all you have the omnipresent Palace of Culture of Science. Sure Stalin was a mother fucker, but it's undeniable that he had a taste for architecture (or convincing posters). The building is even more stunning than I expected and the views from the 30th floor are more than worth the price (around 5 EUR I think to remember). The high speed elevator that takes you up there also adds to the experience (it takes just seconds to lift you there). It seems like the population has managed to reconcile herself with this present from the man responsible for the murder of millions of Polish people, and now the building is nicely lighted in a beautiful blue light at night. Another remarkable feature of this sky scrapper is that the tower that crowns it somehow reminds me of the baroque church towers all-pervasive to Central and Eastern Europe

On the other hand, Warsaw boasts a cozy, delightful old town (completely destroyed during the WWII it was wisely rebuilt in the fifties, which is quite amazing if you compare it to Berlín, where only selected buildings were restored along with the later rebuilding of the tiny (but cute) Nikolaiviertel). I got to the Old town proper after a pleasant walk along Nowy Swiat. This street reminds me a lot of the so nice Gediminas Avenue in Vilnius (indeed, many things on this trip brought to my mind memories of last year's trip to Latvia and Lithuania). An interesting feeling while being around this area was that it didn't seem like being in the Old Town of a big European capital, it was more like being in the Old Town of a middle size city (I wouldn't know to explain the reason, it's just how I perceived it, I guess the fact of not having too many tourists around played its part). Warsaw's old town does not have any element that particularly stands out and is not too impressive if compared to other European jewels, but it's charming and harmonious and well worth your visit.

As the urban explorer that I am I didn't want to miss the chance to cross the Vistula to the Praga neighbourhood (and that way enjoy the views of this wide river). Unfortunately this is one of those cities with its back turned to the river, or at least not leveraging it too much. Same as with Vienna or Zagreb, the main part of the city developed on one side, so even when now it expands almost equally on both sides, you don't have its banks lined with historic buildings reflecting on it. To the point, Praga is well worth a couple of hours that most tourists tend to deny it. Old pre-war buildings with their facades entirely flaking expose its orange bricks. Many small businesses give it character and helps you get a grasp of the normal city. By the way, little after you cross the bridge you run into a nice Orthodox Church.

I should also mention that entering the West bank when coming by bus from Modlin Airport was rather pleasant, as first you get a fast glimpse of the old town right before entering the tunnel that crosses under it. Then, once in Aleja Jana Paula II you'll see to your left an impressive mural by Blu

Krakow

This cute city really lived up to my huge expectations. I got to Krakow by train from Warsaw in one of those hyper-hot central European summer days. Unfortunately it seems like I've got a tendency to bring along with me heat waves to this part of the world (I've been above 30 degrees in Vienna, Bratislava, Budapest, Ljubljana, Zagreb...). So when I stepped out of the train I guess we were verging 30 degrees, and the sun really burned. Anyway, the beautiful classic covered corridor painted in green that leads to the outside of the station was more than enough to predict a more than interesting stay there. I had my hostel in Kazimierz, the old Jewish neighborhood, that is currently the bohemian heart of the city. This means I started my exploration in a really nice, lively and authentic zone, but please, don't be fooled by some guides comparing it to Kreuzberg or Montmartre... that's senseless. After getting a fast grasp of the area I headed off to the city centre.

I firstly explored Wawle Hill, wow, it's stunning, a really gorgeous architectonic mix, with beautiful views of the Vistula (though the river does not go through the city centre properly, Krakow seems to leverage this water flow quite better than Warsaw). From there I continued my walk to downtown along Grodzka. There I came across the beautiful St. Andrew church with imposing sculptures of the apostles lined next to it. Go on and you reach the gorgeous Main Square. Based on my previous readings I could imagine how beautiful this square was, but what amazed me the most is how much it reminds me of Prague's central square.

The following days I took care of checking out all the other essential tourist spots, and of all that I want to highlight the Museum in Schlinder's Factory. First, it's a pretty new one, so if you've not read pretty up to date information, you could miss it. Second, the Museum of Wartime Krakow hosted there is probably the best WWII related museum I've been to (and I've been to some pretty good ones like: the information center of the Holocaust Memorial, the Topography of Terror or the Museum of the Occupation of Latvia. I think I spent more than 2 hours there, and I could have stayed event longer if I hadn't been that hungry. There are tons of information about those 5 so hard years for Krakow and Poland in general, and everything seems to have been laid out with great precision and detail. Well, in fact, there are a couple of rooms there that I would say are too realistic, one room with huge nazi flags and another one with its floor tiles with swastikas motifs, to my taste it's like a bit revolting.

I always like to take a glimpse out of the tourist areas, and bearing in mind my interest for Socialist Realism, the Nowa Huta district seemed like the obvious bet. I took tram 22 out of Jozefa Dietta and alighted at the Central Square of Nowa Huta. Well, the place is less interesting than I expected, thought it's astonishing to think that these new and beautiful buildings were built for the proletariat masses working in the gigantic steel works, they are not that impressive as the similar buildings in Berlin's Karl Marx Allee (nevertheless, it's important to realize that these Berlin buildings were intended for the party elites, not for ordinary workers). It's a bit depressive to see how the old communist street names and monuments have been taken over by the pope or Ronal Reagan. Sure the pseudo-communist experiment in Eastern Europe did not work well and population there prefers to forget it, but that should not mean throwing yourself into the arms of alternative opresors

General Notes.

Most likely is that when one thinks about Vegetarian food Poland would not be the first place to come to mind, but indeed it's been one of the places where I've enjoyed the most with food in all my trips. Green Way is a restaurant chain with units in most Polish cities. I kept visiting the one in Krakow (2 minutes away from the Main Square) daily, to be delighted by enormous, delicious ultra cheap dishes. The soups/creams are excellent, same as the soja and tomato beans stew or the Mexican Stew. In Warsaw, I regularly headed to Green. Outstanding place, again with tasty, healthy, enormous, hyper-cheap portions. One day I got a soup of the day that seemed to contain as many mushrooms as I usually have in 6 months :-)

Something that rather caught my eye, particularly in Warsaw, were the enormous fabric advertisements covering almost whole facades of many buildings in the main streets. Wherever you looked there seemed to be one of those signs inciting you to pursue happiness through consumerism. One guy explains it neatly in this interesting essay

Advertisers in Poland seem to be addicted to ‘building wraps’, i.e. mammoth fabric advertisements covering entire buildings. Entire façades of hotels, high-rise blocks and even historic buildings are cloaked in massive fabric screens promoting Coca-cola or ice cream. Behind these temporary and changing surfaces, many of the communist-era structures continue, of course, to yield slowly to the processes of time.

It was also interesting to see how (at least at a street level) the Polish economy seems to have kept more independence than the economy of other ex-Soviet Block countries. I mean, in the Baltic countries, Swedish banks, Coffee chains and supermarkets seem to be everywhere. In Hungary, Czech Republic, Slovenia, Croatia... I noticed a huge presence of Austrian and German banks and supermarkets. These countries have been drawn into the sphere of influence of their Western neighbours (in fact, creating back these old spheres of influence was one of the hidden motivations for Western Europe to push the collapse of the Soviet block and the bloody break up of Yugoslavia).
So far, most banks and supermarkets in Poland seem to be local brands, so it appears as if a big piece of the cake were still there to be taken over...

I shouln't conclude this write up without saying that hopefully my prospect was correct, and Poland seems to have walked a long path these last years towards a much more open, modern and tolerant society. I hardly saw any neonazi shithead, and I could see black people on the streets, left wing slogans on some walls and even a gay pub, and in general I felt a good attitude towards foreigners (at least for tourists).

You can also check this and this galleries that I've uploaded into Picasa

Monday 8 October 2012

Soundtrack to these last months

It's been a long while since my last write up about music, so seems about time to post something regarding the bands that I've been listening more regularly in the last months (not that I think that this can be of much use to my few readers, but more as a homage to the bands themselves)

  • Downfall of Gaia/In the Hearts of Emperors. I've been a loyal follower of Donwfall of Gaia's neocrust since their first instalments. Their side in this split is extraordinary, these German punks manage to raise their sound to a new level of darkness and raw intensity, brutal blackened neocrust in uppercase. Though every second of their side is excellent I have to particularly praise the very fast passages with black metal melodic riffs, wow, go for it.
  • Axidance/Gattaca, split 2012 Some years ago I wouldn't have expected so many excellent, social aware bands hailing from Russia. Not that I have any sort of distrust in the music skills of the slavic people, it's that sadly enough in Russia most of the rebellious subculture seems to be on the far right... Hopefully things have been changing very fast in the last few years, and a whole social aware scene has developed almost from scratch (thanks among others to What we feel and this blog.
    Axidance are part of this new scene, and play top notch blackened neocrust, long songs, slow parts that give way to very fast blackmetalesque sections. Maybe the Czech guys that make up Gattaca (great name for a band, I absolutely love that film) made a mistake doing this split record. Their side (as their previous works) is pretty good (some sort of good old emocrust), but it's outshone by Axidance's geniality.
  • Keny Arkana, "L'esquisse", 2011. Since the first time I listened (and felt deeply touched) by "The Rage", back in 2008, this French lady rapper has been one of my favorite MCs. Her last work not only does live up to its predecessors, I well might say it's even better. Uncompromising lyrics expressed with an almost perfect flow over good and diverse music
  • Decoded Feedback, "Aftermatch", 2010 This came as a wonderful surprise. Decoded Feedback was the band that along with Hocico introduced me to Dark Electronic sounds (aka Terror EBM aka Aggrotech aka Hellektro...) back in 2005, with their albums Phoenix and Combustion being two of my favorite Elektro albums of all times. I thought they had disbanded once and for all in 2006, but to my surprise I found recently that they had released a new album 2 years ago. This new album is quite different from their previous works, quite less aggressive, with some "old school" electronic sound, but it's amazing. One of those few records I can listen non stop from beginning to end and even repeat it.
  • Arma-X, "Anticonstitucional", 2011. This Asturian far left rapper is a secure bet when you seek for excellent social, leftist lyrics. His last work is no exception, on the contrary, it has some of his best tracks to date (El Carrousel, Et in Arcade Ego, Minas y Dinamita...) Essential.
  • Martyrdod, "Paranoia", 2012 One of the best crust records (no neo crust or blackened crust) in years. Pure Scandinavian power in the Skit System vein, as good if not better. The last song is superb.
  • Seeds in Barren Fields, "sounding the siren song in vain", 2011 Goteborg metal at its best, but less melodic and much more black metal influenced than the average Goteborg sound. Technique, fury and attitude (green anarchists). By the way, their name is probably one of the best I've come across in a long time.

    "Sprung from the vegan metal/hardcore act "through the mist of tears", with roots deeply entangled in punk and political hardcore, these seeds are blooming, bursting out into a fully fledged, and raw as hell, metal assault. SEEDS IN BARREN FIELDS engage, with black flags raised, in a battle against religious moral dogma, capitalism, nationalism, consumerism and social control. Promoting values of freedom such as (green) anarchy, animal liberation and gender equality as an alternative to being a part of a lost, scared and disillusioned mankind"

  • Amebix, "Sonic Mass", 2011 Well, to the total disdain of some of the few people reading this, I have to admit that I've never been a huge fan of Amebix. Of course I fully acknowledge their seminal role, but I started to listen to them quite late, and at that time the bands influenced by them seemed much more interesting to me than their "instigators". This said, their new album sounds impressive to me, with really powerful and interesting melodies. I think they should have called it quite properly "The return of the Gods", and it would have not been pretentious at all.

Monday 1 October 2012

Unity, Interception, AOP...

Though I've been familiar with Dynamic Proxies, Interception and AOP (on a theoretical basis and on some of my "toy projects") since a long while, it was last year the first time I applied some of this on a Production project. As we were using Unity as IoC, we decided to leverage its interception capabilities for some apparently trivial stuff. We succeeded obtaining the functionality that we were seeking for, but a few things seemed a bit unclear to me, something I mainly blamed on our very tight schedule that made me read too fast through the extensive Unity documentation and online samples

So when I recently came across this excellent series [1, 2 and 3] by Dino Esposito, I thought it would be a good idea to look back to my previous experience and clarify this all for future projects

First we should note that AOP and Dependency Injection are quite different things, but in the last times, most IoC containers provide some kind of (basic) AoP support (Spring.Net, Castle Windsor, Unity. This support is mainly limited to intercepting method calls to insert there code related to our logging, validation, security... cross cutting concern.

This method interception is achieved at runtime by means of Proxy Objects, that either point to the intercepted instance (composition) or inherit from the class being intercepted. Well, this is common ground to Spring, Castle and Unity, but there are a few things in Unity that can lead to some confusion:

  • At least for version 2.0, Unity is completely independent from Enterprise Library (the only relation now is that both are developed by the Patterns and Practices guys). If you want to use Unity's (soft) flavor of AOP all you need is adding these 3 assemblies to your project:
    • Microsoft.Practices.ServiceLocation
    • Microsoft.Practices.Unity
    • Microsoft.Practices.UnityInterception
  • Unity mainly avoids the term "Proxy", using the "Interceptor" term instead. We don't have a ProxyGenerator class as we have in Castle, but the Intercept class does just that, creates Proxies (interceptors)
  • When intercepting calls with Unity, we create a chain of IInterceptionBehavior objects, containing the additional logic that we are injecting. Castle's equivalent to these behaviors are called IInterceptor.

Unity provides us with 2 types of Composition based proxies (Instance Interceptor). You already have an instance of an Object and will wrap it with a Proxy (Interceptor in Unity's parlance): InterfaceInterceptor and TransparentProxyInterceptor
and one type of Inheritance based Proxy (Type Interceptor): VirtualMethodInterceptor

We can create and use proxies without need of an IoC container, though for production applications aiming for decoupling and extensibility, it's obvious that we should create them through a Container

I'll write down a few samples, just based on what we needed in that project last year. Let's say you have a Data Source that you want to mock somehow. Mainly, first you want to serialize the Data Entities returned by the real DAOs, and then you want to use those serialized entities instead of querying the real DAO's-DataSource.

So, if we want to inject in our real DAOs an behavior that will serialize those entities they are returning. For this, we can wrap our real Dao in a Proxy object, this will call the real Dao to retrieve the real entities (from a DB for example) and then will serialize those entities before returning them to the caller code, that is fully unaware of this added behavior.

We can create the Proxy ourselves (I'm using a Composition based Proxy, that is, an InterfaceInterceptor)

IUserDao userDao = new DBUserDao();
            IUserDao userDaoProxy = Intercept.ThroughProxy<IUserDao>(userDao,
                new InterfaceInterceptor(), new[] { new SaveResultBehavior() }
            );
            var users = userDaoProxy.GetUsers("Asturies");

Obviously, to decouple things we'll want to use an IoC, register the Dao type with it and later on obtain the Dao instance from the Container

var container = new UnityContainer();
            container.AddNewExtension<Interception>();
            container.RegisterType<IUserDao, DBUserDao>(
                new Interceptor<InterfaceInterceptor>(),
                new InterceptionBehavior<SaveResultBehavior>()
            );

            IUserDao userDao = container.Resolve<IUserDao>();
            var users = userDao.GetUsers("Asturies");

The second part, using a MockDao that will just deserialze the previously saved Entities turned quite more interesting, and is the one that last year gave me some problems and made me resort to Castle Dynamic Proxies. The thing is that we don't want (because should be unnecessary) to define MockDao classes. All the behavior we need (find an entity on disk, deserialize and return to us) can be done by the interception code (the IInterceptionBehavior), so no need to define empty MockDao classes. So we want Unity to create a Proxy implementing the necessary I___Dao interface and has the deserialization behavior. The problem stems from the fact that Intercept.ThroughProxy requires us to give it an instance of the class being intercepted, so we would need a MockDao class... Obviously, Inheritance based proxies have the same problem, as the proxy will inheritn from that MockDao class. This problem quite astonished me, as I had previously achieved the intended behavior with Castle Proxies, using CreateInterfaceProxyWithoutTarget

Proxy without target. This one is tricky. You don’t supply target implementation for the interface. Dynamic Proxy generates it for you at runtime, using interceptors to provide behavior for its methods.

At the time we were quite in a rush with that project, so I did not further investigate if there were some quite of equivalent in Unity and just fell down to Castle, but it left me with some bad taste that I've finally cleaned now.

Googling a bit, there are other 2 guys asking just that, the Unity equivalent to Castle's CreateInterfaceProxyWithoutTarget [1] and [2]. Well, there's a (failing) answer to the second question that put me on the right track for this, we have to use NewInstaceWithAdditionalInterfaces and a Casting, just like this:

IUserDao userDao = (IUserDao)(Intercept.NewInstanceWithAdditionalInterfaces<Object>(
                new VirtualMethodInterceptor(),
                new List<IInterceptionBehavior>(){new RetrieveSavedResultBehavior()},
                new List<Type>() { typeof(IUserDao) }
                ));
            var users = userDao.GetUsers("Asturies");

Using the IoC, there's something more we need to take into account. We can't register a Type, cause the interesting thing of all this is that we're not defining those Mock classes, we're letting the Proxy Generator to do that. Hopefully, we can register a Factory (InjectionFactory) that will take care of calling the Proxy Generator (Unity's Intercept class) to create the proxy, something like this:

container.AddNewExtension<Interception>();
            container.RegisterType<IUserDao>(new InjectionFactory(c =>
            {
                return Intercept.NewInstanceWithAdditionalInterfaces%lt;Object>(
                    new VirtualMethodInterceptor(),
                    new List<IInterceptionBehavior>() { new RetrieveSavedResultBehavior() },
                    new List<Type>() { typeof(IUserDao) }
                );
            }));

            IUserDao userDao = container.Resolve<IUserDao>();

You can download the whole sample from here

In these samples I've been using the simplest form of interception, we just intercept all the methods for one given object (in that case it's just what I needed, serializing/deserializing all the calls on that Dao). However, in many occasions we'll need to discriminate, some of the methods will need that added behavior and others not. One solution here is continue to intercept all calls, and let the code in the Behavior class decide if that method needs the extra functionality or if it just should let the call go through without any further action). Well, that's one options, but in those cases what we really should use is Policy Injection with its mapping rules and call handlers (as explained by Dino Espósito in the third article in the series).

As we saw last month, all intercepted methods on the target object will execute according to the logic expressed in the Invoke method of the behavior object. The basic interception API doesn’t provide you with the ability to distinguish between methods and doesn’t support specific matching rules. To get this, you may resort to the policy injection API.

To wrap-up, I'd like to point out that Microsoft seems to refer to AOP as "Policy Injection" which I think adds some confusion. Seems like I'm not the only one with this impression

When asked why the name Policy Injection and not AOP, Ed answers:
... the reality is most of our customers have not heard of AOP or AOSD. Please put yourself in their shoes for a second. We wanted a name that was reflective of the use and benefit the block brings, rather than using an unfamiliar term that only the exceptions understand. We also wanted to have no implicit expectations on the design that may be inherited from AO solutions.
So Policy Injection is AOP, or at least a part of it. The reason why Microsoft did not choose the term AOP seems to be that AOP could have been perceived as a boring academic concept, which was fashionable in the .NET community about year 2003.