A new semester, a new capstone project
11 January, 2013 § 3 Comments
This is the first week of a new semester at Michigan State University, and with that brings a new group of students who will be working on a senior capstone project with Mozilla.
This semester the students will be focusing on multitouch gestures within the browser. They’ll start out the semester by fixing a few good-first-bugs, then they’ll move on to adding some gestures to standalone image and video documents. The final step of the project will be to focus on improving our pinch-to-zoom for webpages in Firefox.
As the semester progresses, the students will be blogging their progress on their own blogs (I may crosspost them here from time to time):
Brandon Waterloo: http://brandonwaterloo.wordpress.com/
Raymond Heldt: http://heldtray.wordpress.com/
Bill de Araujo: http://spartanfire.wordpress.com/
Here’s to a great semester!
Identity theft with Comcast?
28 November, 2010 § 1 Comment
Over the holiday weekend, the cable box in my house stopped working. The user interface for the cable box functioned fine, but the picture and audio were completely gone. I brought the cable box to Comcast and swapped it with one that they had in stock for no charge.
The next day I hooked up the cable box and called Comcast to sync up the box with their licensing service. When I was on the phone with them, the operator mentioned that there was a pending service order in a couple days and they could do the work then if that wasn’t a problem. Weird, nobody here knew anything about this service order.
Somehow there was an order in for telephone and cable service upgrades/installation. The phone number they had on file as requesting this service had nothing to do with us. Googling the phone number got us a name and address of a house in the next city over. It goes without saying that we promptly got the service order cancelled.
In the end, I’m happy that we noticed this before it happened.
Could we be a victim of identity theft? How could an order like this be placed on our account? What would have happened if we hadn’t noticed?
Thank you Tom Izzo
16 June, 2010 § Leave a Comment
Thanks Tom. These past few days have brought a community and state together for a common cause that will most likely be forgotten about when Midnight Madness comes around.
Often times a coach of a college basketball team has to help his players choose if they should leave college for the pros, and just recently Izzo got to trade places with his students (not for the first time though).
Izzo could have decided to leave East Lansing and move down to Cleveland to coach arguably the best professional basketball player right now. But he didn’t.
As an MSU student and alumni, I am glad that Tom decided to stay at MSU. The basketball program has helped the university tremendously, and much of the thanks go to Mr. Izzo and his family.
Unit testing code behinds in ASP.Net Web Forms
13 June, 2010 § 5 Comments
Have you ever inherited an ASP.Net website with waaaaaaay too much logic in the code behinds?
A while back I came up with a solution to solving this problem. I don’t have a name for it, but if you do, please leave a comment at the end of this post.
The problem that I was trying to solve is that I wanted to make a new page and implement it using Test Driven Development. The hard part was that there was a lot of code that basically dealt with the visual aspect and interaction of the page but not much with the data model. I needed to find a way to write tests around this code, as the data model code already had a framework for writing tests.
Here is an example of the before-case:
public class CodeBehind : System.Web.UI.Page {
protected void btnFindUser_Click(Object obj, EventArgs e) {
if (Page.IsValid) {
var dbConnection = new DatabaseConnection();
var users = dbConnection.GetUsers( txtQuery.Text );
if ( !users.empty() ) {
dataTable.Bind( users );
}
}
}
}
What I came up with was an introduction of a “controller” class that lived outside of the ASP.Net Web Forms project. Here is an example of the after-case:
// CodeBehind.aspx.cs
public class CodeBehind : System.Web.UI.Page {
protected void btnFindUser_Click(Object obj, EventArgs e) {
controller.FindUser( Page.IsValid, txtQuery.Text, dataTable );
}
}
// CodeBehindController.cs
public class CodeBehindController {
public void FindUser( bool pageIsValid, string query, DataTable dataTable ) {
if ( pageIsValid ) {
var dbConnection = new DatabaseConnection();
var users = dbConnection.GetUsers( query );
if ( !users.empty() ) {
dataTable.Bind( users );
}
}
}
}
// CodeBehindControllerTests.cs
public class CodeBehindControllerTests {
public void FindUser_WithNoUsersFound_DataTableIsEmpty() {
DataTable table = new DataTable();
CodeBehindController controller = new CodeBehindController();
controller.FindUser( true, "ImpossibleUserToFind", table );
Assert.IsTrue( table.empty() );
}
}
With that, I can now mock out the DatabaseConnection and the DataTable and I’m good to go. By passing in Page.IsValid instead of the whole Page object, I’m able to provide types that are easier to instantiate and I also now have code with less dependencies.
Getting this to work is actually very simple. Just introduce another class and put all of your logic in that class. There shouldn’t be a single conditional in your *.aspx.cs page. As long as you follow this pattern, it should be pretty easy to TDD your next ASP.Net Web Forms page.
Any questions? Leave a comment and I’d be glad to help.
Code Jam programming competition
11 April, 2010 § 2 Comments
I found out about the Google Code Jam programming competition this past week through Reddit and registered for it. It’s my first programming competition so I’m pretty excited to see how it turns out.
I’ve started to go through the practice problems listed on the site and completing them as though they are part of the competition. As I compete them, I’ll upload my solutions to the problem. Since these solutions are written in haste and I don’t plan on making the code maintainable, for your own benefit please don’t copy the code and use it in an actual production scenario.
The first problem that I have solved is the Alien Numbers problem from April, 2008.
The decimal numeral system is composed of ten digits, which we represent as “0123456789″ (the digits in a system are written from lowest to highest). Imagine you have discovered an alien numeral system composed of some number of digits, which may or may not be the same as those used in decimal. For example, if the alien numeral system were represented as “oF8″, then the numbers one through ten would be (F, 8, Fo, FF, F8, 8o, 8F, 88, Foo, FoF). We would like to be able to work with numbers in arbitrary alien systems. More generally, we want to be able to convert an arbitrary number that’s written in one alien system into a second alien system.
See if you can solve this problem. Then continue reading to see my solution.
« Read the rest of this entry »