Excellent article on Scrum and time-boxed concepts from MSDN.
Download outline on SCRUM presented at the Campus Web Publishers meeting in UCLA.
So last couple of posts I have been talking about the new Dynamic Data features in .NET 3.5 SP1. Specifically I am talking about the dynamic scaffolding feature which automatically builds a CRUD operation page directly from the EDMX model. So last week I wrote a post on how to make certain tables readonly.
To reiterate, you would do something like this:
[ReadOnly(true)]
public partial class Course {
}
… and add the rest of the code discussed in my earlier post into your Global.asax. And Course would then become readonly. Unfortunately, if you do this you’ll all parent tables that has a relationship to the readonly table will no longer show a ForeignKey reference dropdown.
What that means is, if you have a table say Enrollment which has a many-to-many relationship to course, the dynamic data relationship manager is not going to give you a dropdown for all the course when you open up an enrollment, like it is supposed to. And the reason for this is that you’ve made the Course table readonly-which prevents FieldTemplate to pull up the ForeignKey_Edit.ascx template, so the ForeignKey.ascx comes up which is just a literal control.
Project Natal for Microsoft Xbox will completely change the way we play games. There’s is no controller-you are the controller-and you thought Wii was cool!
So we’ve been working really hard on restructuring our code base and our branching pattern. I’ve spent a lot of time reading various books and articles on best practices for branching patterns and source control management. There’s two ideas that I would like to share with you today that I’ve found very useful.
How many branches should you have?
Turns out this is a fairly complex question. The answer in short is: as few branches as you can possibly live with. If your programming practice works with a single branch-great! Don’t change anything – just because people have a production branch, mainline branches, a trunk and all that – you don’t need it. If your projects and project management practices are supported through a single branch continue on. But! If you are having issues and would like to streamline the process then the answer is tricky. So couple of weeks ago this is where we were. Our branching structure was getting out of control and we needed to come up with a way to branch better.
So we started off with a single branch, a mainline branch. The policies for the branch was that: the code builds, there are unit tests at least for all data access functions, and that the code completes a user story.
Since we had already moved to SCRUM, it meant that the mainline branch contain code with completed features only. If you’ve read about SCRUM you know that you cannot start or work on anything else until your user story is completed in full. So that’s what we have on the mainline are bunch of fully completed user stories.
But we have a problem! If we were to only check-in our code when we completed a user-story it could potentially be days without any code checked in. This is a potential problem because the longer you wait to check-in code the worse the merging situation becomes, there’s a greater chance that the integration will fail, and your developers have unchecked in code, which is never a good idea. We wanted to be able to commit as often as possible but the policies on the mainline branch did not allow us to do that. So we created another branch which we called the working branch–and the policy is simple: the code should build. That’s all. It does not even have to be unit tested, the idea is if you are done with a small function, check-it in-so that the continuous integration process builds the project (CruiseControl.NET) can kick in.
It’s important to keep both the mainline and the working line in sync. The working branch should be at most 2-3 days away at most-anything more you are risking merging issues which can become a full-time job.
So finally, we have a production branch which holds the production line. If major issues come up that needs to be fixed in production immediately we create a hotfix branch directly from production, fix the issue, and merge the hotfix with our mainline and working branches.
Which files-types should I check-in?
The last thing I wanted to talk about was on what files should be checked-in to your repository. Fortunately the answer to this is simple: if you can generate the file in some automated fashion then don’t check it in, make it part of your build process. If you cannot, then go ahead check-it in. So for instance, DLLs should be checked-in, if you can build them and create the DLLs. Simple enough!
So couple of days ago I talked about the new ADO.NET Entity Data Model. The Entity Data Model sometimes also referred to as the Entity Framework can also be used with the new Scaffolding feature that’s available in .NET 3.5 SP1. Scaffolding allows the run-time engine to build a CRUD (Create, Read, Update, Delete) operation system for a given model. However, it is often times useful to include a model just for viewing purposes not for editing or deleting – which is a behavior that comes in by default with the scaffold operation. In order to to that you can simply edit the Global.asax file and before the default routing code add the following lines of code:
#region Readonly tables
var visibleTables = from t in MetaModel.Default.Tables
where t.Scaffold == true
select t;
var readOnlyTables = new StringBuilder();
foreach( var table in visibleTables ) {
var isReadOnly = table.Attributes.OfType<ReadOnlyAttribute>().
DefaultIfEmpty( new ReadOnlyAttribute( false ) ).
FirstOrDefault();
if( isReadOnly.IsReadOnly )
readOnlyTables.Append( table.Name + "|" );
}
routes.Add( new DynamicDataRoute( "{table}/{action}.aspx" ) {
Constraints = new RouteValueDictionary( new
{
action = "Edit|Insert",
table = readOnlyTables.ToString().Substring( 0, readOnlyTables.Length - 1 )
} ),
ViewName = "Details",
Model = model
} );
#endregion
Basically using LINQ this code goes through all the tables in the MetaModel (which holds all the models in a given namespace) and looks for the [ReadOnly(true)] attribute for each of the classes. If there’s a table found with the ReadOnly attribute the Edit/Delete operation is re-routed to the View Page (Routing is also a new technique that’s available in .NET 3.5 SP1).
Some excerpts of this code taken from Stephen Naughton’s blog.
If you use Subversion, please take a moment to nominate it for the Community Choice Awards. I think it’s one of the best open source products out there.
If you’ve used the ADO.NET Entity Data Model to generate some models from your database schemas you’ll have noticed that sometimes ADO.NET assigns primary keys that does not necessarily correlate with your database schema. This is specially true if you are pulling from a view that has several joins. For instance, notice in this model the Term, the SrsNumber and the CatalogNumber is marked as the primary keys (Course happens to be a View in this case):

