.NET Technical Interviews

Posted in .NET, ASP.NET, C#, Interview on May 13th, 2010 by msposato – Be the first to comment

In the past year I’ve participated in several job interviews related to .NET development, both as interviewee and interviewer. Which leads me to write this short list of suggestions.

1. Don’t ask .NET trivia questions.
We all know the .NET framework is huge. Too big for mere mortals to know it entirely. Hence it’s easy to create arcane, esoteric questions about some obscure part of it. Failure to answer these trivia questions only proves someone doesn’t know 100% of the framework, which frankly is most developers.

2. Be humble
I feel this applies to both sides of the interview. I’ve seen interviewers use their position to push around a candidate. It’s a real turn off, especially to experienced candidates.

3. Don’t ask the .NET Interview questions posted on Scott Hanselman’s blog
No disrespect to Scott Hanselman. I like the interview questions he’s listed (here and here). But they’re a victim of their own success. I’ve heard them asked in at least half the interviews I’ve attended since Scott posted that article. Think of questions related to skills and experience listed on the candidates resume.

4. Reply to questions with focused, short and related answers.
I recently interviewed someone who answered each question with a long, rambling and almost irrelevant answer. The less he knew, the more he talked. He start off trying to answer the question and ten minutes later was still going on some unrelated topic. Maybe he was really nervous. I think a good, general rule is to not speak for more than two or three minutes.

Here are a few of the questions I like to ask when I’m conducting a technical interview. I prefer questions that anyone can answer, from a recent college graduate to an experienced professional. Answers can be short and simple or can lead to in depth discussion.

What are your favorite books, websites, magazines, podcasts, conferences etc. related to software development?
Anyone with a passion for creating software can name several sources they use to improve themselves. The ones who can’t, are, in general, not growing and learning.

How does .NET manage memory?
Even a beginner should be able to talk about garbage collection and the stack versus the heap. More knowledgeable developers could discuss the various generation heaps, the large object heap, heap promotion, finalizer queue, weak references, GC.Collect, etc. It’s a question you can use to plumb someone’s understanding of .NET. For the record, I’m not an expert and thoroughly enjoy finding someone who thoroughly understands this topic.

How can you make a website fast and scalable?
I like this question because there are so many different answers. Webpages could designed to have a small footprint on the wire. Someone could discuss the scalability of webforms vs. asp.net MVC. Answers can be specific to webform, e.g. viewstate and outputcache. The discussion could focus on architecting a site with separation of concerns that allows different layers to be hosted on other servers. Answers can also involve hardware and network designs – clustering, load balancing, etc. People who have configured web servers can discuss the tradeoffs between compression, caching, memory usage, cpu usage, response size, et. al.

There’s a few other questions I like, which I’ll add to this post shortly.

Foreign Keys and Performance

Posted in Database on December 28th, 2009 by msposato – Be the first to comment

I recently had an occasion to research the impact of foreign keys on database performance. My assumption has always been that the benefits of data integrity provided by foreign keys was worth the performance cost. I general I believe this is still a valid assumption. However there are some situations were removing foreign keys or adding a NO CHECK option would make sense. For example, where IUD operations vastly outnumber read operations. In my experience this is rare. Usually joins and selects happen far more frequently. Obviously a profiling tool is necessary to make an informed decision. Also consider the end user’s expectations. Do they automatically expect an IUD operation to take longer than a read operation.

Since foreign keys are strictly for data integrity and not performance, I’ve made the assumption that foreign keys are also indexed. In a nutshell here are the advantages / disadvantages of foreign keys.

Advantages:

  • Referential Integrity – aka no orphaned rows.
  • FKs provide big hints to SQL Server’s query optimizer and to DB statistics, both of which lead to better performance.
  • FKs give structure to the data, literally they are the relations in relational databases. In turn, this allows ORMs and visualization tools to see the structure of the database.

Disadvantages:

  • Consistency must be checked on every insert, update and delete (IUD).
  • The index the index must be updated on IUD
  • Data has to inserted and deleted in a certain order.

Agile: Misconceptions, Definition and Perspective

Posted in Agile, Miscelleanous, Pragmatic Programming, Presentations on December 8th, 2009 by msposato – Be the first to comment

