Archive for the 'Articles' Category

Configuring virtual development environment

Primary goal for setting virtual development environments on some Hyper-V server is to efficiently test the deliverables of software development project in complex configurations. Efficiently here means that such environment has to enhance software development process at low cost (in money, time and brain damage) and low-friction (seamlessly integrates with the existing processes).

Here’s my checklist for setting up and configuring Virtual development sever (as discussed in this post):

  • Put at least 2GBs of RAM into your server (4GB+ in DualChannel mode is recommended)
  • Optionally add hardware RAID configured for the speed (to be used for VM snapshots and VHD files)
  • Install Windows Server 2008 64 bit and update it to the latest
  • Setup Hyper-V role and configure virtual network (hook it to the real network adapter)
  • Create base virtual machine images for your VM library:
    • Set-up VM with enough RAM (i.e.: at least 512 MBs are recommended for Windows Server 2008) for the guest OS to work
    • Install guest OS on VM (it is faster to capture ISO image, than use CD/DVD drive on the host machine)
    • Install Virtual Machine additions
    • Update VM to the latest
    • Configure to use virtual network and check how VM picks up your DHCP
    • Move the machine to the workgroup (if needed) and optionally configure network discovery
    • Enable Remote Desktop connections
    • Tweak firewall settings to enable File sharing and Remote desktop access
    • Ensure, that VM is accessible via the RDP
    • Install Mozilla Firefox! (you do not want to waste time in fighting the “enhanced Internet Explorer security” while configuring your virtual machines for the specific development roles).
    • Stop the machine and move its image to the VM library (and mark the file as Read-Only, JIC)
  • For every specific VM implementing development role:
    • Create fresh virtual machine from the VM library
    • Add (if needed) enough RAM to VM to support the development role (RTM for the minimal hardware requirements and double the RAM)
    • Change the administrator password to a new one
    • Install and update the software
    • Save a snapshot
    • If the VM represents constantly running development role (i.e.: integration server, SQL server etc), then configure it to start automatically

Common development VM roles that you might have (separation of concerns is applied here for the simplified management):

  • Integration Server (especially for public projects)
  • Database Server (if your application works via the ORM like NHibernate with multiple Database engines, you can cross-test stability and performance by running same integration tests against multiple connection strings)
  • Web Server
  • Distributed Application Servers (if you are developing .NET applications that distribute CPU load between different machines, these could be helpful here)
  • Testing OS Snapshots for you software (one per each OS configuration being tested; especially if you are targeting .NET Mono-enabled operating systems like SUSE SLED)

The checklist could expand later on, since I’ve configured only a couple of development VM servers so far.

Development meets virtualization - installing Windows Server 2008

Let’s go on with the saga of installing and configuring virtualization server for the efficient .NET development.

Primary requirements for such a development server are:

  • 64 bit OS (to utilize more than 4 GBs of RAM and leverage Intel Core 2 CPUs natively)
  • Efficient virtualization (to provide virtual development sandbox environment)
  • Cheap
  • Simple and easy deployment and management

Note, that these requirements are just spawned by the opportunities provided by the new Windows Server 2008 64 bit.

The primary (and, obviously, the only) candidate is Windows Server 2008 64 bit with Hyper-V (btw, it is free for 240 days). This OS has two primary installation options:

Continue reading ‘Development meets virtualization - installing Windows Server 2008′

Linq queries with parameters for your ORM IRepository

Ricardo Cavalcanti has raised question on fluent passing of parameters into the queries encapsulated by the QueryFor (specification) pattern.

Let’s talk about the easiest option of passing parameters, first. It requires no new code at all and is just about chaining queries:

var list = customers
	.Find<ImportantCustomers>()
	.Where(c => c.City == "Ufa");

Where comes from the in line extension method provided by Linq.

However, in certain situations Linq might be not enough. This involves queries that encapsulate come complex business logic or require parameter pre-processing, that you want to hide away.

Continue reading ‘Linq queries with parameters for your ORM IRepository’

Options of separating queries from the ORM Repository

