July 2007 Entries

Configuration Free JSON with WCF and AJAX in Visual Studio 2008 Beta 2

With all the out-of-band technology releases we've had (ASP.NET AJAX, .NET 3.0), it's nice to reach a point where we can bring them all together. As an example... Create a new web site in Visual Studio 2008. This will have to be a website under IIS, unfortunately, for reasons I'll point out later. Once the web site is up, add a new item – a WCF service. The service contract can look like the following: [ServiceContract(Namespace="http://OdeToCode.com/ws",                  Name="ServerProcessInfo")] public interface IServerProcessInfo {    [OperationContract]     IEnumerable<ProcessInfo> GetRunningProcesses(); } The data contract can look like so: [DataContract] public class ProcessInfo {     [DataMember]     public string Name { get; set; }     [DataMember]     public long WorkingSet { get; set; } } Finally, the LINQish...

Some Cool Software You Might Not Know About

Sahil's post on "Things I can't live without" got me thinking about some software I use that might not be so well known. ...

ASP.NET and Separating Concerns

Ayende had a recent post with the following quote from Nicholas Piasecki: To me, this discussion all boils down to one thing: the foreach loop. Let's say you want to display a table of sales reports, but after every tenth row, you want to print out an extra row that displays a running total of sales to that point. And you want negative numbers to appear in red, positive numbers to appear in green, and zeros to appear in black. In MonoRail, this is easy; with WebForm's declarative syntax, just shoot yourself in the face right now. Most solutions I've seen...

Rockville User Group

RockNUG is the newest .NET user group in the vast suburbia of Washington D.C. Their next meeting is on August 8 at Montgomery College, and I'll be there to talk about ASP.NET AJAX. I have one WF book and one Pluralsight T-shirt to give away, too. Come for the free pizza, and stay for the asynchronous fun!

Unit Testing with Visual Studio 2008

Unit testing features will now be available in the Professional version of Visual Studio 2008. Unit testing has been to Visual Studio what Barry Bonds has been baseball – a center of controversy. First there was the Peter Provost petition to include unit testing features in all version of VS. Then there was the highly criticized TDD guidance accompanying the feature. Next came some performance issues and pain while using the shipping version, and most recently, the TestDriven.NET hullaballoo added an emotional charge to the air. Putting all this behind us - what's new in 2008? I've been working...

Automatic Properties

I wrote my first class with automatic properties in Orcas today... [DataContract(Name="FoodFact")] public class FoodFactMessage {     [DataMember]     public int ID { get; set; }          [DataMember]     public string Name { get; set; }     [DataMember]     public int Calories { get; set; } } ... then I found myself staring at the screen. It's an interface! No,it's a class!Wait, it is a class! I'd say the syntax is still growing on me. I'm sure some people will say – why use properties at all? If you don't need special code in the get and set methods – why not just use a public field? The quick answer is: reflection. There are many forms of magic that...

ASP.NET and ASP.NET AJAX Double Feature

Come join Fritz Onion and myself at a Pluralsight double feature in southern California. Starting October on 22nd, we'll cover everything from JSON spitting web services to the Sharepointy magic of ASP.NET 2.0 web parts. It's more than a class … it's an experience (and fun, too)!

The Better Developer Thing

Raymond tags me in every blogging meme, which is great. If it wasn't for Raymond, I wouldn't get to play along. The current meme is "what I will do to be a better developer in the next 6 months". Bettering is a tough topic to write about, because there are so many ways to get better. Interviewing Skills Not interviewing for jobs, but interviewing candidates. Although interviewing isn't strictly a development job – it is a job I am occasionally tasked to do. Good interviewing skills can help you build a great team and contribute to the success of a project...

Terminals

If you are a heavy user of remote desktop connections, and you haven't tried Terminals, then give this free, open source utility from CodePlex a try. "Terminals is a multi tab terminal services/remote desktop client. It uses Terminal Services ActiveX Client (mstscax.dll).The project started from the need of controlling multiple connection simultaneously." One of the great features in Terminals is the ability to set up a "group". One click on a group can open multiple RDP sessions at once. Terminals can also auto-scale a remote desktop to the window size, and setup a default desktop share for drag and drop operations...

