June 22, 2009

Simplification of the puzzle prototype

Posted in Web tagged , , , , , , , at 11:36 pm by sagito

As mentioned before, I have been looking for a way of simplifying the puzzle architecture and encapsulate its functionality inside the Piece class. So now, in order to use this architecture, only two things are needed:

  1. Inherit the Piece class
  2. Call the Piece constructor with the Piece name. For example (from within a constructor): public _Default() : base(”Main Page Piece”) {}

Only two steps are required now! The data is automagically filled in by calling the update() function, which searches the whole page for the sections of code, whose name matches the one on the file. For example, if I have an entry “news” in the configuration file and a div called “news” in the .aspx file, then the information will be automatically filled in. The code was largely reduced by using this new technique!

Advertisements

June 20, 2009

The Puzzle Architecture

Posted in Web tagged , , , , at 11:42 am by sagito

Recently I had to develop a large and multidisciplinary web-based software system using ASP.NET and C# for an university course, which consisted in a Decision Support System. The development of this application was carefully planned in the very beginning of the project and was to be developed by a team of 12 students, in which I was included.

However, the application was composed of a large number of small parts which had to be integrated to work as one. As the project’s team leader I knew that the integration would not be as trivial as it should and we decided to start integrating some of the components right away. Truth be told that the integration was very positive because we put everything together from the very beginning. However, some of the features that should have been independent from the others turned out to be mixed in the end, in order to ease the integration of these parts. Although that did not seem to be a problem at the time, this now looks like a big mistake to me while doing the project’s post-mortem.

After reading the “Gang of Four” design pattern books and after having this experience, I decided to do a bit of investigation and try to develop a somehow different type of architecture. A large number of applications today use the concept of “plugins” as a way of extending themselves. Maybe the best example of this would be the Eclipse IDE or even the Mozilla Firefox Browser, which are largely extended by a huge ammount of plugins! However, to apply a plugin to the Eclipse IDE, I need to actually have the base Eclipse application. Same can be applied for Firefox. Plugins, as the name say, just fit into a bigger application and extend their functionality.

So, I intend to build an application that does not have a base. That is, it is composed of completely independent pieces which can be removed or added at any moment. This idea reminds me of a puzzle where a piece fits into some other pieces, but there is not a main piece! Every piece is just like every other piece with the difference that it adds a little bit of colour to the whole thing. Also, it can be removed or added at any moment and when looking at the big picture it won’t affect the rest of the whole puzzle.

Considering that each puzzle piece is now a small piece of software, how would each of the pieces know of the existence of the others? I consider this to be the main problem in this architecture style. My current idea is to implement this communication by using some kind of “hand-shake” XML configuration file that each piece must have and deploy when it is installed. Then, every other piece will attempt to read the file and try to see if it fits within its features and configurations. For example, the main page for a site could integrate a “News” section. This section would be implemented as another piece of the puzzle. So, the “News” piece would give the main page some configuration file, indicating how and where the data could be obtained from in the database (or some other data source, like an external file or some other site).

But now you could think: “Wouldn’t that imply that the main page would already have a space for a news spot?”. Although we could try to make the creation of this space dynamic, my answer is still “Yes, it would”. Because in a puzzle you still need to have a hole in one piece, so that the dent of some other piece can fit in, right? ;P

I will try to develop a system like this in ASP.NET, using C# as the code-behind language. Keep you posted… 😉