About Me
I'm a Software Engineer specialized in Microsoft technology with a special interest for Silverlight. Since 2007 I work for Rubicon as a Software Engineer.
|
|
|
Mark Monster
February 8th, 2010
.NET, Patterns, Silverlight, Technology
|
|
In step 2 I explained about the Architecture of MeXperience I had in mind. This article explains the implementation of the pipes and filters pattern to filter the list of experience objects. I will start to tell that my implementation is based on an article from Oren Eini.
The Filter
In MeXperience there are currently only two types of filters: by tag and by role. But I could think about others like a filter by year of experience.
The idea of the filter in the pipes and filters patterns is to have a simple operation, and a lot of combine simple operation in one pipeline make a complex operation.
My filters are also used as objects to represent an item in the TagCloud. This is my base.
public abstract class CloudItem
{
public CloudItem()
{
Weight = 1;
}
public int Weight { get; set; }
public string Name { get; set; }
public abstract IEnumerable<Experience> Filter(IEnumerable<Experience> experiences);
}
Yes I know it’s abstract and there’s no filter implementation. First the signature, there’s an enumeration of experiences coming as input, and there’s an enumeration as output. Let’s see one of the implementations, the of CloudItemTag.
public class CloudItemTag : CloudItem
{
public override IEnumerable<Experience> Filter(IEnumerable<Experience> experiences)
{
foreach (Experience experience in experiences)
{
if (experience.Tags.Where(t => t.Name == Name).Count() > 0)
yield return experience;
}
}
}
The Filter implementation is a simple loop through the experiences, and if the experience corresponds to the filter it will yield return this experience.
You can probably figure out how the CloudItemRole would look like. These filters are simple, let’s combine the pipeline of filters.
The Pipeline
Code explains more than words.
private IEnumerable<Experience> ApplyFilter(IEnumerable<CloudItem> filter)
{
if (filter == null)
return _experiences;
IEnumerable<Experience> current = _experiences;
foreach (CloudItem filterItem in filter)
{
current = filterItem.Filter(current);
}
IEnumerator<Experience> enumerator = current.GetEnumerator();
while (enumerator.MoveNext()) ;
return current;
}
Alright a little bit of explanation. First we start with the list of filters to apply, if the list is null we will not filter, else we will start with chaining all filters together in line 8. After everything is chained together we see all the magic happen in line 11. Until line 11 no filter has been executed, but by iterating through the experiences filter chain we will get a filtered list of experiences.
What’s to come?
There will at least be one more article on the MVVM implementation, but this is how it’s going to look like. Or look at this video.

|
|
|
Mark Monster
January 17th, 2010
.NET, MEF, MVVM, Patterns, Silverlight, Technology
|
|
Besides the purpose of the application itself, I want to make sure I expand my knowledge on Silverlight. This would be especially on the architecture of Silverlight applications.
Architecture - MVVM
I’ve read quite a lot of articles on MVVM, but there weren’t many article series that were as complete as the series on RIA, MEF and MVVM by Shawn Wildermuth (1,2,3,4). I have no intend to write an article or series on MVVM because it’s not really in my fingers yet. But to know more on MVVM please read the fantastic series by Shawn. But then again my intend is to make use of MVVM for MeXperience. The idea is to introduce two ViewModels (please let me know if you’d advice a different setup for ViewModels).
1. The ExperienceFilterViewModel, which supports showing all experience-tags and the ability to form a filter.
2. The ExperienceViewModel, which has control over all experience-parts that are found in the data store and can interact independent from the filter but can have filters applied as well.
Because I chose to use the articles by Shawn as my knowledge base for MVVM, I will make use of the same components: MEF and MVVM Light Toolkit. If you have suggestions for other libraries, I’m interested, but this will be my start.
Architecture – Pipes and Filters
For the purpose of filtering the experience I want to introduce a Pipes and Filters design pattern. I know it’s not absolutely necessary but it makes sense for this purpose.
Architecture – Experience Data Store
It’s very standard to give an application a database for it’s data store. But to be honest there are many situation where a database isn’t the best choice. So in this occasion I think an xml file containing all the experience information will do. For now MeXperience will only be about the presentation of the experience. Maybe some time in the future there will be an application to edit this xml file.
User Interface Components
I’ve searched around the web (being aware of some licenses I won during Silverlight Control Builder Contest) for some User Interface components that could really help implementing the User Interface that I proposed in my prototype in the first part of my series.
 