Closure On JavaScript Closures

At the end of the last post, we looked at a function named createDelegate. The createDelegate function constructed a nested function named shim, and shim created all the magic we needed to invoke an object's method during a button click event. In this post we'll finally put the topic to rest. First, we have to cover an important topic: scope. Scope A variable's scope defines where the variable can be used. In JavaScript there is really only local scope and global scope. Notice that local variables will hide global variables of the same name. var x = 10; function f() {         {         // no block scope in...

Putting Function.apply() to Work

In the last post I demonstrated how you can fiddle with the this reference during a method invocation using Function.call and Function.apply. After reading that post, you should understand why Function.apply was the most interesting method to us. It's because we can use apply() to specify the this reference for an arbitrary target method, and also pass-through an argument list to that target method via the arguments identifier. With the above understanding in place, let's look at the following code. <input type="button" id="submitButton" value="Press Me!" /> <script type="text/javascript">     function MagicButtonManager(buttonId, message)     {         this._message = message;         var btn = document.getElementById(buttonId);                  btn.onclick = // what do we here...

Function.apply and Function.call in JavaScript

In order to explain how the createDelegate function works in the last post, we have to understand JavaScript closures and Function.apply(). The apply() method is the easiest subject to tackle, so we'll start there and work up. ...

JavaScript's Slippery this Reference and Other Monsters in The Closet

One problem in WWWTC # 16 is the assumptions Estelle makes about this. In C# you don’t need to explicitly use the this keyword to reference an instance field from inside an instance method. It’s tempting to write a method like Estelle’s … InputManager.prototype.resetToInitialValue = function() {     _input.value = _initialValue; } … only to find out the method tries...

What’s Wrong With This Code (#16)

It’s been some time since the last WWTC, but Estelle Hertz is still cranking out software. This time Estelle was asked to write some JavaScript code for a web page with hundreds of textbox input controls (the page collects details for a life insurance policy). When a user double clicks on any textbox on the page, the textbox should reset itself to its initial value (the value in the control when the page first loaded). Estelle has yet to experience all the slippery pitfalls in JavaScript development, and writes the following code: <%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <body>     <form id="form1" runat="server">         <div>             <input id="Text1" value="default"...

A System.Configuration Object Represents a Merged Configuration View

Look! Actual ASP.NET content is back! The documentation for WebConfigurationManager.OpenWebConfiguration says: "Opens the Web-application configuration file as a Configuration object using the specified virtual path to allow read or write operations." This might lead you to think you'll only find stuff from a single web.config file in the returned Configuration object - but this isn't true. The following code will return the extensions and paths mapped to the web forms PageHandlerFactory for "MyWebSite". IEnumerable GetPageHandlerFactoryExtensions() {     string sectionName = "system.web/httpHandlers";     string pageHandlerFactoryName = typeof(PageHandlerFactory).ToString();     Configuration config =         WebConfigurationManager.OpenWebConfiguration("/MyWebSite");     HttpHandlersSection handlersSection = config.GetSection(sectionName)                           as HttpHandlersSection;     foreach (HttpHandlerAction httpHandlerAction in handlersSection.Handlers)     {         if(httpHandlerAction.Type == pageHandlerFactoryName)         {             yield return httpHandlerAction.Path;         }     }       } ... and you should at least...

We Hold On

It's common behavior in the technology arena to hold on and wait for the next big thing. Sometimes we wait for bug fixes. Sometimes we wait for new features. It's not just software – I've waited for phones and TVs because I know the next generation will be so much better. Have you ever picked up a piece of hardware or software and said, "this is perfect - I can't imagine anyone ever making this better?" If so - how long did that feeling last?

Malignant Narcissism

I've been thinking about getting a MySpace page, but first I need a good design. What do y'all think of this? ...

Scott Allen
Posts - 869
Comments - 4493
Stories - 14