It’s unfortunate, but in my experience, Agile development is closely following the Gartner Hype Cycle. Furthermore, I’d guess that many teams are currently in the “Trough of Disillusionment”, perhaps considering Agile another overused buzzword in an industry full of buzzwords. In this post, I enumerate some common Agile misconceptions and, hopefully, offer a more reasonable perspective.

Agile Misconceptions

A common misconception is that Agile is a software development methodology. It’s a reasonable statement, and the sentiment is accurate. However Agile itself lacks the detail of a methodology. The Scrum methodology is most associated with Agile and seems to align itself with the principles of Agile, frequent, short iterations, collaboration, etc.

In recent experiences I have heard Agile defined as a particular development practice. For example, Agile is working in short iterations or Agile is automated testing. Again, there’s a nugget of truth here, but the answer is incomplete.

Other misguided perceptions are that Agile applies only to the IT department or that Agile is easy or at least easier. Clearly the former ignores Agile’s emphasis on collaboration and interaction.  Concerning the latter, Agile helps remove obstacles to better software, but does not involve less effort. I feel Agile often highlights weaknesses, like poor communication skills, or lack of commitment by the business. And those can be hard to fix.

Defining Agile

At a really abstract level, Agile is a philosophy. But I find it hard to sell a philosophy to management. So I use the definition is that Agile is a set of practices that embody the Agile Manifesto[1].  If you’re trying to sneak Agile into your shop, which I currently am trying to do, describe it a set of practices that follow the concepts of integrate, inspect and adapt. Senior management may especially appreciate the inspect and adapt part. I envision the Agile principles and practices being organized as follows[2]:

1. Individuals and interactions over processes and tools

  • Face to Face Communication
  • Code Reviews
  • Pair Programming
  • Close Proximity
  • Mentoring

2. Working software over comprehensive documentation

  • Test Driven Development
  • Continuous Integration
  • Unit Testing
  • Frequent Releases / Short Iterations

3. Customer collaboration over contract negotiation

  • Daily Meetings
  • Face to Face Communication
  • Close Proximity

4. Responding to change over following a plan

  • Frequent Releases / Short Iterations
  • Continuous Improvement

The figure below is a visualization of the above list.

Visualization of Agile Manifesto and Practices

The ideas of maximizing simplicity and self organizing teams need to fit in somewhere. I just haven’t figured out which principles they best embody.

I suppose any development methodology could be used with Agile, but, for me at least, the Scrum Methodology best compliments Agile.

Agile In Perspective

Agile is a means to an end. That end, of course, is better software. Software that meets the customer’s needs and is reliable, maintainable, secure, etc. The end game is not to be Agile, but to create better software.

When Agile was conceived in 2001, it was in response to rigid, structured methodologies that emphasized documents, specific roles for people, well defined phases, milestones, etc. These methodologies seemed generally inconsistent with how software was actually created, or should be created. Nor did these methodologies embrace change, a reality in most line of business applications.

Eight years after conception, many places would not call themselves Agile. However I would venture to guess that many of those places have adopted Agile practices, for example unit tests, or shorter releases. If Agile isn’t mainstream, many of its practices are.

Most of what I’ve discussed thus far is at the project level. For developers, many Agile practices existed before Agile. Two years prior to signing the Agile Manifesto, Andrew Hunt and David Thomas wrote The Pragmatic Programmer.   Many of the practices they discussed would now be called Agile practices. To find out more about Agile developer practices I would direct you to either The Pragmatic Programmer or Practices of an Agile Developer.


[1] I wish the Communists didn’t have a manifesto. To me, it ruined the word.

[2] The numbered items are from the Agile Manifesto. The bulleted items are practices that support the concept.

Using ValidationGroups in Dynamic Data Prior to .NET 4.0

Posted in .NET, ASP.NET, ASP.NET Dynamic Data, C#, ValidationGroup on December 3rd, 2009 by msposato – Be the first to comment

In ASP.NET webform pages, validation groups create sets of controls that are validated separately from other controls. For example, on the same page, one set of controls could be validated when inserting a new product, while a separate group of controls are validated when searching for a product. More information is available here.

