Isolated calls of dynamically loaded assemblies

Definition of the issue:

In one of the project I’m currently working on, I need to be able to call a function from an assembly that will be provided at run time.
One of the major requirement I have is to have a clear isolation of the call with a minimum of configuration.
The second requirement is to be able to provide a regular configuration file on my callee assembly in order for a lambda developer to implement a WCF call in that assembly using regular config files.
Meaning they should be able to write a simple .NET Assembly referencing other assembly and making use of a config file and all that should work.

There is no particular performance requirement. It is left to the developper of the callee assembly to manage this issue. It will be up to him to dispatch and manage threads if needed.

My first solution:

The easiest solution I found was to create a new app domain. To load the callee assembly in that new domain and to execute the call there. This gave me the isolation level I was needing.

My calling class looks like this

//Setting the new app domaine configuration
AppDomainSetup appDomainSetup = new AppDomainSetup();
appDomainSetup.ConfigurationFile = "Custom.Config"; //The config file of my calle assembly
appDomainSetup.ApplicationName = "ProxyName"; //Just to be cleaner
appDomainSetup.ApplicationBase = @"D:\dev\Dummy\ConsoleApplication2\ProxyComponent\bin\Debug\"; //Where is my calee assembly
//Creating a new app domain
AppDomain domain = AppDomain.CreateDomain("IsolatedDomain", null, appDomainSetup);
//My parameters
string dllFilePath = @"D:\dev\Dummy\ConsoleApplication2\ProxyComponent\bin\Debug\ProxyComponent.dll";
string proxyFullName = "ProxyComponent.Proxy";
//Loading my assembly in my new app domaine
IScheduler myProxy = (IScheduler)domain.CreateInstanceFromAndUnwrap(dllFilePath, proxyFullName);
//Executing my call on the new app domain

My ProxyComponent.Proxy class looks like this

<?xml version="1.0" encoding="utf-8"?>
<add key="Key01" value="Value01"/>

The only shared assembly bet ween the callee and the caller is the assembly that contains the IScheduler interface.

public interface IScheduler
string GetSettingValue(string key);

This could have been avoided using DLR and Dynamic. I’ll try to work on this in a near future.

Is there something wrong with Enum.ToString()?

This morning, while we where working on the creation of Key/Value pair table containing different kind of entities one of my senior team meber ran into an “Exotic” behavior.
The key of our table is a string build on the composition of the entity Id and the entity type. The entity type is simply an enum value converted to a string.

This looked like this:

_ToString = string.Format("[{0}/{1}]", id, contactType.ToString());

contactType is here the enum variable. Nothing really fancy or complicate untill we ran the performance monitor on it.

We saw that this line, according to its simplicity was taken too much time to process.

We have to perform this operation for millions of records and every millisecond counts.

At first sight I though it was the string.Format() that was taking all the processing and we tried a quick optimization.

_ToString = "[" + id + "/" + contactType.ToString() + "]";

Same result. I had to face it, the ToString() of the enum variable was taking most of the processing.

The number of entries in enum being short, we tried the following code:

switch (contactType)
case ContactTypeEnum.Undefined:
_ToString = "[" + id + "/Undefined]";
case ContactTypeEnum.Organisation:
_ToString = "[" + id + "/Organisation]";
case ContactTypeEnum.NaturalPerson:
_ToString = "[" + id + "/NaturalPerson]";
case ContactTypeEnum.OrganisationContact:
_ToString = "[" + id + "/OrganisationContact]";
throw new ArgumentOutOfRangeException("contactType");

The difference was impressive. This long piece of code is almost 8 time faster.

The following image gives the performance numbers of each of the code block.

Enum.ToString performance capture

Enterprise, System, Software, Application, Technical Architect, what is my role?

Enterprise, System, Software, Application Architect, just pick one.

I’ve been on assignment building a strong commercial relationship with my current customer for several years now.
Interesting projects, nice environment, smart and fun colleagues, everything is available for me to stay happy and work there ever after… but… Well, I am starting to have the need to meet new people and face new challenges.
Of course I do not want to jeopardize my relation with my current customer, but I need to evolve. I need to get out of my comfort zone and start something fresh.

This is why I have decided to update my resume and to investigate different opportunities that could be available on the IT market.
First think first. What am I? What is my role? On my current assignment I ‘m called a “Technical Architect”. Yeah!!… but what does it means…
This title is not available anywhere else. I checked on IEEE, Wikipedia, googled about it… there is no Technical Architect Role definition or at least I could not find one…

As a “Technical Architect” what are my duties:

Team coordination: Coordinate is not really the term. Lead and coach seems more appropriate.
I guide the team on the activities we should conduct in order to deliver and act as scrum master.
I advice the project manager on what is achievable and what is not and if I feel a potential risk on the project.

Functional analysis: I do not conduct the functional analysis but I review it. I did it on the past but in Belgium you need to speak both national language to work on this area and unfortunately, I don’t.
I Review the functional analysis for consistency and feasibility. I challenge the content as well. I will probably not let build a space ship to cross the street.

Technical Design and Architecture: I have an analytical mind. I like to conceptualize and modelize stuff. I enjoy putting structure and explain difficult concept.
If I manage to make myself understood then I can say I really have understood what I was talking about. This is probably the activity I’m better at.

