Posts By Category

Posts By Date

I would like to show you a project I was working on recently, involving Microsoft Robotics Developer Studio and Lego NXT 2.0 Mindstorms robot. It consists of a DSS service that controls the robot and a WPF application that draws the current state of the sensors of the robot on the screen.

The code is written in C#. The complete source code can be found at http://legobotprima.codeplex.com/

I also have a short YouTube video showing it in action http://www.youtube.com/watch?v=toAZGQVWQqg

Continued...

We are all familiar with using the embedded code block in the MVC framework views. They give us a powerful way to implement the functionality of the views without removing the separation between code and UI. One of the most common use is for generating UI of different controls through the use of HTML helpers.

But there is one significant limitation of that approach. All the code defined in a common embedded code block will be executed during the render stage of the page execution cycle.

But what if you had the following scenario: you register different css files in different parts of the view. Perhaps in different partial views and then you print them in the header section on top of the page. Something that would look like that:

Continued...

This is one Silverlight 4 control I wanted to share. It extends the RichTextBox control in a way to add coloring of HTML and XML tags. The tags are colored as you type. I am planning also to add intellisense. It also has right click menu with Cut, Copy and Paste options for now but more can be added including custom links, activated by contextual position. Below you can see how a typical HTML looks when formatted:

This is the link to a demo page:

http://www.bodurov.com/XmlEditor/

And here you can find the complete source code:

http://xmlcodeeditor.codeplex.com/

In the source code you will also see a full set of tests. To see the tests when you load the project go to the /Tests folder of the project web site.


This is one tool I wanted to develop for quite a while but I was never able to find the time for this, until this weekend when I finally got it done.

This is a 3D map of the nearest stars within 16 light years from the earth. There are some tools like that online but non is showing the stars in relationship to some known constellations. I wanted to see the nearest stars as 3D but also placed in a way so if I go out at night I can picture those stars in their right positions, even though most of them are not visible with the naked eye, but at least I can visualize them in their real positions.

Continued...

Visual software development through diagrams and other visualizations was a dream that persisted for a long time in IT, but never came true for any software platform. Yes it is true that UI design or database modelling can be very visual these days but the main bulk of any serious software project remains as of this day primarily text based. There are many reasons for that, but I don't want to discuss them here. Instead I want to express my opinion that despite the apparent lack of progress in this area, the visual expression of any abstract concept for most people makes it much more easier to grasp. So perhaps we should make more steps in that direction, even if we cannot turn the whole programming into a visual work yet.

Continued...

I was playing the other day with some equations and thinking about how I was taught the logarithmic function back in school and how we usually think about it these days. And correct me if I am wrong but I can't remember a case when this concept was introduced in a some kind of visual way. The most visual thing I've ever seen about it was a graph of the logarithmic function – the well known curve. And may be you would say, this is because there is nothing visual about the logarithmic function per se. May be it is a purely mathematical concept, having nothing to do with visualizations.

Continued...

This is a WPF control I just put on CodePlex that implements the basic functionality for a source code editor.

You define it in the XAML with something like this (of course after you put the assembly com.bodurov.WpfControls.SourceCodeEditor.dll in your bin folder):

Continued...

Source: http://htmlsummarizer.codeplex.com/

This is one C# tool that I want to share. It can be used for extracting a portion of an HTML code without cutting the HTML tags in half or leaving unclosed tags. It also allows to measure the length of the extracted part in number of letters, words, sentences, closed HTML tags, closed P tags, closed DIV tags and closed P or DIV. When counting the number of letters or words, those contained within the HTML tags are not considered.

If you have some content stored as HTML in a database, or if you want to summarize an HTML page residing on a remote server you have to be able to extract a certain number of words or letters without considering the HTML tags them self and without leaving unclosed HTML tags. This is the exact tool for this kind of scenario.

Continued...

This is a short You Tube video I made last month, to visualize the Quick Sort sorting algorithm. As you all know this is one of the most efficient algorithms for sorting data. There are many implementations of that algorithm so this is just one of them.

The basic idea is to choose one element that we call pivot, and to place all the elements lower that the pivot on the left side and all the elements higher than the pivot on the right side. This way the pivot is placed on the right place and we repeat the same procedure for the two remaining sub lists and so on recursively until we have the entire list sorted.

Continued...

The main idea of the Unity Framework is to give us the ability to quickly replace different parts of big application without having to recompile or re-factor our code. Ideally that means adding another assembly to the bin folder or GAC, and certainly that is the right way to add new providers or class implementations. But sometimes you may want to quickly script a provider in order to test a new idea on your staging server or debug a problem without having to deal with all the hassle of adding a new assembly.

