If we didn’t have loops

February 27, 2007

I've stumbled upon this article which explains how to implement delegates in Java. The issue of implementing things we have taken for granted  reminded me of a course I took a few years ago, in a language called Scheme, which is a variant of Lisp. Scheme is a functional language, and has a very recursive nature. It has no loops. As exercises at this course, we had to implement things such as While and For loops and add them to the Scheme interpreter. This made me think of how I would implement loops if didn't have them at C#. I...
tags: ,
no comments

ASP.NET Url Rewriting

ScottGu has posted a great article about Url Rewriting, which basically allows you to replace addresses such as www.mysite.com/games.aspx?gameid=HalfLife with www.mysite.com/games/HalfLife. He pretty much covers everything you would want to know on this very useful technique.And a bonus - a very interesting architecture discussion has developed at ayende's. Dig in.
tags:
2 comments

Unit Testing is Fun

February 24, 2007

As I've said in a previous post, I've been playing with unit-testing lately, trying to write up some classes and tests for them as I go along. I found this to be a really enjoyable experience. The tests help me understand what's going on in my code better, and they actually make me write better, and more correctly-structured code. Coupled code with too many dependencies is hard to test - by having to write tests as I go along I somehow force myself to think of a better design. This also made me feel like up until now I...
tags:
no comments

ASP.NET 2.0 CodeBehind

February 23, 2007

I've always found the new CodeBehind model of ASP.NET 2.0 to be a bit confusing. What I like to do with confusing things that I want to remember and understand better, is to write them down. Here we go. Of the top of your head, which classes will be generated by ASP.NET for the following WebForm? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tester.aspx.cs" Inherits="Tester" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server"...
tags:
no comments

Using ASP.NET Cache in Non Web Applications

February 16, 2007

I'm a unit-testing newbie, but I'm trying to get into it (as I realized, one day, how scared I was to change working code someone else wrote a long time ago). Trying to test some of my code using NUnit failed completely, since that code tried to cache stuff, and the calls to HttpContext.Current.Cache threw a null reference exception. Well, silly me, of course that wouldn't work. There's no HttpContext when the unit test is running (it's not running in a web application), and therefore no Cache object. Or is there...? Apparently you can use the ASP.NET cache in...
tags: ,
no comments

Debugging a Windows Service: Windows 2000 Issue

At work we had to create a windows service for a certain purpose. We were glad to find out that Visual Studio allows you to easily create one of those and install it using the installutil command. When we tried to debug our service, which was running on our local Windows 2000 systems, we ran into some problems. The first one is well known - you can't debug the service unless it is started already*, so how do you debug the entrance to the service - the OnStart method? There are many solutions for this, we solved it with...
no comments

The Bug and You

February 12, 2007

One thing I learned over the years is that programming can tell you a lot about yourself, and even improve you as a person. Can you handle intense pressure? Can you make the impossible possible by finding creative solutions? Imagine the bug of your nightmares creeping into your code days before the deadline. This bug, like all really annoying bugs, is happening randomly, caused by no apparent reason, and is impossible to solve. Think segmentation-faults in your university C++ project 10 hours before it's due (and of course, at first it looks like the error happens only you're looking away from...
no comments

No Excuse

February 9, 2007

Recently, I've encountered the following code, in a commercial API for a software that costs dozens of thousands of dollars. Now you don't need to know what this method is supposed to do, all you need to know is that Geometry is an abstract base class for all types of, well, geometries, and Point inherits from Geometry. public DataTable Identify(Geometry geom) { //... Do some stuff ... if (!(geom is Point)) ...
tags: ,
one comment

Historical Notes

February 5, 2007

Today my teammate Matan has sent me a piece of code I wrote a while ago, which he had to read for some reason.The code had the following comment://Changed by Doron Yaacoby: 9/7/2006, WC Finals. Forza Italia!!!I love to leave amusing little comments in my code, especially on special occasions/circumstances.  It's always fun to look back later at the code and reminisce in that little piece of history. Nostalgia is always a fresh breath of air, especially if you're trying to fix something in an old piece of code. Also, if you're debugging someone else's 3 years old code,...
tags:
no comments

Wiz Kid

February 3, 2007

Check this out. This 14 year old kid called Shachar has lectured about Windows Vista in front of a crowd of grown-up professionals at the Microsoft Developer Academy a few days ago (which I attended and really enjoyed). Man, when I was 14 I barely knew what an operating system does. And they say today's youth spend all their time watching TV and IM-chatting...
tags:
no comments