The current (.NET Framework 3.5 SP1) Dynamic Data controls do not have the ValidationGroup property. This is problematic when there are different sets of DynamicValidator and ValidationSummary controls on the same page. For example, controls for managing products and product subcategories might be on the same page and each set of controls would have validation (required fields, date format, etc.). But without the ValidationGroup property, validation errors in one set of controls would show error messages in both ValidationSummary controls.

Starting with the .NET 4.0 Framework, ValidationGroup will be a property of the Dynamic Data controls. However it is possible to use validation groups without the entire 4.0 framework. Here’s how.

First, download and unzip ASP.NET Dynamic Data Preview 4.

Second, from a Dynamic Data web application remove the existing references to System.ComponentModel.DataAnnotations.dll and System.Web.DynamicData.dll. Then add references to the following assemblies, which are in the  DynamicDataPreview4\DynamicDataVNextSamples\CommonFiles directory.

  • Microsoft.Web.Extensions.dll
  • System.ComponentModel.DataAnnotations.dll
  • System.Web.DynamicData.dll

You’ll have to decide if the risk of using preview assemblies is worth the benefit of extra functionality. Personally, I’ve had no problems with the preview assemblies and would use them until I upgraded to the 4.0 framework.

Third, you will need to update the version number of the System.Web.DynamicData assembly in  the web.config file. The version number must match the one being referenced. In the system.web/compilation/assemblies node, change

<add assembly=”System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

to

<add assembly=”System.Web.DynamicData, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

And in the system.web/pages/controls node change

<add tagPrefix=”asp” namespace=”System.Web.DynamicData” assembly=”System.Web.DynamicData, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

To

<add tagPrefix=”asp” namespace=”System.Web.DynamicData” assembly=”System.Web.DynamicData, Version=99.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″/>

Last, add the ValidationGroup property to the Dynamic Controls. Attached to this post is an example page with two sets of Dynamic Data controls. One set is for products, the other for product subcategories. The DynamicField, CommandField, ValidationSummary and DynamicValidator controls are in their respective ValidationGroup, which as expected eliminates cross validation.

ListDetails.aspx

Upcoming Presentations

Posted in Presentations, Speaking on July 31st, 2009 by msposato – Be the first to comment

In the fall I have the privilege of presenting at the following events.

If you’re attending one of these events, please introduce yourself.

Thank You

Presenting to the Richmond Software Craftsmanship Group – July 30th 2009

Posted in .NET, ASP.NET, ASP.NET Dynamic Data, C#, Miscelleanous, Presentations on July 29th, 2009 by msposato – Be the first to comment

Tomorrow I’m leading a discussion on ASP.NET Dynamic Data to the Richmond Software Craftsmanship Group. Part of this discussion will likely compare and contrast with scaffolding in other frameworks, like Ruby on Rails. Also we’ll discuss and demonstrate some useful applications of scaffolding. I’ve attached my presentation slides and the demo projects.ASP.NET Dynamic Data Presentation

ASP.NET Dynamic Data Presentation – Powerpoint slides

Dynamic Data Website – no customizing

Dynamic Data Website – with customizing

Photo courtesy of Kevin Hazzard

Photo courtesy of Kevin Hazzard

Creating Random Names and Dates

Posted in .NET, C# on June 19th, 2009 by msposato – Be the first to comment

Often, website demos are more compelling when using a copy of production data. However, my current client has no production data. Nonetheless, I want to give them a realistic view of my work. So I needed to create a great deal of realistic looking data.

I began by creating random Customer objects. For the first and last names I could have created random strings. But this particular client would be distracted by the random character names. Silly I know, but that’s my reality sometimes. First names are often either female or male, so the firstnames collection is an IDictionary. The key is the first name and the char is the gender, either ‘M’ or ‘F’. This links a name with its typical gender. I wrote extension methods to return a random element from the firstname and lastname collections. The last extension method generates a random date for the DOB. This extension method accepts another date, figures out the number of days between the two dates, let’s call this value x, and adds a random number of days between 0 and x to the lesser date to create a new random date, which should always be something between the two date values.

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using JCS.Model;
 