But in reality, the actual table the view pulls from only has Term and SrsNumber marked as the primary keys. So what’s going on? Turns out the ADO.NET Entity Data Model assigns primary keys to all non-null columns.
If you have the freedom to correct this in the database schema then that’s one solution to mark columns nullable otherwise you’ll have to manually adjust the CSDL (Conceptual Schema Definition Language) file manually. More on that tomorrow.
“Internet knowledge” can be scary. It’s not about how much you know about the internet, but rather the knowledge you gather using the internet.
Internet knowledge tends to give the impression of knowledge about a certain topic, which is one of the reasons why Wikipedia is so successful. For instance, Wikipedia explains Kleene star in less than one page. Yet anyone who has taken a class in complexity theory must have felt those sleepless nights on K* problems–the problems so elegant and simple yet so hard to come up with a solution. In most cases reading from the internet only give you a very basic high level overview of a certain topic. It almost seems like common sense when I say this, but people don’t seem to realize that when they learn about Tuberculosis in under five minutes that their knowledge is basic.
This has given birth to a slew of so-called internet engineers. Their knowledge about software development starts from reading the internet.
Google plays a huge role in this. The Google search engine is simply amazing. If a web developer is stuck he/she issues a search gets back bunch of code, integrates it somehow to his/her problem and there you have things start working. That’s an issue. Developers don’t have the basic understanding, concepts like inheritance, and polymorphism seems like alienated words-yet they are using it everyday in the .NET framework. So I fear this has spawned a culture of believe that we are an educated society.
No knowledge is better than some knowledge. Yes, I didn’t type that incorrectly, I did mean to say no knowledge is better than some knowledge. If you don’t have any knowledge about something it’s very easy to accept it. But if you have some knowledge, then it’s really hard to gaze how much you know. Because relatively, from the point you didn’t know anything – to the point you know something, you actually know infinitely more, even though the knowledge may be 5% of the actual topic.
So what does that mean? Don’t use the internet, don’t use Wikipedia, don’t use Google? No, not at all. Absolutely use these tools, these tools help shape our lives but keep in mind the breath of knowledge you’ve gained. That’s the key.
If you’ve ever worked on an intranet site, you often want to know, programmatically, if a client that’s accessing your website has the ability to automatically login to your site (Integrated Windows Authentication). With Integration Windows Authentication, Windows can basically send (as a HTTP header) the currently “logged on” username. So your application can access this LOGON_USER HTTP header and go from there.
I won’t get into the details of how to setup integrated windows authentication, but basically the idea is you go into IIS and for a given resource (a folder or a file) on your site you change the directory security to Integrated Windows Authentication. Once this is done, when a client visits your local site (the definition of local depends on the gateway or group policy), IE switches to the “intranet site” profile which allows the automatic authentication. That’s the broad picture. But unfortunately, if the same users visits that same website from another location, say from their home, they will end up getting the ugly NTLM authentication box – and most of the times they don’t know what to do. Partly because their experience has changed, at work they were simply “logged in” without doing anything and now they have to login and often times need to prefix their username with domainusername format. That’s not good.
So it’s useful to be able to find out programmatically if integrated windows authentication is available, if it is then you simply login using the integration authentication, otherwise you provide the user with a clean and simple forms authentication system. So let’s start with some JavaScript code:
var autoLogin=true;
try {
var dom = new ActiveXObject("Msxml2.DOMDocument");
dom.async=false;
dom.load("ntlm/spacer.gif");
}
catch(e) {
autoLogin=false;
}
}
The code makes an AJAX call to a resource that you know is locked with integrated windows security. If the AJAX calls succeeds you know that your client has integrated authentication get to the resource. If it does not you know something’s wrong, either they are using FireFox, or perhaps they are at home, whatever the case, your client cannot get to the resource without authentication. This is great, but we don’t want the user to see an error message when the AJAX call fails so we wrap it around a try/catch block. The catch block essentially sets the autoLogin=false because something did not work out. That’s it – that’s a nifty little trick to check if your users can use integrated windows authentication.