Archive for December, 2007

The worst exception handling

After I’ve finished writing the last post and tried to hit “Post” – BlogJet has pondered a little bit and then popped up window saying “Something has went wrong”.

Well, that’s how you should never write your exception messages (if they ever show up). People do not seem to appreciate when something suddenly goes wrong. It is better for us to see the exact problem and the actions that could be taken to deal with it.

And if the exception/problem takes place for the first time (and thus the application could not tell how to deal with it), then that is one more bug to score. Prompting user with the dialog to review and send the exception details to the issue management system – is the best way to capture it while it is fresh.

People at JetBrains do it all the time. And the people were praising them in weblogs for that (especially when they were contacted back in a couple of hours after submitting some new exception).

Simplified architecture for the xLim 2 solutions

Here’s the simplified logical structure of the xLim 2 solution

Simplified logical organization of xLim 2 solution

Basically that’s your generic Client-Server application that heavily relies on the Inversion of Control/Dependency Injection (and the inherent pluggability because of that) and uses the composite application approach for the client UIs (supported by the distributed model).

Note, that the different types of UIs share the same in this structure. Web UI is just another type of interface, and thus there could be a number of those running around the single server (another way to balance load between the web applications). For some situations the Web UI could be directly coupled with the server (i.e.: when the server is hosted in the IIS), but logically they would stay separate.

Another requirement specifics lies within the extensibility approach common to all business frameworks. That’s the “Don’t Repeat Yourself” principle. Basically if some functionality is going to be reused and it could be efficiently made reusable, then this should be done. For example this could be done with the generic grid handlers or the configurable editor handlers (and then the reflection and configuration could do the rest). Things like controllers and workflows theoretically could be made generic and configurable, but it is just not worth the effort (no, I do not like the Windows Workflow Foundation).

Note that in this scenario there is no Security/Permissions block. That’s because sprinkling the CurrentAccount.IsInRole(“Admin”) or CurrentAccount.For(currentProject).Can(“Print”) all other the UI code is a bit inefficient and complex for my taste (and using policy injection with the castle is still too heavy for the maintenance). So for the core framework all the security is based on the views (although this could be extended).

Views and handlers

The user has access to the pre-configured views that are handled by the appropriate UI handlers in the corresponding UI. So basically if there is message board functionality that is supported by both the Web-UI and desktop UI, then we could configure it only once in the navigation tree. And then the corresponding UI will just pass the configuration to the appropriate handler. And the configuration will explicitly tell the handler how it should behave and look.

Navigation tree, views and handlers in xLim application

So what about the security? Although the communication channels are easy to secure, the client still could be simply hijacked or hacked. From the security point of view, the views just hide illegal actions and options. And the server is actually responsible for enforcing security. Its architecture makes sure that all the critical resources are secure.

Secure extensibility in xLim 2 solutions

Whenever a handler on the client side wants to do something specific with the database or any other resource, it talks either to the data gateway service or its own service implementation.

The data gateway interface handles generic access to the back-end data-store with the basic security checks based on the data schemas. Basically, it answers this question: “Can this user C/R/U/D these records while working with these columns?”. And if he is not allowed to (either the client is hacked, or the malicious component has been installed or the administrator has forgotten to hide that “delete” button from that view), then there will be proper log entry made and the exception will be passed back to the client.

Additionally the gateway supports distributed caching and support for the server-side filtering, grouping and ordering of the dynamically constructed client queries.

If there extra functionality needed on the client side, then here are the primary extension options:

  1. Implement client-side custom handler that uses services/components registered in the kernel
  2. Implement client-side custom handler and the custom client services that talk directly to the data gateway
  3. Implement custom gateway service on the server that talks to the secure server components. It should be exposed and consumed by the custom components and handlers on the client.

In all these three scenarios communication with the data storage (and other critical services) goes only through the secure core API (and it brings all the logging/audits, base security etc along). So, for example, if the audit tables have been explicitly blocked, the extensions will never have access to them.

Note, that the data gateway initially provides only schema-based protection. So if there is need for finer-grain control (like ACL lists) then it would have to be implemented separately. Once this is done, the new functionality could be reused in other services as well.

These logical restrictions are explicitly stated up-front (along with the other requirements). Following them may constrain the development tactics, but the overall development strategy will lead to the efficient and maintainable flexibility.

Note, that this solution definition is not something solid. It constantly evolves as the new requirements are being passed from the customers. Some of those go into the extensions, and some even affect the core. 

Additionally, the actual implementation requirements are too numerous to be listed in this short article. Some other things that are just being considered but nonetheless affect the architecture and development:

  • Possible support for hosting xLim servers natively in Linux environments
  • Possible future support for the Linux desktop clients, etc
  • Using dedicated task engines and notification services for hosting heavy workflows and integration with the 3rd party systems
  • Support for the efficient server load balancing (i.e.: file store could be moved to a separate server, some extension services could host their data on the external repositories, etc)

The latest xLim 2 overview would be published on the Landor Systems web site in the mid January, 2008. The next big post would finally be about the development environment requirements of this xLim solution.

Introduction to the xLim architecture

Note: the old name of the “Lim” has been changed over to the “xLim”. “x” goes for the eXtensible and additionally yields better SEO.

