Omer van Kloeten's .NET Zen

Programming is life, the rest is mere details

News

Note: This blog has moved to omervk.wordpress.com.

Omer van Kloeten's Facebook profile

Omer has been professionally developing applications over the past 8 years, both at the IDF’s IT corps and later at the Sela Technology Center, but has had the programming bug ever since he can remember himself.
As a senior developer at NuConomy, a leading web analytics and advertising startup, he leads a wide range of technologies for its flagship products.

Get Firefox


powered by Dapper 

.NET Resources

Articles :: CodeDom

Articles :: nGineer

Culture

Projects

February 2004 - Posts

Tool: Publisher Policy Maker

Publisher Policies are files used for redirecting assembly versions.
Creating them is not a mind-boggeling task, but it's still time worth saving.

I've gone and created a simple little application that takes two files of the same assembly, with different versions, and creates a publisher policy file for them.
Mind you, it's not thoroughly tested or anything. Just helpful. ;)

View the source or download it.

Understandability

We all talk about usability: How to focus on how the system fits the user and not the user fitting he system.
What Memi is talking about is Understandability. It's not that the user has to be able to use the system, he has to understand it. Memi makes a point in saying that no technical terms should enter the user's domain.

The point mentioned was using the error message "The date format is incorrect. Enter valid format: dd/mm/yyyy”.
I'm sure that I'm not telling you anything new here, but there are at least three ways out of this without a scratch:

  1. You separate the field to three fields and write day, month and year for each. Maybe even combo boxes.
  2. You create a field that is a formatted text box (adding slashes automatically, etc).
  3. You put a big-ass explanation of what is 'dd/mm/yyyy' somewhere close to the field (or somewhere in the manual).
None of the said solutions are easy to implement or look nice (unless you're a UI whiz).

Memi calls it "The newbie syndrome" but I know way too many experienced developers who don't really care much for usability, never mind the understandability, of their work.
In my opinion, thinking in terms of usability starts from the lowest ranks, the developers, and not the designers.

Exception Stack Trace

Hey guys, here's an idea for a feature: Clickable Exception Stack Traces.

How? Well, if you can collect where the exception has passed until I caught it (or failed to catch it and have it in $exception), why can't I just click on a part of that exception's stack trace in the watch window and directly go to the method or line that the exception has passed through?
Nowadays, I have to copy the stack trace string from the watch to a new notepad window and then cut the "\r\n"s from the string just to understand it.

Suggestions, comments and improvements upon the idea would be more than welcome.

Posted: Feb 20 2004, 10:23 PM by Omer van Kloeten | with 1 comment(s)
Filed under:
Interface Re-Implementation

I had to look this up today, so I thought I'd share:

Section 13.4.4 of the ECMA C# Language Specification states that if you inherit a class that implements an interface explicitly and re-implement that interface explicitly, the previous implementation will be overridden.
This means that you can do this:

	interface I
	{
		void m();
	}
	
	class A : I
	{
		void I.m()
		{
		}
	}
	
	class B : A, I
	{
		void I.m()
		{
		}
	}
And the implementation would be overridden.

What I did not find, however, was which method was called when you did this:

	A something = new B();
	((I)something).m();
Apparently, it's the method from class B. Nice to know that... ;)

Conditional Operators

The C# spceification declares the Conditional Operator (14.12), otherwise known as the Ternary Operator. It means that you can do this:

int i = (boolean_expression ? j : k);

This is great. Less readable, but great.
A couple of days ago, I thought: "why not go another step?" and came up with this:

int i = try { int.Parse(str); } catch { 0; }
This would help remove the "Use of unassigned local variable" errors and make the code less complicated.
Of course, the usual cases of "if there is more than one line in there, write it in the expanded form" apply.

I'd love to hear comments and suggestions.

Posted: Feb 10 2004, 12:25 AM by Omer van Kloeten | with 5 comment(s)
Filed under:
Rules in a ForeignKeyConstraint

I've noticed too many occasions when a fellow programmer comes up to me with this question:

"I've deleted a row and suddenly, another row got deleted! I checked my code and I don't delete it anywhere... Must be some bug somewhere..."

So the answer in 99.9% of the cases is that you didn't pay attention to the Rules in the foreign key constraints when you created your typed DataSet. Why? Because the defaults for UpdateRule and DeleteRule are Cascade (AcceptRejectRule defaults to None). This means that if you didn't pay attention and you have a row that's related to your row by foreign key, when you delete your row, that row will be marked as deleted.

My advice? Never have Rules set to Default. Microsoft could decide that what they're doing today is wrong, change the defaults and you're screwed.

Shameless Plug

Just wanted to mention to everyone that DevDays Israel is tomorrow and that Ami Dudu, my former PM, is lecturing about Code Access Security.
All the luck to you, Ami. Have fun!
DevDays attendees, you've got one hell of a speaker. I hope you enjoy yourselves ;)

How To: Debug Into File References -- Correction

Quite a while ago, I posted a way to debug into file references when you have the source code. At the time, we believed it to be the only way, even though it did not work at all times. However, I have found an easier way to do just that:

  1. While debugging, break and open the Modules pane (Ctrl+Alt+U).
  2. Right click your Assembly and select "Reload Symbols".
  3. Select the PDB file for your assembly.
  4. Step into the code.

Easy, isn't it?
You can also reload the symbols from the Call Stack window, when selecting any method from the Assembly you wish to debug.

More Posts