Let’s get back to the discussion from XPO+ORM+IOC series on Implementing ORM-independent Linq queries.

As you can see from the previous post, there are 3 options to abstract away queries in a testable manner (and we will add one theoretical one for the Boo):

1. Put queries right into some domain-specific repository implementation (i.e.: CustomerRepository.FindImportantCustomers) and ask the container about it.

  • Pro: Simple and looks as if there is no logical separation between the repository and queries
  • Con: Low scalability
  • Con: Coupled code that would take some effort to test

2. Put queries into the extensions that use Repository[T].Find method.

  • Pro: A bit more abstraction and testability, than in the previous option
  • Con: Does not make a lot of sense

Continue reading ‘Options of separating queries from the ORM Repository’

Matrix algorithm for rendering XtraLayout designs into Web UI

In the past post on using XtraLayout component by DevExpress as a simple but powerful run-time designer I’ve mentioned rendering designs into Web UI. Here’s simple recipe for the matrix algorithm that is actually used to render XtraLayout-generated form designs in web UI of xLim 2 implementation.

Matrix algorithm for rendering XtraLayout designs into Web UI

This implementation does not require creating groups for every logical section like it has been done in XAF Web UI (and defining some custom orientation direction there) - all group contents sit within one table. Additionally this makes the designs reusable for WPF, Windows.Forms and Silverlight UI rendering (xLim 2 compatible renderer prototypes already exist for the first two).

Basically the UI rendering process happens in two steps. First, we check out every single control in the group and register its coordinates. We are only interested in unique X and Y values at this step.

Then, we count number of unique non-zero X values (that’s the number of columns in our table) and number of unique non-zero Y values (that’s the number of rows in our table). After that we calculate the sizes of these columns and rows (derive them from actual X, Y values). Widths will get sizes in percentages, since normally we want our forms to resize with the browser window.

In second pass we simply render all the controls into cells of the HTML table, while assigning appropriate RowSpan and ColSpan to these cells.

What about extending xLim2 with DSL implementations?

As you can see from the overview article, the minimal development cost of implementing first Domain Specific Language in your solution is:

Cost(generic_DSL_framework) + Cost(specific_DSL_implementation)

where initial cost of generic DSL framework could be close to zero, if you reuse Boo compiler and Rhino.DSL. And the cost of specific DSL implementation normally revolves around writing the appropriate base class with all the syntax specifications.

Now, when you have all this in place, development cost of adding another DSL implementation to your solution (in the optimistic scenario) would just depend on creating yet another base class.

So, if it looks so easy for us to add different Domain Specific Languages to our information management solution, what could we do?

  • DSL for workflow definitions (WWF is just too heavy)
  • DSL for the complex security rules
  • Business rules DSL
  • DSL for specifying Smart Client UI composition for different user roles (composite web UI could reuse this, too)
  • Message routing rules

And remember, that you can compile these DSL implementations to .NET at build-time (this results in easier development) or at run-time (also adds flexibility of run-time configuration of the system).

Given all this efficient flexibility at low development cost (and possibly low maintenance costs), it is no wonder that Boo-based DSLs are being considered for the introduction into the architecture concept of building lightweight extensible information management systems.

Obviously, pros and cons of this step are yet to be researched, but I already could think of some big chunks of code, that could be thrown out of the existing xLim 2 implementations.

Overview of creating custom DSL with Boo

Here’s a short overview of creating custom DSL with Boo. It will serve as technical intro point to the Capture business requirements with Boo-based DSL series.

Basically, when we create custom DSL with Boo, we just add our own steps to the Boo compiler pipeline. These steps inform the compiler how to transform our DSL to valid Boo syntax. Then, the actual compilation steps kick off and compile the results into .NET code.

Since Boo syntax itself is also quite flexible and customizable, later on we can take advantage of this too and make our DSL even more expressive.

One of the transformation approaches (I think Ayende came up with it, although not 100% sure about that) works like this:

Continue reading ‘Overview of creating custom DSL with Boo’