Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,583
|
Comments: 51,213
Privacy Policy · Terms
filter by tags archive

C# Riddle #5

time to read 1 min | 184 words

Following Alex's post about traps in interviews, I thought about posting bits of code that I won't use in interviews. Mostly because I don't think that it is fair to the interviewee. I can think about crazy usages to langauge features, and not in a good way.

Consider the following peice of code (which is valid C# 2.0):

public IEnumerable<Predicate<Customer>> ValidationPipeline()
{
 yield return delegate(Customer c)
 {
  return c.Name != "";
 };
 
 yield return delegate(Customer c)
 {
  return EmailService.IsValid(c.Email);
 };
}

How would you use this method, and what is wrong with it?

time to read 2 min | 380 words

If at all possible, minimize any dependencies on infrastructure that you have in your applications. The more dependencies on infrastructure you have, the less freedom you can get.

I define infrastructure as anything that I can put on my laptop and use without being connected to any network whatsoever.

Some examples of infrastrcuture bound applications are:

  • Domain dependencies - the application must contact a domain controller for autentication, authorization, or just for the hell of it. (The reverse is also true, the application must not be run from a computer which is part of a domain).
  • Forced distributed application - each part of the application cannot (under pain of crash) be run from the same computer.
  • Each part of the application require radically enviornments (server OS vs. client OS, windows/linux, etc)
  • The application uses Oracle.
  • Using very large DB (Greater than 1GB) or multiply thereof.
  • Requiring an exotic component (AS400 to hold the configuration for the application, for instnace).
  • Requriing connection to a remote server accessible from a single point only

An infrastructure bound application is:

  • Harder to deploy.
  • Harder to test.
  • Impossible to develop in a disconnected environment.
  • Usually impossible to run except where it is was developed (or deployed with much effort).

I guess you know my opinion about such applications. I hate to be forced to work from a specific place, because it usually means that I can't "steal" work time on it when I am away from the office.

time to read 1 min | 160 words

I have quite a bit of rants against several teams at Microsoft, but I wanted to dedicate this post to the VS debugger team, which has done a superb job in VS 2005. Maybe it has to do to the fact that I am a debugger user and not a developer, but so far the only issues that I had with the debugger are stuff like "You didn't configure E&C in the option panel, etc".

This post was prompt by a fact that I accidently discovered recently. You can step into the web service code from the client code, if it is on the local machine. Just to give an idea about the eneromosity of this feature, this means that you automatically attach yourself to another process, find the correct place to go, and go there. I would have never thought of trying this, because "obviously" this would work.

 

time to read 3 min | 404 words

Alex is making a good point about interviews questions and traps. Interviews questions are not real code, at least not at the first stages. Most of the stuff that I intend for interviews is not going to get somebody called on the carpet if I get to it on production code.

In an interview, I need to be able to judge someone's technical skills very quickly, and hopefully accurately. I can spend a day pairing with a guy and then give a highly accurate view of his/her abilities, mindset and match for our team. I can't do that in half an hour to an hour (the span of most first-stage inteviews).

The point of questions like that is not neccecarily to get the correct answer, it is to discover areas of knowledge. If you can't answer this question, you don't have a lot of experiance in C based languages, period.

If you need to think before you answer this question, great! I want people who take a step back when they encounter this code. But if you programmed in any C based language for any significant length of time, you would know what the meaning of postfix ++ operator, and what it should do.

If you can't figure out the answer, but can decompose the steps taken by this answer, than is fine as well. But this question points fairly accurately to the amount of knowledge that you have in the language per-se.

Other questions that I ask include "What is the difference between value/ref type?" and no one told me yet that ref types are on the heap, and value types are on the stack. I was told that value types are not changes, are copied, etc. That question is another good indication for the amount of knowledge that a person has.

"Is string a ref or value type?" - this one almost everyone gets wrong.

Part of the problem is that I refuse to be limited to what Microsoft supplies, which means that I need to be able to judge what they will be able to learn if/when we hire them. If they can't think and they program by rote, I don't want that. And asking questions that require thinking is a good way to discover that.

time to read 2 min | 236 words

Continuing on the interview stuff, here is something that can tell you quite a bit about a developer. Given the following error, what do they do?

(Image from clipboard).png

Here are a couple of options:

  1. They tell you: "I can't get it to work, it keeps failing and I don't know why."
  2. Look into the inner exception.
  3. Googles the exception message first, and give up if the first result doesn't show anything relevant.
  4. Look into the inner exception, google that, and fix the problem.
  5. Fix the error after reading the message
  6. Look into the inner exception and fixing the problem.
  7. Download and install the kernel debugger and then they start digging

If they can't pass this test (and if you are reading this post, I sure do hope that you know what of the above is a correct response), they don't hire them.

time to read 1 min | 147 words

For some reason, I get to see a lot of WTF?! in the field, and I think that this is about time that I do something about it. I'm going to start a series of posts about the stragest stuff that I see.

Today, we have the New Data Model to observe. As you hopefully know, there are three (and only three) ways to create associations in the database, one to many, many to one and (using an association table) many to many. Trying to invent new ones will cause pain.

Take for example this table diagram:

(Image from clipboard).png

It may not seem bad to you until you dig a bit deeper and realize that both Items.Id and Items_Security.ItemId are primary keys, and both are Identity Columns!

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. Production postmorterm (2):
    11 Jun 2025 - The rookie server's untimely promotion
  2. Webinar (7):
    05 Jun 2025 - Think inside the database
  3. Recording (16):
    29 May 2025 - RavenDB's Upcoming Optimizations Deep Dive
  4. RavenDB News (2):
    02 May 2025 - May 2025
  5. Production Postmortem (52):
    07 Apr 2025 - The race condition in the interlock
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}