Well, the first idea that comes to my mind is to use a class defined in the App_Code folder. The class will be recompiled each time there is a change in the source file so this seems as a perfect candidate for a quick test. But there is one problem. The assemblies for the classes in App_Code folder are dynamic and so we don't know what their name is, and because of that we cannot set the right class reference in the configuration file.

Continued...

A common problem for a .NET project is that after deploying a DLL into the bin folder or as a matter of fact doing any change in the bin folder of a web site all the data for any of the current in process sessions is lost. The same happens if we change the web.config file.

In some cases it makes sense to be so, for example if we store in the session objects that are being changed by the current deployment of a new DLL. But in many other cases it is rather a disturbing frustrating side effect that we want to avoid.

Continued...

If you need to serialize your business objects into XML you may also need to generate automatically XML Schema so you can check the XML against that schema before try to deserialize it. This is one utility that will do that for you. Now, let’s first see one utility that will do basic XML serialization and deserialization objects.

Continued...

Very often we have a scale of values that can be generalized and described as a real number within the range of 0 and 1, 0 being the lowest value and 1 being the highest. For example if we are building an airplane with highest possible altitude of 5 miles we can represent the current altitude with a number from 0 to 1, in this case 0 will represent the plane on the ground and 1 on it’s highest altitude of 5 miles. This may be useful in many different situations, for example if you show this value to a person or instrument that is not familiar with the specific value but can understand the idea of minimum and maximum of this value. Another useful scenario would be in you want to represent this value in a diagram, arranging it from 0 to 1 makes it easy to plot on a surface of any size.

Continued...

Here I want to describe the steps you can use to search for database performance bottlenecks before you deploy your web application to production server.

1. Modify Fiddler Rules

We want to add to Fiddler the option that would allow us to execute a sequence of requests and then tell it to repeat the same sequence N number of times.

First of all if you don’t have Fiddler yet, install the latest version from http://www.fiddlertool.com/Fiddler2/version.asp then start it and go to Rules - Customize Rules…

Continued...

I would like to present here one tool I have developed recently for visualizing vectors in three dimensions. The tool allowes not only to view vectors but also to share them with others. Check the "link to current vectors" for that.

You can view it only by visiting URL: www.bodurov.com/VectorVisualizer

The tool is build from scratch and does not use any 3D engine. In fact it includes a very simple light weight 3D engine for drawing lines in 3D. For the platform I chose Silverlight under C# as I find .NET to be the best coding environment.

If you want to dive deeper into the concepts that this tool is based on you can check my Simple Talk article at www.simple-talk.com/dotnet/.net-framework/building-a-simple-3d-engine-with-silverlight/

Continued...

Web service proxies for asmx web services are quite annoying. They are supposed to represent the contract between the service and the client and without any doubt there should be such a contract. But in reality they represent not only the contract between the service and the client but also the tool that generates them. And they make you vulnerable to any inefficiencies of that tool. Do you like to be dependant in such a way?

Well, fortunately WCF offers much better approach. The contract between the service and the client is represented by an interface decorated with the right attributes. That is all you need for the contract between the client and the server. There is no third party involved and everything is clear. I like that.

Here is an example of a wrapper around the WCF client.

Continued...

Let’s say you have a group of settings in your database. There are some settings that are specific for each client. But those settings can also be generic and be used for all the clients. So if ClientID column contains the key of your client you use that value but if there is no such value specified the value defaults to the value specified in the column with ClientID set to NULL. So in a way your client specific value inherits from the default value and if there is no specific value the default is used.

Now the things get more complicated if you can have some setting with a client specific value and no default value and some with a default value and no client specific value.

Let’s set up a test table and test data first.

Continued...

This is a simple tool for testing Flash Remoting Calls I want to share. You can use the tool from here: http://bodurov.com/TestFlashRemoting/ or download the source from here http://bodurov.com/TestFlashRemoting/TestFlashRemoting.zip This is a simple and light weight tool to test your services.

I have set up a test service with this source:

Continued...

This is a follow up of my last performance related article where I compared the cost of passing XML vs. Table vs. plain Varchar parameters to a procedure without considering the cost of querying the data http://blog.bodurov.com/Performance-Test-for-the-cost-of-passing-parameters-to-a-SqlServer-2008-Stored-Procedure-as-XML-vs-Table-vs-Simple-Varchars.

In this test I added a query to the procedures to see how will the results look if we consider the query cost in the equation.

This is how my modified procedures look:

Continued...

In this test I want to examine the performance implications of passing a relatively long set of data to a SQL Stored Procedure. I compare performance for passing that data as XML, as Table variable or a list of NVARCHAR variables. The test consists of 10 000 iterations. There is nothing in the procedure, so I am not testing the cost for querying the data but only the cost for passing the data to the SqlServer stored procedure. Following are my procedures.

Parameter as XML:

CREATE proc [dbo].[Test_Xml_Parameter]
    @Xml XML
as
    SELECT 'Return'
GO

Parameter as Table:

Continued...

I want to start adding video tutorials to my blog in order to make it a bit more interesting and fun.

My first video will be a short movie of how to use Flajaxian file uploader. The topics covered in this video are:

Continued...

Writing unit tests for any application that connects to a database is always challenging, because deviation from the expected alterations of the database may influence the work of the business objects. The same tests have to run over and over again – after each change of the code, in order to ensure that the previous functionality has not been broken by the newly introduced changes. Altering the data so many times may have unpredictable consequences.

One of the most popular solutions of that problem in the Java and .NET worlds is the usage of mocking framework, for example Rhino Mocks. And despite the enormous advantages of this approach it has also some noticeable drawbacks. For example it is not hard to imagine a situation where your tests will pass well with the mocked data but will fail on the real database. And what if you have a lot of business logic in stored procedures that also need to be tested?

Continued...

When you have to save hierarchical data inside a database you can traverse the tree with recursion and for each note call the database to save it. But that is not the most elegant solution; because your tree might be quite big and you can end up with lots of calls to the database. You may also need to wrap this whole thing inside a transaction but as we all know stretching a transaction between several calls is not the best approach.

What we actually want is to transfer the hierarchical tree inside a single stored procedure and process it there. But how can you pass a hierarchical data to a single stored procedure? Well the answer as often is XML. Let’s assume you have this hierarchical XML:

Continued...

Normally when generating Json you would serialize typed .net objects. In most cases this is the right way to go, but if you have important reasons not to use this approach, for example if the format of the coming data cannot be predicted at compile time and you don’t want to generated dynamically typed objects, for performance reasons, you may consider generating Json code as string. A common way to go is to use StringBuilder, but I would not call it as a very json friendly tool, so here is an alternative.

Json builder can help you iterate through collections and hide json related string transformations from you. Here is how you use it:

Continued...

Often in a Silverlight client you will need to delay the execution of a particular action. There is no intrinsic setTimeout function like in JavaScript window object but you can use System.Windows.Threading.DispatcherTimer object. If you are looking for a tidy wrapper around this object you may want to consider this solution:

Continued...

If you want to define the number and the type of Silverlight DataGrid columns at runtime you can use the following approach. The technique can actually be used not only for Silverlight but also anywhere where you have to transform IDictionary (for example Dictionary or Hashtable, SortedDictionary etc) into anonymous typed object with each dictionary key turned into an object property.

Continued...

This is a simple tool for traversing the file system in search for a file or folder or doing something to many files.

The source is available here: http://www.bodurov.com/files/FileSystemIterator.zip

And here is a sample application that searches for the first file with extension .aspx

Continued...

Another Flajaxian.com tool is the adapter that you can use together with Flajaxian FileUploader, the tool is FREE and open. You can use it to enable file upload to a CS3 Amazon Service.

Flajaxian S3 Amazon Service Uploader is adapter for the Flajaxian FileUploader .NET web control designed for asynchronous file upload to an Amazon Service of multiple files at the same time, without a page post back and with a progress bar indicating the current upload progress. This control and adapter do not require full trust environment.

For download and documentation, please go to: http://www.codeplex.com/FlajaxianS3Upload

The web site is: http://www.Flajaxian.com

You can see a Wiki page here: http://flajaxian.com/flajaxian.com/docs/html/HowToUseAmazonUploader.htm

Continued...

I would like to present one project I am starting together with a friend – Flajaxian.com. This is a web site providing FREE, open source tools for AJAX web development.

The first tool you can find there is .NET web control for AJAX style file upload designed for asynchronous file upload of multiple files at the same time, without a page post back and with a progress bar indicating the current upload progress. This control does not require full trust environment. The control can be extended with the addition of server side and client side adapters. Flajaxian FileUploader uses Adobe Flash Player 8 or higher Flash player for the file upload.

For download and documentation, please go to: http://www.codeplex.com/FlajaxianFileUpload

The web site is: http://www.Flajaxian.com

Continued...

Here I would like to present a tool for formatting and coloring raw JSON code. Very often if you use JSON generated by server side code it will be in a nice compact format but at the same time it will be quite hard to read it and possibly alter it. So the tool allows you to make your JSON more readable. For example if you have code like this:

[[{anArray:[2,3,4,["string1","string2",{aa:[]}], {"type":"simpleObject"},null],abotherProperty:"",anObject:{justANumber:2,func:function(){if(1>0)return false; else return true;}}}],true]

it is a real challenge to find something you need inside the graph. In this case the JSON formatter is the right tool for you.

You can see it at: http://bodurov.com/JsonFormatter/

Continued...