Here I would like to share a data structure that I use for navigation in 3D space of a game. In essence it is a binary tree build out of linked lists.

It attempts to combine best of the two worlds 1.Linked Lists and 2.Binary Trees. So you can find a specific item in log(n) time or explore near by items in n time. This is very useful in a game where you always need to know what is near the camera, but once in a while you have to find a specific object. Below you can see the basic schema of the structure:

This pictures only one single dimension. In a game I use three dimensions but the structure allows N dimensions.

Continued...

Here I would like to share this C# implementation for efficient calculation of the median from a continuous stream of numbers.

One way to do that would be to use two heaps. One max heap on the left and one min heap on the right. In the middle will be our median value. When inserting new value we will make sure that the numbers on the left and on the right are the same. Below is a picture of how it would look:

heaps

And here is the implementation: Source Code in C#

Continued...

Frog Fu is iOS game written on C++ with OpenGL 2 now available as open source project on GitHub

https://github.com/YouVisio/frog-fu-youvisio

You can find it on the App Store at: https://itunes.apple.com/us/app/frog-fu/id574269225?mt=8

Please review and rate it!


Here is an open source tool we developed at Move.

https://github.com/vbodurov/dynamic-proxy-creator

You can also find it in Nuget repository https://nuget.org/packages/com.bodurov.DynamicProxy/1.0.0

The tool takes an existing object and wraps it in interface able to implement this object. For example if you would like to wrap HttpRequest in an interface that you can later pass to your business objects and mock in your tests.

This is how you would use it:

Continued...

This is one application I have developed for WP7. It is a map of the night sky and at the same time a three dimensional map of the nearest stars. You can switch between a view from the Earth and a Space view of the nearest stars. A 3D view of the solar system is coming soon. This is a link to the Windows Phone Marketplace: http://social.zune.net/redirect?type=phoneApp&id=960d8167-c43c-e011-854c-00237de2db9e

The website for the project is http://www.stars-3d.com/

A short introductory video can be found on YouTube at http://www.youtube.com/watch?v=UmdW6rH2K0o and also another one at http://www.youtube.com/watch?v=0pCtfvLPLZw

Continued...

When working with XNA on XBox 360 or Windows Phone 7 you have to register each font used in a sprite font file. You can just define there a big range that would ensure that the Unicode characters you use will be within, but that would increase the file size. The best option would be to only use the character ranges you need.

Here I would like to present a free open source Silverlight tool that you can use to determine the exact regions you need to include:

http://www.bodurov.com/UnicodeRegions/

Just drag and drop your text file onto the screen. Your file will not be sent to a server, the code is completely client side. On the left side you will see characters regions XML that can be copied and pasted into your XNA font sprite. The right side pane shows visually what characters are included in each range sequence.

Continued...

My latest work is this Silverlight control for discovering and visualizing the difference between two text files or just two strings that you copy and paste. You can choose files either by clicking on the file buttons and selecting them from the file dialogue or you can just drag and drop them in the boxes.

Demo is available here: http://www.bodurov.com/TextDiff/

Unlike my previous post at http://blog.bodurov.com/Implementing-Longest-Common-Subsequence-Algorithm-in-JavaScript-Text-Diff/ where I just wanted to prove the concept that it is possible to implement the Longest Common Subsequence Algorithm in JavaScript, this app is optimized and capable to handle much bigger strings. It also can work with files.

Continued...

When we use SqlCommand with a set of parameters, they are being executed as a parametrized query. You may or may not pass the desired type with each SqlParameter. If you do not specify desired database type it will be determined by the ADO provider, but you will not know what the actual SQL type is. Below I provide a code that will give you the actual parameters. This code can also help you find out what the actual SQL query executed in the database is.

Continued...

This is a tool for finding the differences between two text files and in particular finding what parts have been edited, deleted or added. It implements one of the algorithms for finding the Longest Common Subsequence between to data sources.

You can see a demo at: http://www.bodurov.com/JavaScriptDiff/

The main idea of this algorithm is to build a matrix with rows – future state, and columns – previous state. This matrix will consist of squares incorporated one into the other as steps in a stairway. The path of following those steps from the top left corner to the right bottom corner determines the actual graph. Moves to the right are deletes, to the bottom – inserts. Inserts followed by deletes are changes.

Continued...

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.

This is a link to an article that I wrote about this project: Using Microsoft Robotics Developer Studio with Lego Mindstorms NXT Robot

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

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.

Continued...

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 of quicksort 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...