Development: I love to code and unfortunately this is something I do not do enough. I’m told to be not to bad at that and In order to stay up to date I try to do my TDD Kata at least three or four times a week.
I have a pluralsight subscription and I complete at least one training every two week. This is a must have for any developer.
I try to stay sharp or Csharp to be precise and pluralsight is a good way for this..

Coaching: This is also something I like to do. I like to share knowledge. On my current assignment I try to do this on a daily basis.
I launch topics I read about. I advice on training people should follow. I share my tips I tricks and I try to understand what the others are doing.
If I manage to bring the level of expertise of the team I’m working with to a higher level of expertise then this is already a success for the project.

Day to day management and client facing: I’m also organizing the deliveries and the operational hand over. Coordinating the testing and the delivering is also part of my duties.

I perform other activities but those are most probably the most frequent ones.

Now let see what title I can find to match those duties. l find on Wikipedia the following definitions:

Enterprise architect: handles the interaction between the business and IT sides of an organization and is principally involved with determining the AS-IS and TO-BE states from a business and IT process perspective.

Solution Architect: The Solutions Architect is responsible for the development of the overall vision that underlies the projected solution and transforms that vision through execution into the solution. Solution Architects in large organizations often act as the bridge between Enterprise Architects and Application Architects.

Application Architect: An application architect works with a single software application. This may be a full- or a part-time role. The application architect is almost always an active software developer.

The following tables indicates many of their differences

Architect Type Strategic Thinking System Interactions Communication Design
Enterprise Architect Across Projects Highly Abstracted Across Organization Minimal, High Level
Solution Architect Focused on solution Very Detailed Multiple Teams Detailed
Application Architect Component re-use, maintainability Centered on single Application Single Project Very Detailed

According to those definitions and tables, I must probably seat somewhere between the Solution architect and the application architect but closer to this last one.

When not asking the right question can lead to stupid answer

I’m currently working on a project where the long ago choice to use SOAP as standard for all our services is making people stop thinking. I’m convincing that reconsidering technical choice when a valid and valuable context arises is an attitude that should be natural for all architects. But in the reality, it is not… Or maybe they might not be architects.

I’m the kind of guy who prefer understand the “why” instead of learning the “what to do”. I’m an architect and by definition I think ahead, and I design a minimum up front. If I found something illogical…Well I will challenge it.

Let me be more explicit on this. I need to build some services for a mobile middle ware. Those services are DATA services. They only provide CRUD operation on some entities that will made available to a mobile client. This mobile middle ware supports 4 kind of communication technologies (SOAP,SAP RFC, REST, SQL). It supports them in the same extend. Meaning it will not be able to support the full extent of features (transaction, security, reliability…) that each of those technologies support. It supports the bare minimum.

Because we want to be SOA……. (Yeah!!!!) We have to use SOAP…(Yeah… What a shortcut…). Fine we are building DATA Services, and we need to use the more complex protocol for our services… This is a non-sense. Those services are meant only for this middle ware. Their contracts are tailored for the middle ware. There is no possibility for them to be used by something else than the middle ware and we are choosing the most complex and universal protocol….

Why not considering something simpler like REST and a simple and optimized XML message? “Because this is not a company standard!”… What can I reply to this? I believe that this choice can make sense (Yes I say can make sense J) when the services you are building is meant to be a companywide service and used by different platform. But then it needs to be advertised like this. This is not our case… We are mainly providing services that list all instances of some entities. Those services will return hundreds of thousands of records. Let’s reconsider that companywide standard for this case and use it properly. Let’s build something which our customer will take advantage of for once. Let’s be “Thinker” and not follower this time.

Structural domain entities or context oriented domain entities?

I’m working on a project that has been going on for couple of years now. We manage to deliver a solid and nice application composed of several building blocks. Those blocks go from front end web application to mobile disconnected application all serviced by Web services components.

This web service components are build on top of a DDD Architecture. The challenges we are facing now is that our Domain entities were design based on a structural approach and our domain entities becomes quite complex. For example we have a project aggregate root made of work package entities and them self made of activity entities.

At the begining of project we had only a limited kind of project and activity type. The scope of the solution is constantly increasing and we are now having far more type of project and activities. Those domain entities become bigger and we have a lot behaviour which are partially overlapping each other and it is hard now to change one type specific behaviour without impacting the other inherited.

In my quest to make all those complex entities more manageable and less interdependent. I’m trying to restructure them in bounded context and to organize them in context oriented entities. Meaning I’m trying to build entities which are meant to support some dedicated context and processes. Instead of having a domain entity model that looks like my database model. Their are now behavioural oriented not structural oriented.

By doing this I’m ending up with far more aggregate roots but which are simplier and more maintainable. The repository are also now more complex as well. Before we had almost a one to one relation between a domain entity and the database model. It is not the case any more. We may end up by reading five different table to build a simple domain entity. I can live with that after all this is what the repository is there for. Serialiaze and deserialiez my domain entities.

The major issue i still have to face now is the resistance of the development team to work this way. They have the feeling that we will end up by duplicating a lot of business rules. I tried to show them and explain them that if a business rules needs to be duplicated they we might have to refactor the bounded context cause they might not be that bounded… But that did not do the trick :(

Has anyone gone throug the same experience? I would appreciate any advice on this.