Jun
23rd | 2008

A Programming Job Interview Challenge #9

Posted by Shahar Y |
Filed under .Net, Misc. |

That’s it, the 9th post of the series of programming job interview challenge is out and alive. 19 readers provided answers to job interview challenge #8, Pieter G was the first to provide a correct answer:

The fastest way I can come up with is to generate a finite state machine at initialization. The transitions between states would be defined by the records you look for in the pattern and one transition for an unmatched record. When the machine enters the goal state is should send the notification (how to most quickly do that I leave to someone else). When reaching the goal state the machine should not terminate but continue (else we may miss a occurrence).

You can see more details about the solution in those blog entries:


Continue Reading...
Jun
20th | 2008

How To Create a WPF Custom Context Menu

Posted by Amit |
Filed under .Net, WPF |

How would you like your WPF application to have a Context Menu like this:

Context Menu Example

Well, It is not so hard. Here is how you do it:


Continue Reading...
Jun
18th | 2008

Diagnose Assembly Binding Failures

Posted by Shahar Y |
Filed under .Net, Misc., Utilities, Visual Studio |

Every one of us, software developers, experienced situations where the .Net Framework could not locate an assembly and ended up facing the TypeLoadException. These failures usually happen due to an assembly deployed to the wrong location or a mismatch in version numbers or cultures. A quick way to check what went wrong is to open the module window (Visual Studio) during debugging but that may be sometimes impossible or inconvenient because:

  • We may not have Visual Studio installed. 
  • We installed the product in the customer site and we don’t have the code available.
  • It is some third party assemblies which causes the problems.

Luckily, there is an assembly binding log viewer which displays information that helps us diagnose why the .NET Framework can not locate an assembly at run time. This tool is called


Continue Reading...
Jun
17th | 2008

Software Errors Parade

Posted by Shahar Y |
Filed under .Net, Misc. |

Software errors, are so prevalent and so harmful that they cost the U.S. economy an estimated $59.5 billion annually. There are many examples of very serious and detrimental software errors such as:

softwareErrors Obviously, we would like to deliver a “bug free product” to our customers, but unfortunately, this is an un achievable goal. While some errors can be very easily eliminated, other are very evasive. What are the measures taken into consideration when we decide if an error is evasive or not? Lets create a list of software error parade and talk about it:


Continue Reading...
Jun
16th | 2008

A Programming Job Interview Challenge #8 - A Needle in a Haystack

Posted by Shahar Y |
Filed under .Net, Misc. |

The eighth post of the series of programming job interview challenge is out. 68 readers provided answers to job interview challenge #7 and most of them had the correct solution. As rvh mentioned, the trick here was to understand that the round table has a symmetric shape and: Actually this algorithm isn’t limited to just a round table. It will work with any shape that is symmetric with respect to both x and y axes. I couldn’t describe the correct answer better than Yoav Zobel, as he was the first one who also formally proved his algorithm:

The Correct answer (as provided by Yoav Zobel):


Continue Reading...
Jun
13th | 2008

Why Should You Use The x:key Attribute In WPF DataTemplates

Posted by Amit |
Filed under .Net, WPF |

We have all used WPF DataTemplates, but I bet most of you never gave thought to the meaning of the x:Key attribute. We all know the meaning of the DataType attribute, which determines to what type of data the template will apply to. But what about the x:Key why is it there? Lets tale a look at the following code:

<Window.Resources>
        <DataTemplate DataType=”{x:Type data:s}”>
            <Button Width=”50″ Height=”50″>
                <TextBlock Text=”{Binding text}”></TextBlock>
            </Button>
        </DataTemplate>
    </Window.Resources>
    <Canvas>
        <ItemsControl ItemsSource=”{Binding}”>
        </ItemsControl>
    </Canvas>


Continue Reading...
Jun
12th | 2008

Creating Visual Studio Keyboard Shortcuts Cheat Sheet

Posted by Shahar Y |
Filed under .Net, Visual Studio |

After publishing 10 Visual Studio shortcuts you must know and then 11 more Visual Studio shortcuts, a colleague of mine, Elan Kynsky, introduced me an MSDN page called Visual Studio 2005 IDE Tips and Tricks. This is a long article where you can learn cheatsheeta couple of useful things about Visual Studio, but what attracted me most, was the “Creating a keyboard shortcuts cheat sheet” section.

As we all know, there are a lot of keyboard shortcuts in Visual Studio. We mentioned only 21 of them here at Dev102.com but according to this article, there are about 450 shortcuts available. That fact, made me realize that I know less than 10% of them… Fortunately, we can write a macro that enumerate all of the available shortcuts. To achieve that goal, go to Tools->Macros->”Macros IDE”, a macros window will pop up, expand the MyMacros project (in the project explorer), expand MyMacros namespace and double click on Module1. Copy the following code to the Macros IDE and run it.


Continue Reading...
Jun
9th | 2008

A Programming Job Interview Challenge #7 - Coins of The Round Table

Posted by Shahar Y |
Filed under .Net, Misc. |

That’s it, Times up on the sixth in the series of job interview questions. There were 39 people who answered and the first one to give a correct answer was leppie from the IronScheme project.

The correct answer is that both will return false.

You could sum up the answer by saying Boxing.

An ArrayList hold objects, so when you insert a ValueType into it, it will be boxed and become an object. When you compare List[0] to List[1] you are comparing references, and they will never be the same because they are pointing to different objects. This is the reason for getting the false in both comparison. It is true that in the second comparison you are comparing a double and an int ( 2.0 and 2), but that is not why you get false, it is due to the Boxing.


Continue Reading...
Jun
6th | 2008

Cool links for programmers

Posted by Shahar A |
Filed under .Net, Misc., Utilities |

In this post I do not intend to make a list of the best programmers web sites, but to share with you some you might not know:

CodeFetch - Search for source code in programming books. Their mission is to connect programmers with authors and is uses and support open source. If we are talking about code search I am sure you are familiar with Koders - top search engine for code.

FreeTechBooks - Free Online Computer Science and Programming Books, Textbooks, and Lecture Notes.

QuickRef - interactive programming documentation, allows you to keep many docs and remember them.


Continue Reading...
Jun
5th | 2008

The Use of Environment.NewLine In a WPF MultiLine TextBox

Posted by Amit |
Filed under .Net, WPF |

Last week I was in the need to use a WPF TextBox that had multi line capabilities. I started Typing Multi and hit CTRL + Space to get the intelisense and I was shocked! No MultiLine TextBox, I did get the following:

But no MultiLine TextBox

   1: <MultiBinding></MultiBinding>
   2: <MultiBindingExpression></MultiBindingExpression>
   3: <MultiDataTrigger></MultiDataTrigger>
   4: <MultiTrigger></MultiTrigger>


Continue Reading...

Search Dev102