When we write web services, we need ways to test them.
Instead of writing an elaborate harness or using curl or wget or some other tool, I discovered that Fiddler can be used to invoke SOAP services, with either a GET or a POST. Fiddler is a great, free tool you might already be using to monitor net traffic. If not, I would highly recommend it.

To use Fiddler to test you service that accepts a POST of param1, here is a quick rundown:

Start Fiddler and go to the Request Builder tab.

image

In this tab, enter your service path.
Note: you can run Visual Studio and grab the (dynamic Cassini) address from there.

Choose the submit type aka verb

image

For a POST type, we have to specify the Header to contain additional info.
viz. Content-type: application/x-www-form-urlencoded

 

image

 

Enter the various parameters to submit to the service in the Request bodyfield.

e.g. for 2 params, with value1 and 2

image

 

Hit the Execute button (in the far top-right) to submit the Request.

I usually choose Tear Off in the Options so that I have a nice little floating window to do my testing.

You can put a debug point in VS and step through the Request if you want.

This post is a slight deviation from software to talk about the very interesting topic of Fractals…

Fractals mean different things to different people and are a very useful tool used in many ways, from tie-dye shirts to Star Wars animations to geographical measurements.

What are fractals?
Fractals are a mathematical construct, depicted as a geometric form that is composed of smaller pieces of itself. Thus it is possible to construct very complex shapes from very elementary ones using duplication.
A good article of fractals can be found at: http://mathworld.wolfram.com/Fractal.html

Benoit Mandelbrot invented the term  fractal, which he depicted using self-similarity and wrote a paper to compute the length of Britain’s coastline, which he depicted as a fractal.
The concept of self-similarity was not new and was around since the 1700s, but Mandelbrot defined it mathematically.
He defined a fractal dimension (figures composed of fractions) and faced opposition from classic mathematicians who were more about lines and curves and integral dimensions (whole parts made of ones and twos and so on).
http://math.bu.edu/DYSYS/chaos-game/node6.html#SECTION00060000000000000000 has a good explanation of this.

Mandelbrot defined a fractal to have the properties of self-similarity, fractal dimension and formation by iteration.What he essentially did was to describe nature in a mathematical form, which had never been done before when math was only applicable to human-made structures like buildings.

His paper was applied by many people to create complex shapes, e.g. artificial mountains were rendered by an animator at LucasFilms, who started with a simple triangle and replicated it multiple times. This started a whole world of realistic animations of natural forms like clouds, waves, etc.
Some practical applications are:
Cell-phone antennas where surface area is maximized by using a fractal shape.
Calculating the surface area of a forest to know how much CO2 it can absorb, which in a study was found to be fractal in nature (pun intended), and has the same form as that of a tree.
Similarly, clouds or oceans can be depicted as fractals and used for predictions.
A heartbeat waveform is apparently a fractal and not a clean sine or square wave. Thus irregular heartbeats can be detected if they don’t exhibit a fractal nature.

Here is a fractal I drew called the Pythagoras Tree, that starts with 1 triangle with 2 half-size triangles at 45 degrees, and that is repeated over.

Hope this opens up the wonderful world of fractals for you…

It’s been a while since I wrote about TFS although a post I made about it 5 years ago is still the most popular post on my blog (weird!), and I’d like to give a plug for a plug-in for TFS called Urban Turtle, that provides SCRUM tools for Agile development. 
The name seems like a play on Tortoise, which provides integration for SVN (a source-control system), and I have this vision of a turtle walking in a city with shades on and a boom-box on it’s shoulder.

The Urban Turtle website is at http://urbanturtle.com/, and it has all the info and videos for you to get started.
Brian Harry of the TFS team has a good post about it here: http://blogs.msdn.com/b/bharry/archive/2011/01/05/urban-turtle-for-scrum-and-tfs.aspx

I am still exploring it, but it seems to have all the features you’d require in a SCRUM tool.

The SCRUM features are available in the Project Portal (website on SharePoint), for easy web-access to all team-members (including clients)

Creating Sprints, for example.

image

image

At work, we use TFS for source control and JIRA for SCRUM, but I don’t like the Printing possibilities of our JIRA setup, and assigning a Task to someone is not easy (because of a clunky interface with the name list).

Let’s see how things are in Urban Turtle land, and I’ll report back if I end up trying it.

We are currently developing an LOB application and one of the screens in Silverlight shows about 20,000 records. When the (Silverlight) client made the domain service call it got back no data. This was because the database calls took a long time and returned many records. This led to problems with RIA services on 2 levels viz. timeouts (the time the call takes to return) and the number of objects returned.
To resolve this, I did the following:

Setting the timeout

To work around the default timeout of 30 secs for RIA services, we need to over-ride the the timeout of the binding for the endpoint at run-time.
This is a simple concept but tricky to implement. The idea is to create a partial class that will complement the DomainContext class auto-generated for the Silverlight client.

