Show Blogger Panel Hide Blogger Panel
Alex Yakunin

April 2, 2010

Birth of Xtensive.PnP (patterns and practices)

The time has come :) I'm going to establish Xtensive.PnP (patterns and practices) solution in our repository on this week.

The idea behind this step is to separate use case oriented code to a set of "PnP" assemblies. I have the following layout of this solution in my mind:
  • Xtensive.PnP.dll will contain all the code dependent only on DataObjects.Net
  • Xtensive.PnP.Technology.dll will contain the code dependent on a particular technology, e.g. there must be Xtensive.PnP.AspNetMvc.dll for ASP.NET MVC 2.
So to start using a particular pattern, you must:
  • Add reference to the assembly implementing it
  • Register all the types from either the whole assembly or a particular namespace (if there are several patterns in this assembly) to DomainConfiguration.Types to enable its support.
What project are expected to be there? I imagine the following:
  • Web: helpers related to ASP.NET applications; initially there will be just SessionManager.
  • Wpf: helpers related to WPF applications. We must provide SessionManager analogue there returning Session for the current Window or its part (this is quite desirable in MDI case) and allowing to propagate the changes among them. This part will be based on more advanced WPF sample we're working on.
  • AspNetMvc: helpers related to ASP.NET MVC 2. Shortly I'll describe what I already have in mind here.
  • Wcf: helpers related to WCF. Such types as DisconnectedResult<T> and ModificationSet (from WCF sample) will be there.
  • Localization: reusable types from Localization sample.
  • Security: our security framework. Initially there will be just base types for Principal, User and Role + service managing all of them and a set of helper extension methods to Session object. Likely, ASP.NET Membership Provider will be there as well. ACLs will appear there a bit later - our initial goal is to provide a basic API that can be used.
My further PnP plans include:
  • Tagging: attaching tags to items is one of typical problems developers deal with, and we're going to help you a bit here - by providing a framework for this. The case here is very close to localization: we'll propose a working approach + some helpers (may be, query preprocessor - I'm not sure for now) simplifying usage of this API.
  • Sync: most likely it will be implemented as PnP pattern as well.
  • Undo-redo: "redo" support is already provided - it is our Operations framework used by DisconnectedState. So here we must add undo operations logging support (by nearly the same way) and add few helper types allowing to persist these info for each executed transaction and study it later.
  • Multitenancy: if you're developing a SaaS application, you must think how to scale it up. So this pattern must help to solve this issue. Base tenant type (with arbitrary key), service and Session extensions allowing to specify current tenant, domain module that automatically adds either a reference to tenant type (or its key fields) to the beginning of each primary key and index, query preprocessor automatically injecting tenant-related constraint to any query and service automatically providing Domain for a particular tenant based on its hash is the implementation plan I keep in mind here.
  • Something else? Your ideas are welcome.
I'm going to implement PnP project mainly by my own forces:
  • Although each of these projects seems pretty complex, its complexity is mainly related to design and the way of integration with DO4, but not the amount of code (from this point all the projects must be relatively simple). So it's a good task for framework architect.
  • This might help me to gather more information related to practical usage of DO4.
And, what's more important, I'd like to involve you in this process. Currently I have the following implementation plan:
  • I'll work in 2 week iterations; so almost any of PnP projects will require 2 or 4 weeks.
  • First week in each iteration will be spent on gathering requirements and samples. To maintain a discussion, I'll create a topic in feature requests forum for each feature (PnP project) planned to be implemented in this iteration, where I will describe the features I keep in mind and will discuss the exact implementation with you. I'd be glad to hear any ideas on proposed or additional features.
  • By the end of first week I'll make final decision on actual implementation, as well as on implementation time.
  • The actual work on implementation will be started on the beginning of the second week. If any issues will be faced there, I'll talk about them with you.
  • When feature is implemented, it will immediately appear in the nightly build (possibly, this will be done even earlier). So it will appear in release after some period of testing.
  • Documentation for each feature will be written during next feature's spec. duscussion phase.
Finally, here is my plan for the next 4 weeks:
  • April 5 - April 11: discuss features for Web, AspNetMvc and Localization PnP projects and migrate existing code to PnP solution. The only new project here is AspNetMvc project, so that's why they come together. Goal of this phase is to develop ASP.NET and ASP.NET MVC samples utilizing binding, error handling, versions (optimistic locking), validation, paging and DisconnectedState (e.g. for wizard).
  • April 12 - April 18: implement the decisions.
  • April 19 - April 25: discuss features for Wpf and Wcf projects. I intentionally want to wait with this, since Denis Krjuchkov is working on new WCF sample now. Goal of this phase is to develop N-tier and regular samples utilizing data binding, error handling, versions (optimistic locking), validation, paging and, obviously, DisconnectedState. Likely, we'll start discussing all the stuff here immediately when it's done; moreover, corresponding projects will appear in PnP solution shortly after appearance of new sample. But since I'd like to have a realistic plan, let's schedule this for 3rd week for now. If the time will permit, we'll go faster.
  • April 26 - May 2: implement the decisions.
  • Having this done, I'll switch to Security.
If you have any ideas on possible improvements for the proposed process, feel free to share them in comments.

P.S. It seems I'm the only person @ Xtensive writing absolutely serious posts today. Hopefully, you already have got enough smiles during April Fools' Day :)