Barcelona Summary
I wanted to blog a bit more, but I got too wrapped up in playing with technology while at the event (I also enjoyed the beer and food a bit too much in the evenings). I was really interested in the JSON message format, and I played around with getting an AJAX based tic-tac-toe implementation working with a WCF service using the new webHttpBinding. (http://dotnetslackers.com/articles/ajax/JSON-EnabledWCFServicesInASPNET35.aspx)
I had some real nice sessions, some of them actually relevant to the stuff that I'm busy with now! Here's a list of the sessions that I found really interesting:
Pat Helland - The Irresistible Forces Meet the Moveable Objects http://blogs.msdn.com/pathelland/
This session provided insight on the way we need to change the way we develop systems, due to the way CPUs are changing (more CPUs on the same board, instead of faster CPUs - due to heat), the cost associated with huge datacenters and their respective backup locations. My take away from this session is that it's sometime all right for a system in a distributed architecture to make a mistake (like saying a book is available when it isn't) and correcting it when it finds out, instead of trying to "code in the now" - which implicitly means distributed transactions.
Udi Dahan- Designing High Performance, Persistent Domain Models http://udidahan.weblogs.us/
I enjoyed Udi's session, because he approaches complex problems by doing simple OO magic. It was nice seeing some real code, using dependency injection, etc, instead of code with the sole purpose of demonstrating new tech.
Stefan Schackow - Building Highly Scalable ASP.NET Web Sites by Exploiting Asynchronous Programming Models
This was real relevant to what we are busy with at the moment. I've read about the async=true directive before, but this was a real practical and thorough presentation on using asynchronous patterns in asp.net. Stefan took care to point out some pitfalls and weirdness to expect when implementing async pages.
Justin Smith - Windows Communication Foundation Performance (interactive session)
This was the most relevant session that I attended. Justin went through all the areas that impacts performance in WCF. For each area, he showed us some findings from performance testing that they performed. He spoke about the effect of bindings, message format and serializers on performance.
He also highlighted the fact that ChannelFactory proxies have less overhead than generated proxies. He wrapped up with some common pitfalls to watch out for, in particular not closing your channels on the client as well as regeneration of the proxy for each call with the channelfactory, instead of reusing it. Unfortunately we are in a situation where we inject custom headers into our messages using behaviors, so it overcomplicates reusing the same proxy for different requests.
Because it was an interactive session, I also got to ask him some questions regarding using the async pattern on the client when using ChannelFactory. It turns out all you have to do is to have the correct methods on your contract, you don't need to implement them on your service, but it will allow you to use the proxy asynchronously.
Another question I had was whether it's actually useful to implement the async pattern on a service which needs to make a call to another service. Meaning, if you have service A, which calls service B, is it still useful to make an async call from service A to service B. The answer is that it's only useful if service A does not return a value. If it returns a value, there are no gains in making the call asynchronous, because the service needs to return a value in any case, so there is no gain in freeing the thread (except if you have to do multiple operations in parallel). I asked him about the performance win that you can gain from using the JSON message format between services, which is substantial. Although, I'm sure a lot of ws-* fanatics will not be too happy with that solution.
I hope I'm in a position to attend teched again next year, because I feel that I left the conference as a better developer.
 Teched Barcelona
Teched BarcelonaI arrived in Barcelona on Sunday for Teched Europe. This is the first time that I've set foot on mainland Europe! The city is quite nice, and the weather is much better than dreary London.
It's my first time attending teched and I must say that I'm really impressed. The technical content is engaging, the infrastructure is seamless and there's always food!
I'm trying to mix and match the sessions that I attend so that I can get a good variation of new tech, architectural sessions and more practial knowledge that I can use right away.
So far the sessions I enjoyed the most were Pat Helland's talk on transactions and Luca Bolognese's talk on LINQ to SQL.
Pat was the guy behind MSDTC and now proclaims himself an Apostate of the technology. In fact, in the session he proclaimed that: "Distributed transactions suck". He took us through managing of transactions in a distributed computing environment using asynchronous messaging patterns, for example idempotence. It reminded me a lot of the concepts in the book called Software fortresses by Roger Sessions.
Luca is a real funny guy, but what impressed me the most about his talk was the simplicity of the demo. I've done some work with the framework before, but he got my colleagues real fired up about it, as I'm sure he did with a lot of people.
Let's hope the rest of the week is as informative it's been thus far...
 an Anonymous delegate based nmock action