To get a handle on this, open the auto-generated file by RIA services during compilation, named [your project].g.cs in a hidden Generate Code folder. To view this, click the Project for your Silverlight client as specified in the RIA services link.

image

Click on the “Show All files” button icon in VS2010 and you will see it.

This file will contain the proxy Domain Context class generated for calling your Domain Service, amongst many other namespaces and classes in that file. Ensure you have the right namespace for this class (it could be confusing) which is essentially the namespace of your Domain Service.

Create a partial class for this Context.
Make a new file and add code similar to the following to it
(replace myns and MyDomainContext with yours, and the required timeout value which I have as 5 minutes)

namespace myns
{
    public sealed partial class MyDomainContext
    {
        partial void OnCreated()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                ((WebDomainClient<MyDomainContext.IMyDomainServiceContract>)this.DomainClient)
                    .ChannelFactory.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
            }
        }
    }
}

 

Add a reference to the web client of Domain Services

image

If the class you added does not compile, check the namespace and the Interface name (from the hidden file for that domain context constructor) and the reference.

Changing the number of objects returned

RIA Services limits the number of objects that can be returned, and this limit can be over-ridden by modifying the service behavior (not the client). This is done by modifying the web.config file to first specify a behavior node

The existence of the behavior node is specified in the services section

<services>
  <service name="myNS.myDomainService" behaviorConfiguration="myDomainService" />
</services>
The actual behavior node is specified in the behaviors node in the system.serviceModel section. Minimize the number of objects returned to suit your needs
<behaviors>
<serviceBehaviors>    
<behavior name="myDomainService">
  <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="true" />
     <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
The above changes should hopefully work for you as well.

While developing Win Phone apps, there are a few options for having a timer. Here are 2 possibilities which provide precision vs. blocking/overhead:

1. Dispatch timer
This is basically a timer that runs on the UI thread and so is precise but can block the UI for any refreshes and activity when it executes, so be careful how/when you use it.

It can be declared and created as:

System.Windows.Threading.DispatcherTimer _predictionTimer = new System.Windows.Threading.DispatcherTimer();

It is set up as: (Do this in the Page loaded event, for the Page)

_predictionTimer.Interval = new TimeSpan(0, 0, TIMER_INTERVAL_SECONDS);
_predictionTimer.Tick += new EventHandler(PredictionTimerEvent);
_predictionTimer.Start();

Note: If you type in the += after the second statement, hitting Tab twice will also generate a callback stub in code (like the one below) for you.

The method to call for the timer event is written as:

void PredictionTimerEvent(object sender, EventArgs e)
{
   …do something…}

2. IDisposible timer

This timer is not very precise, but runs on its own thread and not the UI thread  and so does not block the UI. It does need to switch contexts to do anything with the UI/display. So, you need to get a handle to the UI thread to do anything with the display. I use the MVVM Light Messenger and subscribe to a message that I then send in the timer so I don’t need to do any switching myself.

It is declared as:

        IDisposable _timer;

It is created as: (Do this in the Page loaded event)

if (_timer== null)

{

        IScheduler scheduler = Scheduler.Dispatcher;

    _timer = scheduler.Schedule

                              (new Action<Action<TimeSpan>>TimerInterrupt), 
                    TimeSpan.FromSeconds(TIMER_INTERVAL_SECONDS));

}

The timer event handler is written as:

        void TimerInterrupt(Action<TimeSpan> action)         {             …do something…             action(TimeSpan.FromSeconds(TIMER_INTERVAL_SECONDS));         }

To kill the timer (while navigating away, for e.g.)

_timer.Dispose();  //kill timer

Both of the above essentially do the same thing, but there are different reasons to use either.
Hope that helps.

It is a common scenario to navigate to another URI on a button click. If you have MVVM fully wired up, this command in your View will likely connect to a method in your ViewModel. But the View is the one that can navigate via the NavigationService.

So, this means the ViewModel will need to tell the View to do so. One way to do this is by using the Messaging framework in MVVM Light toolkit.

For e.g. Let’s say your About button needs to go to to the About Uri. The following are the various steps involved.

1. View – Register the Message (to receive) in the source View.
Let’s say we want to look for a Uri and a token of “Navigate”. When it is received, we want to invoke the Navigation. This can be elegantly done with a delegate as follows

Messenger.Default.Register<Uri>(this, "Navigate", 
        (uri) => NavigationService.Navigate(uri));

2. ViewModel – Send this Message from a ViewModel, and MVVM Light will deliver it to the View

private void About(object param)
{
    Uri uri = new Uri("/View/About.xaml", UriKind.Relative);
    Messenger.Default.Send<Uri>(uri, "Navigate"); 
}

This ensures there is no tight coupling between the ViewModel and the View, as the pattern requires.

You can use this pattern even between 2 Views if you need.

Here is a presentation about MVVM and implementing the design pattern with MVVM Light toolkit, that I made to the San Francisco Silverlight User group.

Feel free to use this as you may please.