xLim architecture is one of the approaches for building client-server applications that follow the requirements:

  • Small and medium-sized information management solutions.
  • Distributed client-server architecture with the automation engines (either in the server core or separate)
  • Low cost and efficient development, development automation where possible.
  • Rich desktop interface, efficient web interface and the support for other types of interfaces.
  • Existing efficient development ecosystem for the software being produced.
  • Efficient development due to the extensive usage of the proper components and libraries that aid the project.
  • Proper separation of the concerns.
  • Inherent extensibility and modularity (we all are using Inversion of Control and dependency injection, are not we?) for the components and UI elements.
  • Overall configuration over the hard-coding (where it is appropriate).
  • If the user can not break something by configuring it (grid layouts, filters, single editor layouts etc) then this should be handed either to him or the system administrator.
  • Future cross-platform support for the mixed solutions.
  • The solution server should be capable of working in the constrained environment of the IIS hosted applications (with the medium trust).
  • Inherent support for any primary database engine that’s out there, efficient work with it, data caching
  • Authentication, authorization, roles and permissions.
  • Logging and exception handling.
  • Maximum testability (unit tests, integration tests, live validation tests or “sanity checks”).
  • Support for the workflows.
  • Reports, exporting and printing.
  • It should be fun writing it properly.

It is impossible to instantly build the solution that that does all this. But if all these things are considered up-front, it is possible to bend architecture and the logic in the proper ways. And then it will be possible to deliver all that efficiently.

The next  big post on xLim will be about the common development principles and guidelines that were enforced in the Landor Systems in order to allow for the efficient development of the xLim solutions.

How to make DevExpress XPO caching work over the WebServices?

DXperience has a nice feature of the distributed caching built-in. Essentially this allows the cache to be kept on the client, but the server will tell if it could be used or the refresh is needed.

This approach really makes the applications more responsive over the slow channels.

Unfortunately there’s a drawback: the ICacheToCacheCommunicationCore could not be exposed as a WebServices (at least in 7.3.5) due to a number of reasons:

  • dictionary being used for the table ages does not implement IXmlSerializable (I also wonder why it is non-generic yet)
  • DataCacheCookie can not be passed around since it is can not be serialized to XML either (no default ctor).

There are two quick options to deal with this problem:

  • Fix everything in the sources. This option has better performance and it also brings decent TCO with it (DXperience updates would require merging with your own code).  
  • Wrap the cache communications (TableAgeDictionary, DataCacheCookie and all the results) with your own classes that work, pass those over the web service, and then unwrap on the client side. This one just works.

2007-12-28_172819

Here’s the source for the dictionary wrapper: TableAgeWrapper source

PS: Obviously web services are not the best way to handle the communications in the distributed client-server applications. If the software requirements allow that, then the WCF (binary formatter over the tcp channel) should be used. Unfortunately in this situation this was not the case.

Silverlight applications as clients for the distributed computing

That’s a cute article here. Daniel Vaughan has a project that uses browser-hosted Silverlight applications for the web-based grid computing. Basically the Silverlight CLR dynamically loads and executes tasks in the browser, then sends the results back to the server.

Good thing is that this approach makes it is easy to participate in any grid computing project. You just need to have the Silverlight on your machine and visit some web-page.

Bad thing is the same: it is too easy to participate. You could get involved into some computing project without noticing it. Chances are that later on someone would try to offer rich [Whatever]Light content on his web site (i.e.: online games, videos) while additionally running some low-priority tasks in the background. This sounds like “CPU tax” to me.

How to fix issue when CC.NET takes forever to detect changes?

If it takes too much time (or even forever) for your integration server to detect changes in the Subversion repository, try to synchronize time on those servers. It helps.

Does Microsoft plan to implement WPF for SUSE Linux with Gnome?

Microsoft likes to make long well-thought shots.

As Miguel de Icaza points out, there has been some evidence that Microsoft was going to do the language integrated query, long before that happened:

Now that LINQ is out the door, so to speak, I can start focusing my efforts on the next next technology here at Microsoft. Ever since I joined up with the C# team nearly two years ago I’ve been frustrated by my inability to wax poetic about all the goodness we were working on. I was sworn to secrecy. Mum was the word. Perhaps if you were paying attention to the work in C# 2.0 and C-Omega, you may have guessed what was to come. Looking back, it’s easy enough to recognize it in the design of Generics, Iterators and Anonymous methods. The existence of Nullables in there as well should have made it obvious. We were planning ahead for the big pay off, language integrated query.

Similarly it looks like the Windows Presentation Foundation is another Microsoft’s long shot. Reasons:

  • Right now it is totally confusing for people why would anyone ever need to use WPF for line-of-business applications.
  • Yet Microsoft has spent quite some resources to make it done (and do not tell me that they had no analysis and surveys done before that)
  • WPF provides just the right logical separation between the code and the design, to make it usable for creating cross-platform UI applications (While Windows.Forms is really mature, but due to the tight integration into Windows API it is incapable of running natively on Linux platforms).

It may seem that the Mono project would never consider implementing WPF as a priority item, since “only a minority of existing users (Windows.Forms) were willing to rewrite their software to move it to WPF” and the heavy investment is needed (source).

That could be the false impression:

With all this manure around, there’s got to be a pony someplace © Lois McMaster Bujold

There’s at least 35% chance (and it keeps growing) that this would eventually lead to the WPF being implemented on SUSE Linux through the Mono and Gnome. And then someone would notice that Microsoft Expression Blend runs on this “useless” WPF…