Hi there!

Hi there!
My name is Michael Ivanov and i'm a Senior SDE/Software architect.
My CV - here. You can find articles and other blog posts on the main page. I also develop some free and commercial software - complete list is here.

Saturday, October 16, 2010

Un-recursive - part 1

I decided to write a cycle of posts about avoiding recursive calls in your algorythms. Recursion is the thing i hate to implement - it's hard to debug, it cost too much and so on. In this cycle i'm going to start with a common task - Tree Painting in depth - a task that could easyly solved with recursive calls - and show two ways to achieve the goal without recursive calls. After that i ll build parallels between this task and "common" recursive-solved task. Than i will implement quick sort and merge sort. Show/Hide

Tuesday, September 21, 2010

Randomized Quick-sort

Quick-sort is another type of comparison sorting algorythm. It's much better than other comparing algorythms cause it doesn't require additional space for its work (unlike merge sort for example). It also has a good time of work in average case - O(n lgn) - that is best time for every comparing algorytm as you know. It's also has asymptotic n^2 time of work in worst case, that occurs rarely. Using randomization at the each step of algorytm helps to avoid receiving "pre-defined worst case", when our solution gives us worst time on a particular sequence. Here is an implementation of randomized qucik-sort: Show/Hide

Wednesday, September 15, 2010

Count sort - yehhaaa!

Count sort is very good to sort sequence of integer which has small range of values (in comparison with sequence length). Due to two assumptions - our sequence contains only integers and its values range is much less than amount of items in sequence, it's linear in time to the amount of items in input. It's much better than classic algorythms based on comparison, cause it doesn't use comparison in its work, so it overcomes traditional for comparing algorythms O(nlogn). Here is an implementation: Show/Hide

Monday, September 13, 2010

Merge implementation with predicate

I study algorythms carefully during last two weeks and as you probably know, many algorythm tasks require implementation of sorting procedure. There is a huge amount of various sorting algorythms, such as Quick Sort, Heap Sort and so on. But one of the easiest to implement is a Merge Sort. You can find its description somewhere. I implemented it several times - for ascending sorting, for descending sorting and so on, so finally i take time to implement it with any predicate you like. Here is an implementation:

Hide button test

I want to test hot to hide text here Show/Hide

Wednesday, August 18, 2010

extract dll from GAC

Do you know that you can view GAC as "usual" folder if you unregister shfusion.dll? regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll You can browse it and copy any folder you like. Just not to forget register shfusion.dll back.

Thursday, June 3, 2010

your javascript and validators' javascript

I was creating a small web-page the day before. There was a button like this:
I wanted confirmation box appeared before button would postback the page to the server so in Page_load i added such row:
btnComplete.Attributes.Add("OnClick", "return confirm('" + ConfirmTextWarning + "');");
After that, everything was working fine. A bit later i added RequiredFieldValidator to validate a textbox on the page. The button's "Causes validation" button was set to true, but there was no validation on click of the button. The confirmation box was shown but if i click yes - page was send to the server without any validation. When i checked the page source in browser, i found there this element:
<input type="submit" name="btnComplete" value="Complete" onclick="return confirm('some text');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnComplete", "", true, "", "", false, false))" id="btnComplete" />
As you can see, call of the validator's javascript function is added to the onclick event of the button, but it was not call due the return keyword in confirmation box call. I changed row in the Page_load method to
btnComplete.Attributes.Add("OnClick", "confirm('" + ConfirmTextWarning + "');");
and output became
<input type="submit" name="btnComplete" value="Complete" onclick="confirm('some text');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnComplete", "", true, "", "", false, false))" id="btnComplete" />
And it worked fine:) Thank you if you read it, it was my last post before vacations.

Monday, May 24, 2010

Never return!

Never return in the middle of the function.
Never return in the middle of the function.
Never return in the middle of the function.
Never return in the middle of the function.
Never return in the middle of the function.

If you don't want code behind return to be executed, rever conditions of return

Instead of
if(returnCondition) return yourValue;
/// some code


write
if(!returnCondition)
{
//// some code
}
return yourValue;


Never return in the middle of the function.

Wednesday, May 19, 2010

Test yourself.

Just a small task for you, try not to cheat and you ll get a pie :)
Show/Hide

Wednesday, May 5, 2010

just-in-mind: resharper doesn't look into false preprocessor directives

Suddenly noticed resharper doesn't look into preprocessor directives if they are false. For example, it counts such code as good:

var debugVariable = 0;
Console.WriteLine("This use the variable in output, " + debugVariable);
Console.WriteLine("And this is not");

Now, switch to "Release" configuration and add some preprocessor directives, to get a code like this:

var debugVariable = 0;
#if DEBUG
Console.WriteLine("This use the variable in output, " + debugVariable);
#else
Console.WriteLine("And this is not");
#endif

Resharper doesn't like it and it shows that variable debugVariable is never used.

Tuesday, May 4, 2010

Enterprise Library custom tracelistener to log to MS CRM

Hi to all. I hope this will be the first successfull entry in my blog.
It's devoted to a class i created recently in my current project. We plan to use Enterprise Library
in our projects and want our MS CRM users able to watch through the log entries via MS CRM. So my article describes
a process of creation custom listener for Enterprise Library that is able to write entries in MS CRM. I used
Enterpise library Beta 2 version, and it has poor documentation, so in several places i used a workaround code because
i failed to use all power of EL API for creating custom listener... So lets start!
Show/Hide

Tuesday, March 23, 2010

back 2 business

Three years passed since i created this blog and finally i decided to start post here :) Even though my native language is Russian, i ll post in English cause
a) I want many-many readers of my blog:)
b) (i won't tell u now;))

So, sry 4 my english'n'c ya