I always find it tiring writing IAction implementations for nmock2 tests, so I wrote the following thingy, which basically allows you to specify anonymous delegates for an action. public delegate void ActionPerformer(Invocation invocation);
public class DelegateAction : IAction { private readonly ActionPerformer _actionPerformer; private readonly string _actionDescription; public DelegateAction(ActionPerformer actionPerformer, string actionDescription) { _actionPerformer = actionPerformer; _actionDescription = actionDescription; } public void Invoke(Invocation invocation) { _actionPerformer(invocation); } public void DescribeTo(TextWriter writer) { writer.Write(_actionDescription); } }
You use it as such:
Expect.Once.On(_scheduler).Method("GetNext").WithNoArguments().Will(new DelegateAction(delegate(Invocation invocation) { //whatever you want to do - even asserts invocation.Result = whateveryou want to return, even variables before this statement; }, "Whatvever you are performing with the action"));
 Blogging again
Wow, I'm amazed that my blog hasn't been removed from the site.
I'd like to get started again, because it seems that I might be going to some interesting conferences in the near future, including tech-ed europe 2007 in Barcelona.
At the moment I'm working for a software consultancy company in London using netfx3 technologies like WCF and WF using agile methodologies. The project is due for a next phase and I'd like to introduce a federated security implementation as well as rethinking the stuff we exposed as services.
I'll try and post some WCF related stuff as I stumble across it.
<shamelessRecruiting>The company I'm working for is always looking for talented .Net devs, and they are willing to sponsor ZA candidates for a work permit as well as assist with relocation. So if you are interested in coming to the U.K, send your CV to hendrik@novarank.com </shamelessRecruiting>
 Execute a child activity and wait for the results
I came into a situation where I had to selectively
execute a child activity. I wanted the activity to execute it's first child,
wait for the results and then based on those results execute the next child.
The reason for this was that I wanted to write an Ifelse activity which takes
activities as conditions (Instead of making my business user write code for code
conditions) and based on the conditions results execute the rest of the branch.
I'll upload the complete IfElseActivity ASAP.
Step 1:
In order to execute a child activity, the parent activity has to implement
the IActivityEventListener<ActivityExecutionStatusChangedEventArgs>
interface. This enables it to subscribe to execution events
executed in contexts spawned by the parent. This post gives some insight on
contexts: http://blogs.msdn.com/advancedworkflow/archive/2006/03/21/557121.aspx
Step 2:
protected override ActivityExecutionStatus Execute(ActivityExecutionContext
executionContext) { //Spawn
the context (Execution sphere for your child activity) ActivityExecutionContext context =
executionContext.ExecutionContextManager.CreateExecutionContext(EnabledActivities[theChildIndex]); //Register to get an event on this activity if the child
activity's status is set to closed context.Activity.RegisterForStatusChange(ClosedEvent, this); //Execute the root activity of the context context.ExecuteActivity(context.Activity); return ActivityExecutionStatus.Executing; //Important to return Executing because the child will only
execute after this method has finished }
You can only spawn an ActivityExecutionContext for direct
children on the container activity.
Step 3:
In the OnEvent method which was implemented from the
IActivityEventListener interface, we do the following:
void IActivityEventListener<ActivityExecutionStatusChangedEventArgs>.OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e) { if (null == sender) throw new ArgumentNullException("sender"); if (null == e) throw new ArgumentException("e");
//This cis the spawned context with the child activity as the root ActivityExecutionContext context = sender as ActivityExecutionContext;
if (null == context) throw new ArgumentException("The sender must be an ActivityExecutionContext", "sender");
//This event handler will be triggered for every subscribed status change if (e.ExecutionStatus == ActivityExecutionStatus.Closed) { //get a reference to the root activity of the context (Your child activity) MyActivity myActivity = e.Activity as myActivity; //Do whatever you want to do with the activity - something more meaningful as this :) if (myActivity.Bla == "Blie") { Console.WriteLine("Bla was Blie"); }
//Ensure that this activity finishes executing and that the child activity is closed e.Activity.UnregisterForStatusChange(ClosedEvent, this); ActivityExecutionContextManager manager = context.ExecutionContextManager; manager.CompleteExecutionContext(manager.GetExecutionContext(e.Activity)); context.CloseActivity(); } }
Reasons to do this would be to execute a child activity more
than once, or as in my scenarrio to provide an ifelse branch with activities as
the condition.
powered by IMHO 1.3
 Custom Windows Workflow Foundation IfElseActivity
My requirement for an IfElseActivity was for non coders to use it. Normally an IfElse activity will work based on a Code condition which is specified with code on the workflow.
We allow for business users to manage subsets of systems using an embedded workflow editor we provide for their use. Obviously we can't tell our business user to "just learn some simple csharp".. I wanted to have an IfElseActivity where you can use activities with "return values" as checks on the IfElse branch, meaning the user will drag on an IfElse activity and on the one branch drag on other special activities which will determine whether the branch should be executed.
I ended up writing an IfElseActivity that looks like this:

Each branch contains two activities, a condition preview activity and an execution block activity. To implement a new check, implement from the IConditionActivity in the project which exposes an Evaluation property and a Negated property.
The IfElseActivity will execute your check and then decide whether it will continue to the next check based on the Evaluation property you implemented. All the checks associated with the branch's condition preview needs to pass before the branch will execute. You can also negate the check, meaning the check needs to return false in order for it to pass.
You can then proceed in dragging the activities you want to execute in the branch onto the Execution activity. I did this for branch 1 with a code activity. If the first branch does not pass, it will proceed to the next branch. You can also have more than two branches.
Download the solution and have a look: http://novarank.com/customifelse.zip
[Update:] You need to install netfx3 and the latest version of vs.net extensions for windows workflow.
 Exposing JARpackaged classes to jsp files in Oracle 10g
In my previous post I conveyed how to enable a folder in your Oracle application server to serve JSP's. In this post, I assume that you've already enabled your directory and have tested a jsp file successfully.
Normally you'd want to reference external functionality in your JSP files, like external classes packaged in JAR files.
Luckily, this is very easy. In your Jserv conf directory (Jserv is to allow apache to load Java files like jsp and java servlets), which will normally be in the <Oracle_Home>\Apache\Jserv\conf, you'll find a jserv.properties file.
Open this properties file and include a wrapper.classpath statement in order to allow the apache service to find and load the .jar file and it's contained classes: wrapper.classpath=<ThePathToYourJARFile>
You can then use the packaged classes in your JSP pages/Java servlets after you've referenced the correct packages.
 web development puzzles
I stumbled onto 2 weird web development thingy majigs today. Nothing awe inspiring, but here goes....
first:
When populating options into a dropdown on the client-side dynamically, I got an invalid argument error. I couldn't figure it out. I have done this before and I double checked the code in MSDN.
It turns out that I got the sequence wrong. You shouldn't create the option, set it's properties and then add it to the dropdown. You should create the option, add it to the dropdown's options collection, then set the properties of the option (value and innerText). weird....
secondly:
When setting the .Text property of an asp.net password textbox (a textbox with it's TextMode property set to Password) on the server side, on the client-side it remains empty. I've seen several weird forms in the past when it comes to password editing in your profile, so I decided to do a quick spike test. It turns out that this is by design (which makes sense), because it wouldn't be secure to send the value back to the browser, even if it's hashed, seeing that any person can then view the source of the page.. So you have to design the form around this fact.
 templated custom controls in asp.net
Recently, I had to write a templated databound custom control in asp.net.
The reason for this is that we wanted a control which we could reuse throughout the site, and it had toe be very flexible. It needed to have paging capabilities (with completely customized look + feel), searching, sorting and alphabetical filtering.
All of these should also be able to be hidden, based on attributes on the control. Since non of the built-in controls provide this functionality, we had to go the custom control route.
I found a lot of helpful links on the web, but non of them exactly what I wanted. I decided to write a wrapper object to a repeater. To solve the problem in regards of retaining the template functionality of the repeater, I decided to use “proxy properties” on my custom class, effectively passing my custom class' template to my contained repeater.
My custom class had a private variable of type ITemplate and a corresponding property:
private ITemplate itemTemplate = null;
The property has an attribute associated which specifies that the property is a TemplateContainer property of type RepeaterItem.
[ PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(RepeaterItem)) ] public ITemplate ItemTemplate { get { return itemTemplate; } set { itemTemplate = value; } }
Then, when the repeater is initialized, we set the corresponding template property to our properties value:
if(ItemTemplate != null) { innerRepeater.ItemTemplate = ItemTemplate; }
Here's some links on authoring custom templated data bound controls:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcustomizingcontrolswithtemplates.asp
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdatalist.aspx
http://msdn.microsoft.com/asp.net/using/building/webcontrols/default.aspx?pull=/library/en-us/dnaspp/html/databoundtemplatedcontrols.asp
 Another access denied error
I received an interesting error when trying to debug a web project of mine.
The error read:
Configuration error - access to myassembly.dll denied.
The error then shows you a line in your web.config file.
I started getting this problem on a regular basis. Even ending the asp.net worker process and restarting vs.net didn't resolve it. I had to restart my PC every time.
After some intense searching on the web (believe it or not, access denied is quite a common problem), I stumbled onto this link:
http://support.microsoft.com/default.aspx?scid=kb;en-us;329065
Basically what happens is that the indexing server puts your dll file into it's cache, which puts a lock on your file. You have to stop your indexing service to stop it from happening. If it happens to be a production server, you'll have to exclude the temporary asp.net files directory from your index.
interesting...
 over specifying functionality
Something I've seen many a times when developing or managing a project is that a big danger is over specifying functionality.
Developing a spec is something that takes a lot of time, and it removes a lot of the flexibility needed for delivering a successful project.
Don't get me wrong, a spec is definitely needed, but it must be flexible. It's almost impossible to cater for everything in a spec, so if you rely only on the spec, problems will occur, and your whole project plan will be no good.
You need a spec for communication with the client, but I've never seen a project where a spec was fully sufficient in alleviating scope creep. So instead of trying to prevent any scope creep from occurring and alienating your client, you should try to use alternative methods to accommodate the scope creep.
A nice way of saving time on mammoth specifications which is open for interpretation problems, you should spend some of the time to set up a list of testing procedures which will prove that the functionality is hitting the target. And you need to be flexible in this. It's necessary to provide an over all specification and testing procedures before hand. It's also very important to have a solid design and architecture plan. But you need to be flexible and cater for some extra time during the project for specifications that needs to be done just before developing an item.
You always know about more factors just before developing a piece of functionality than at the conceptualization phase, so the chance is that the specification that you provide for the functionality will be more spot on. You will also then be able to provide a better test-plan for that piece of code.
There are a lot of ways for developing and managing project. So I'm not saying that this post applies to everyone. I feel you shouldn't try to stick to one methodology, but try and take some from the several methodologies and use what works best for you and the project you're dealing with.
 enabling asp pages in windows 2003
We have a legacy asp application we use to track our bugs.
When I tried to install it on our Windows 2003 server, I couldn't get the asp pages to run. I knew this was due to the fact that MS disables almost everything by default on Windows 2003.
To enable it you have to open IIS and click on Web service extensions. Here you can right-click on Active Server Pages and click on allow.
 New project
I haven't posted anything in a while, the reason for this is due to the fact that I'm busy with a new project.
Our team has set up in new offices and everyone is up and running. Last week was still a bit chaotic, since I had to develop a POC for an oracle app server integration, while still giving guidance to the team members.
We're only starting to be productive now, and I'm really starting to enjoy the project. We've done some fun stuff, including providers for our db layer and some really interesting OOP designs.
I'll post some info regarding the more technical aspects of the project as I get some time.
 New offices
Moving into new offices are never easy, but I must admit that I was totally unprepared for this experience.
We ordered 3 new pc's, one of them our development server. We specified that we wanted Seagate hard drives and not Maxtor hard drives, but apparently hardware people always knows what's best.
So after setting up our pc's, we found out that the wrong hard drives were installed. After this, we had to call up the hardware guys and let them install Seagate hard drives (we did this to keep our network admin sane - he hates Maxtor), this meant we had to install everything from scratch, never fun.
We decided to make our new network totally wireless - who needs the hassle of wires? It's now almost 8 hours later, and I still haven't managed to get a pc onto the wireless network. All the clients can detect my wireless network, but as soon as I try to join them to the network, Windows XP and Windows Server 2003 freeze.
So now I'm busy with a hopeless search for better drivers.
On top of all that my laptop is acting up and blue-screening me all the time and my Oracle AS installation that took me a while to figure out isn't working anymore. It decided that the password that I wrote down and used several times isn't valid anymore.
Now that I've got that out of my system, I'm going back in again....
 Extreme programming
I've only recently started research on this subject.
It's one of those areas that I always knew I had to go read up on, but never did.
We're currently gearing up for a long awaited project, where I'll be wearing several hats - the combination of which is definitely not recommended by MSF. This also the reason for my blogging abstinence. If anyone noticed...
This project is the perfect candidate to use the extreme programming principles. The xp site is very useful, it contains images which guides you through the principles.
We are also going to use unit testing in the business layer and for the repetitive and high risk asp.net areas. We're going to use NUnit (I've played around with this before, but never really actively used it) and NunitASP.
I must say, I'm very excited at the prospect of using the xp methodology, and I hope it solves lots of problems. Some of the main problems which I hope to address with this methodology are:
- The last dash to fix everything at the end (this is the result of the develop first, test later scenario)
- The requirements misinterpretation problem, where at the end of the project the business people are not happy with what they see, and the whole system needs a rework (This can be solved with iterative development and testing - similar to MSF)
I know you'll never get a cure-all methodology, but I like the ideas like pair-programming and collective ownership.

|