namespace LoadTestData
{
  internal class Program
  {
    private static readonly string connection = ConfigurationManager.ConnectionStrings["XXXAAA"].ConnectionString;
 
    // class variables so they can be used for other names, e.g. parent names
    private static readonly Dictionary<string, char> firstnames = new Dictionary<string, char>
      {{"Troy", 'M'},{"Jamal", 'M'},{"Alicia", 'F'},{"Gabriel", 'M'},{"Christian", 'M'},
      {"Benjamin", 'M'},{"Gavin", 'M'},{"Jose", 'M'},{"Brandon", 'M'},{"Dylan", 'M'},
      {"Victoria", 'F'},{"Savannah", 'F'},{"Riley", 'F'},{"Hailey", 'F'},{"Nevaeh", 'F'},
      {"Lily", 'F'},{"Kandis", 'F'},{"Dominique", 'F'}};
 
 
    // class variables so they can be used for other names, e.g. parent names
    private static readonly List<string> lastnames = new List<string>
      {"Scott","Stewart","Sanchez","Morris","Rogers","Reed","Cook",
        "Morgan","Bell","Murphy","Rivera","Ward","Peterson",
        "Watson","Brooks","Bennett","Wood","Henderson","Jenkins","Sanders","Cox"};
 
 
    static void Main()
    {
      Random random = new Random(DateTime.Now.Millisecond);
      DateTime minCustomerDOB = new DateTime(1940, 1, 1);
      DateTime maxCustomerDOB = new DateTime(1989, 1, 1);
 
      string firstname = firstnames.RandomKey(random);
      var customer = new Customer
                       {
                         FirstName = firstname,
                         LastName = lastnames.RandomElement(random),
                         Gender = firstnames[firstname],
                         DOB = minCustomerDOB.RandomDate(maxCustomerDOB, random)
                       };
 
      using (var context = new JCSDBDataContext(connection))
      {
        context.Customers.InsertOnSubmit(customer);
        context.SubmitChanges();
      }
    }
  }
 
  public static class Extensions
  {
    static public TKey RandomKey<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, Random random)
    {
      int i = random.Next(0, dictionary.Count - 1);
      return dictionary.ElementAt(i).Key;
    }
 
    static public T RandomElement<T>(this List<T> list, Random random)
    {
      int i = random.Next(0, list.Count - 1);
      return list.ElementAt(i);
    }
 
    static public DateTime RandomDate(this DateTime min, DateTime max, Random random)
    {
      int days = (max - min).Days;
 
      // use absolute value in case max is lesser than min
      int i = random.Next(Math.Abs(days));
      DateTime ranDate = min.AddDays(i);
 
      //maybe the max date is actually lesser than the min date.
      if (max < min)
        ranDate = max.AddDays(i);
 
      return ranDate;
    }
  }
}

Presenting to the Richmond Software Craftsmanship Group

Posted in Uncategorized on June 17th, 2009 by msposato – Be the first to comment

On Thursday 06/25 I’m leading a discussion at the Richmond Software Craftsmanship Group. The meeting topic is ASP.NET Dynamic Data. The discussion will likely compare and contrast the Dynamic Data scaffolding to other implementations, such as Ruby on Rails.

This presentation was rescheduled for July 30th, 2009.

Charlottesville .NET User Group Meeting 06/18

Posted in Uncategorized on June 17th, 2009 by msposato – Be the first to comment

Justin Etheredge will present “Building Testable Applications” to the Charlottesville .NET User Group tomorrow (06/18). The meeting will be at the SNL Headquarters in downtown Charlottesville from 6-8PM. Everyone is welcome.

SMTP Testing – without a live server

Posted in software testing on May 5th, 2009 by msposato – 1 Comment

I recently needed to test email functionality in my application. Normally I’d point to a SMTP server, like smtp.gmail.com, and go at it. However the message was being sent from a content management system (CMS) that was difficult to configure locally with the ssl required to send a message to gmail or my usual smpt server. Instead I found papercut, by Ken Robertson. When running, it listens on the default SMTP port (25), or whatever port you tell it to listen. It intercepts the message, allowing you to inspect the contents, headers, etc. Both the binaries and source code are available. Thank You Ken Robertson.