The first piece of User Interface that I want to cover is the TagCloud. But when I search on Google, I first find a component on Codeplex which has tight integration with WCF, second result is an article from my own hand (July 2008), third is the very nice 3D-Tagcloud by Peter Gerritsen. But in the end all that looks like the best suitable component is the Silverlight Tag Cloud by Infragistics (I’m lucky to have the license).
Further on the experience table-tile-view thingy. After some investigation I’m sure, it’s called a Tile View. Both Infragistics and Telerik have such a control. But because I already found a Tag Cloud by Infragistics I will use the Infragistics controls. Hope this will be a good choice.
|
|
|
Mark Monster
August 22nd, 2008
.NET, AOP, Open Source, Patterns, Technology, Writing
|
|
In June this year an article from my hand about Aspect Oriented Programming (AOP) was published in the Dutch .NET Magazine. It’s about partly about AOP in general and partly about the usage of PostSharp. You can download the article here. You can read about my other articles here and here. Let me know what you thing about the article.
|
|
|
Mark Monster
August 3rd, 2008
.NET, LINQ, Patterns, Silverlight, Technology, Unit Testing
|
|
I did show it in my fourth article about Silverlight Networking, using a functionpointer in a call instead of a return type. This was to get the JavascriptWebResponse back asynchronous.
Working with the Silverlight Networking stack is only possible asynchronously. So we need to provide a callback function that get’s called after execution. All the Silverlight examples I’ve seen have this callback function in the User Interface. But what about all the classes that have their own responsibility that normally live in between the User Interface and the actual call to the Networking stack? I’m sure I don’t want to call the Networking stack right from the UI. I normally have at least one class between the UI and the Network call that does some transformation, preparation and other things. Let’s have a solution that I designed for Silverlight but also works within the full CLR.
Read the rest of this entry »
|
|
|
Mark Monster
March 14th, 2008
.NET, Patterns, Technology, WF
|
|
I think a lot of people don’t like the way Workflow Foundation parameters work. At least I totally dislike it. I don’t want to use an almost untyped (yes, we have object as type) dictionary to read values, and besides why do we need to cast, the types are available. Instead of using basic strings for the parameter naming, I have a different approach. I add an static inner class to the Workflow codebeside.
1 public static class Parameters
2 {
3 public const string BaseFolder = "BaseFolder";
4 public const string AnalysisResult = "AnalysisResult";
5 }
When inside the Parameters class I also have a ReSharper Live Template, stpar:
public const string $ParamName$ = "$ParamName$";
In this example I can use the workflow parameter names by using :
WorkflowName.Parameters.BaseFolder
You now have to add a real C# property with the same name as we have in the Parameters class. But much less work, and through this approach we won’t make that many mistakes in the string-based key.
Besides this the use of a basic Dictionary isn’t that readable too. So I created a somewhat fluent interface for use with Dictionary<TKey,TValue>. So we can create a dictonary more readable than the basic way.
1 FluentDictionary<string, object> parameters = new FluentDictionary<string, object>()
2 .Add(AdministrationAnalysis.Parameters.BaseFolder, @"C:\")
3 .Add(AdministrationAnalysis.Parameters.AnalysisResult, null);
So here’’s the code for the FluentDictionary:
1 public class FluentDictionary<TKey, TValue>
2 {
3 private readonly Dictionary<TKey, TValue> internalDictionary = new Dictionary<TKey, TValue>();
4
5 public FluentDictionary()
6 {
7 }
8
9 public FluentDictionary(Dictionary<TKey, TValue> internalDictionary)
10 {
11 this.internalDictionary = internalDictionary;
12 }
13
14 public Dictionary<TKey, TValue> Dictionary
15 {
16 get { return internalDictionary; }
17 }
18
19 public int Count
20 {
21 get { return internalDictionary.Count; }
22 }
23
24 public FluentDictionary<TKey, TValue> Add(TKey key, TValue value)
25 {
26 internalDictionary.Add(key, value);
27 return this;
28 }
29
30 public void Clear()
31 {
32 internalDictionary.Clear();
33 }
34
35 public bool ContainsKey(TKey key)
36 {
37 return internalDictionary.ContainsKey(key);
38 }
39
40 public bool ContainsValue(TValue value)
41 {
42 return internalDictionary.ContainsValue(value);
43 }
44
45 public TTyped Get<TTyped>(TKey key) where TTyped : TValue
46 {
47 return (TTyped) internalDictionary[key];
48 }
49 }
Let me know if you like this approach or if you have a better solution.
|
|
|
Mark Monster
February 24th, 2008
.NET, IoC, Open Source, Patterns, Technology
|
|
Just about two weeks ago the Microsoft patterns & practices team released a Community Technology Preview of the Unity project. Unity is a lightweight Dependency Injection Container. I’ve just been using it in some very basic scenario’s, so far I like it. It has support for constructor and property injection. But also, a thing not many Dependency Injection container support I think, the ability to do method call injection.
David Hayden has some post on Unity on his blog. But most of all he has created a screencast on Unity, very nice to get an introduction to Unity.
Unity already gets some attention on the Internet. Oren Eini, a guy that’s very experienced on Dependency Injection and did some coding on Castle Windsor another Dependency Injection container, has done a review on Unity.
Let’s wait for the final release. Maybe I will add it to my toolbox. It still seams customers like open source projects from Microsoft more than open source projects from different hand. Maybe I will be able to apply Dependency Injection using Unity at a customers place.
|
|
|
Mark Monster
February 18th, 2008
.NET, IoC, Patterns, Technology
|
|
I haven’t been able to use an IoC container on a real-world project yet. And even though I’ve been doing some research on it, I still have questions regarding IoC container usage.
I always thought about using the Application var for storing the container instance for an ASP.NET application. For other application I would use a static class or static var for the container instance. But thinking about this more and more, I’m not sure about this approach.
What approach do you think is the most sufficient way to share the container instance? Or should we not even share the container instance at all?
|
|
|
Mark Monster
October 6th, 2007
.NET, IoC, Open Source, Patterns, Technology, Writing
|
|
Last month an article from my hand was published in the dutch .NET Magazine.
September 2007: The article I wrote about Dependency Injection is published in .NET Magazine #18. It’s partly about the Dependency Injection concept and how to make use of Dependency Injection using Windsor. The article is in dutch. Download the article.
I’d like to know what everyone thinks about this article. Can you post any comments about it?
Something more about articles from my hand can be read here.
|
|
|
Mark Monster
August 31st, 2007
Books, Patterns, Technology, Unit Testing
|
|
Some time ago I did the technical proofreading of the Manning book PHP in Action by Dagfinn Reiersol. The book is available since the end of June.
During the technical proofreading and even before this during the normal review, I began to really like this book. It’s about building PHP applications, but doesn’t stop after “Hello, world!”. Not it doesn’t stop there at all, PHP in Action covers a lot of practices for building more enterprise like PHP applications and also covers design patterns.
Although I’m not longer a active PHP developer I really thing that every self-respecting php-developer should have this book on his bookshelf.
|
|
|
Mark Monster
August 26th, 2007
.NET, Open Source, Patterns, Technology
|
|
I’ve never been a real fan of Enterprise Library. I’ve used User Interface Process (UIP) Application Block in the past no a few projects. Yes it was something interesting but it has been silent on UIP for a long time. And then there was Web Client Software Factory. But just very recently I came across the blog of Davin Hayden and notices he’s making screencasts about Enterprise Library 3.0. I’ve seen all of them and I am going to like Enterprise Library 3.0 more and more.
Read the rest of this entry »
|
|