Thursday, June 29, 2006

Emitting Code, Mind Your Language

{

Caught sight of a post over at Jeff Atwood's Coding Horror blog in which he demonstrates some of the clunkiness of using object libraries while coding. His example is as follows:

Let's say you wanted to generate and render this XML fragment:

<status code="1"><data><usergroup id="usr"></data>

He then shows the 17 or so lines of code it takes to do it with System.Xml objects and shows an alternative with Response.Write and a String formatter:

string s = @"<status code=""><data><usergroup id=""></data>";
Response.Write(String.Format(s, myCode, myUserGroup));

What he was getting at seemed fairly intuitive but a firestorm erupted over his berating those who considered the use of Response.Write and other more terse approaches over object models as second class or "dreadful citizenry."

Of course the big pitfall of his example is that it can be easily broken if the variables used in a Response.Write approach to generating xml contain unescaped or "bad" charactes. The object proponents jumped on this and hammered at how stuff like this works for a "trivial" example but it leaves an aweful exposure for "real world" applications. I'm always annoyed by that word "trivial" because those that use it tend to abuse it for the sake of complexity and overengineering. On the other hand, if you look at my previous post, I'm no stranger to bad characters and encoding issues (trust me, the pain has been dealt!). But I think what this discussion points to is something that is near and dear to my heart: language itself.

It didn't take long for a Ruby coder to point out that generating something like this in Ruby, using the libraries was as simple as:

builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2)
builder.person { |b| b.name("Jim"); b.phone("555-1234") }

Which generates:

<person>
<name>Jim</name>
<phone>555-1234</phone>
</person>

And along came a Perl programmer who shows the original example as:

$x = XML('status', [code => 1],
['data', [],
['usergroup', [id => "usr"]]]);

I share Jeff's frustration in the heavily object oriented approach to doing things with traditional .NET libraries - but I think it points to two things: first, the libraries we get sometimes are a clunky "one size fits all" offering that leave the developer writing a lot of line noise for a simple result, and second that while the language itself may not be the initial culprit (I think the two shorter examples above could be duplicated in C#, for example) the thinking one acquires from their language, libraries, and best practices is why System.Xml makes some developers think that 17 lines of code is the best for a "trivial" example of generating some xml.

This is why language is so interesting to me: the way you think is overwhelmingly influenced by how you express yourself.

Where does that discussion leave me? Wanting to know more about Ruby and work on my fluency in Perl. I may have to write that C#, but I want more flexibility in thinking.

}

Wednesday, June 28, 2006

Querystring Drama

{

Apparently it's older news - a security feature from ASP.NET 1.1 that protects the webserver from "dangerous" querystrings that throws exceptions for illegal characters like angle brackets and so on.

We happened upon it when trying to pass information from a VB6 application to a web app by putting together a querystring and appending it to the target page like so:

http://foo/bar.aspx?id=29oeiu&0209&wweoi9239

The garbled bit after the ? was assembled by doing a little bit of shifting of character codes. It doesn't really qualify as encryption but it seems daunting enough for the casual user and there's really not enough text for a persistent person to find much of a pattern. Unfortunately as you happily shift those ascii codes you run into the "<" and other characters that ASP.NET 1.1+ is not happy about. It makes the case for doing proper encoding but even true URL encoding (done by putting a "%" with the upper and lower 4 bits in the character byte encoded as hex) will not absolve the developer of the application server's squeamishness. For example, the URL encoded value for the left angle bracket, "<", is %3c. For the right angle bracket, ">" it is %3e. So if you think that you might get away with a URL that should be http://foo/bar.aspx?start=<&tag=h1&end=> by formating it as http://foo/bar.aspx?start=%3c&tag=h1&end=%3e you will be sorely disappointed. Sorely.

My colleague and I then thought we'd be a little clever - okay it was my [bad] idea - and just use a constant character for one of the angle brackets but this also fell short since it's not just angle brackets that are considered dangerous.

So what was the fix? Step one is to leverage the might of Google and search on the error message. Then we discovered an attribute to the page processing directive that turns this feature off - it was almost too easy:

ValidatePageRequest="false"

Of course this puts the burden of securing the querystring on the developer but there are a few perks: first is that it only applies to the single page when placed as a directive. The second is that the vulnerability is squarely on the developer leveraging the querystring for some back end command functionality. That's easy to narrow into some clean validation logic.

}

Tuesday, June 27, 2006

Starting Ruby

{

John Lam's RubyCLR project piqued my interest even before I saw him at TechEd. Today was my first step to getting started, here were my steps.

1. Played a bit with a free online Ruby interpreter.
2. Got the single click installer for my own machine.
3. Read a bit of documentation.
4. Then discovered Komodo, the IDE I originally bought for Perl stuff supports Ruby and has an interpreter. Very, very cool.

Next step: language fundamentals.

}

Thursday, June 22, 2006

Mac Twit

{

Seth Stevenson at Slate on Apple's new ad campaign writes:

"Mr. Mac comes off as a smug little twit, who just happens to carry around a newspaper that has a great review of himself inside."
}

Safari Redesigned

{

I'm a rabid Safari user. I think they built their whole business plan for me personally... okay, that might be a bit arrogant but at least I know I'm not alone in my rampant desire for technical books and my need to constantly keep an updated library for the problems/platforms at hand.

Initial thoughts:

1. They've done a great job segmenting the pages to load in pieces so browsing through books is much faster. There seems to be heave leverage of Ajax involved in that process.
2. Search is much, much better. Autocomplete when you enter search terms, faster response time, and a slider control that lets you sort by popularity or by relevancy. Very, very cool.
3. Expand / Contract left navigation (table of contents, search results)
4. Printing is better - instead a popup it's a link to a page with just content. The javascript to automate printing is still there but it doesn't automatically close the browser window when complete which is nice.

I'm sure there are other improvements but getting search and printing to work better for a site offering online books is key.

Just put Ruby in a Nutshell on my bookshelf, preparation for RubyCLR.

}

Wednesday, June 21, 2006

Virtual Earth

{

I'm not sure what day I'm on as far as TechEd coverage (a lot to swallow!) but the next session I see notes for was called "Location Solutions with Virtual Earth." It was a tour of Virtual Earth and how to write applications using the javascript library they expose in the Virtual Earth SDK.

You can get an idea of what Virtual Earth looks like by going to the site: http://local.live.com

The SDK is also quite simple; it consists of referencing some javascript libraries and using a DIV to position the mapped content. For example, to get the basics, just view source on this page.

The Virtual Earth API has the following features, per the presentation:

  • User Navigation
  • Mapping Imagery
  • "Bird's Eye" views
  • Pushpins
  • Find Places/Addresses
  • Directions/Routing
  • Polylines
  • Collections of GeoRSS

For each of these features there is an interactive SDK that generates example code so that you can follow along for your own application. *Very cool*.

I did have a few issues with timing and synchronous processing; in other words sometimes the wait time for processing one command seemed to cancel out a command that directly followed it. In my case I was trying to do a search for "Sioux Falls, SD" and then follow it with a ZoomIn method like so:

map.FindLocation('Sioux Falls, SD');
map.SetMapStyle(VEMapStyle.Hybrid);
map.ZoomIn();

I'll dig around a bit - my idea for a helpful little location solution is a map of Sioux Falls and all the coffee shops along with their attributes: how good the coffee is, whether WiFi is free, and the general atmosphere.

I'm also planning to dink around with the Google Maps API to see how it stacks up.

}

Monday, June 19, 2006

BillG Review

{

Joel Spolsky writes about being reviewed by Bill Gates himself. Self congratulatory, but good nevertheless...

}

Sunday, June 18, 2006

Pragmatic Architecture

{

Cathi Gero and Ted Neward had a session on what they call "pragmatic architecture" - the fuzzy definition of which was architecture that maintains ideals until the consequences outweigh them.

It was interesting to get this high level at TechEd; most of the sessions I went to were very technical where this was a balance between philosophy and a general approach to developing software.

One of the first thing they went after was the recent infatuation people on the architectural level have had with "design patterns." According to them, a cut and paste approach to design patterns is not the path to success - and although I haven't immersed myself in the design patterns world, I doubt it's proponents probably leave some room for flexibility in implementation.

According to Cathi and Ted, the goals of a software architect were twofold:
1. Functional Requirements (Business needs, raw functionality)
2. Non-functional Requirements (the "ities": scalability, maintainability, extensibility, and so on)

Their approach in being pragmatic about architecture was to leverage a vocabulary, not as a means to accomplish the goals of software architecture, but as a lexicon for strategies and tactics in accomplishing those two main goals. They covered what they called the 6 elements of architecture and examples of approaches (patterns?) that lend themselves to the software of the solution.

Here are the 6 architectural "elements:"

1. Communication
2. Presentation (the front end)
3. State Management (how the data are stored)
4. Processing
5. Resource Management
6. Tools

For each of the 6 they presented examples of what we see with most modern software. Under Communication, for example, they listed what they call as a "three part tuple:"

1. Transport
TCP, UDP, other network protocols
2. Exchange
Data can be exchanged using request/response, asynchronous, fire and forget, amongst others
3. Format
XML, Text, JSON, Binary, and so on.

Presentation has to do with the interface for the user. Some examples given here were Console, Graphical Interface, and Markup.

The State Model to apply in the application in pragmatic language is either durable (available always) or transient (available only certain times). Another consideration for State Management is the "shape" of the data: objects, relational, heirarchical, etc... Finally when considering the State Model there was the notion of where the data was: client, server, elsewhere...

Processing used in the application, some examples of implementation they gave were: Procedural, Imperative, Concurrent, Parallel, and Transactional. On the processing side, however, some higher level descriptions of approaches included: Divide and Conquer, Recursive, Event based, Shared Queue, amongst others.

Resource Management had to do with persistence of data and configuration. Some styles discussed for this was locator / registry, discovery, injected, and a very sophisticated term for "hard coding" called a priori.

Tools to consider in being pragmatic could be the programming language, development environment, frameworks, code generation, amongst others.

I'm not sure if this stuff originated with Cathi and Ted, but it's very useful in coming up with a high level picture of how software will work. Although most of what I've worked with recently fits under the umbrella of "web application" it would be very useful to approach new projects with this catalog and the set of approaches beneath each item in mind.

This entire session is available as a webcast, and I'd recommend it to anyone who is involved in software development, even if they don't think of themselves as architects. There is always a point when I'm reading or listening to high level stuff like this where I begin to wonder if it really matters but when it is kept concrete like this the distinction between architecture as high level thinking that has to be done anyway, and architecture as romantic "rah rah" for the higher ups is very clear.

Ted's blog seems fairly alive but Cathi's blog has not been updated for a while.

}

LINQ, deeper

{

My Tuesday morning session was with Luca Bolognese, lead program manager on LINQ, covering a slightly different flavor than what Pablo Castro was demonstrating with ADO.NET vNext on Monday morning. Luca’s Italian accent was charming, but it was even more exciting to see what LINQ does on a deeper level.

He started by showing a classical problem that LINQ solves. Imagine a collection of integers which you need to filter out based on a certain criteria, something like:

int[] nums = {2,3,5,7,11};

It’s usually done with some kind of iteration in the form of:

int[] nums = { 2,3,5,7,11};

List<int> selected = new List<int>();

for (int i = 0; i <>

if (nums[i] > 4) {

selected.Add(nums[i]);

}

}

// selected represents my values

I write code like that on a daily basis, it seems. In LINQ, queries become a “first class” member of the language and operate on anything that implements the IEnumerable interface. A problem like the above can be solved without line noise and iteration:

int[] nums = {2,3,5,7,11};

var selected = from i in nums

where i > 4

select i;

From the perspective of someone who writes the iteration + selection stuff every day, I think that LINQ is going to have a big impact on my code. But this is just the beginning. Luca then showed how LINQ is split out to target several different forms of data structures:

  1. LINQ to Objects (Anything implementing IEnumerable, collections etc… )
  2. LINQ enabled ADO.NET (mapping database structures to objects and then querying off of them)
  3. LINQ to XML

The first example above is a typical LINQ to Objects scenario where filtering, querying, or manipulation can be applied to a collection that supports IEnumerable. Being able to do this sort of manipulation on HashTables, DictionaryEntries, and so on is the type of power that I demonstrated above.

In a LINQ enabled ADO.NET scenario, you can take an object that is mapped to some entity in your database and query off of it. I don’t recall the exact demonstration, but an example would be querying a collection of “customer” objects based on some filter:

var topcustomers = from customer in customers

where customer.orderCount > 10

select {customer.id, customer.fullName};

I’ve heard a lot about ORM ever since my friend Aaron started talking about Hibernate (some time ago) but what catapults this over the typical ORM scenario is that the functionality is built into language and not abstracted through method calls. I’ve been a bit lukewarm to the notion since it seemed like a lot of work up front and because this type of abstraction where objects can represent data and provide some manipulative capacity is already built in the DataSet/DataTable model. However two things make LINQ enabled ADO.NET a little different: first, the IDE facilitates the mappings that are made through an “EDM” diagram and mapping providers that give a lot of flexibility in connecting to the datastore, secondly the developer wields a lot of control over how the mapping works and how things are updated – the queries, the stored procedures, all data access still belongs to you and not to some “tool.”

Finally the LINQ enabled XML is powerful – it exposes XML data to yet another format of “query” besides XQuery and XPath. There is also the ability to work with the hierarchical structure that XML documents sometimes expose as collections within collections. The LINQ processing, with a bit of instruction, can also be instructed how to retrieve content (depth first traversal, and so on).

Luca’s blog seems to have died, but for some interesting tidbits, it’s here. Maybe with a few hits it can start up again?

}

Wednesday, June 14, 2006

Python and Ruby with .NET

{

An amazing session with Mahesh Prakriya and John Lam came on Monday night. Mahesh was covering the IronPython efforts for .NET and John came to talk about Ruby. It was refreshing to see the smaller number of developers practically using .NET but for whom language mattered.

Mahesh gave a history of Python support in the CLR and made a case for dynamic languages within .NET. His examples were pretty cool, especially when he started with a few examples of Python:

2 + 2 (room is quiet)
22**64 (room is quiet - David is amazed at the response in milliseconds)

He also showed a powerful implementation of a Matlab / Mathematica type tool written in Python for .NET.

John's part of the talk was also very good - he has written a bridge between Ruby and the CLR. John was fairly funny and expressive and his demos of Ruby and the CLR were fairly good in giving a picture of what he was tring to do.

John's blog is here, Mahesh doesn't blog but a search on Google shows him in a few places. I'm going to be downloading Iron Python and RubyCLR in the next month or so. Not completely sure, but it seems that here is where one can find RubyCLR.

}

ADO.NET vNext at TechEd

{

One of the best talks of this week was Pablo Castro's Monday session covering some of the new features of ADO.NET. Having used some form of data access library from Microsoft for a while, the changes he showed were fairly dramatic, and they will really impact on a fundamental level how programmers think about data access when it becomes widely available.

The general direction from Microsoft seems to be giving more modelling capabilities to developers to manage in an application space. The original step in this direction was ADO.NET from which we can model on the application level using a DataSet and it's associated classes. But the features in ADO.NET vNext - and I hesitate on superlatives - are an unparalleled shift (in my short life as a developer) in what we do for data access.

The rational behind my claim of this being as big a change is that it is no longer limited to the object model or some IDE-fu that Microsoft implements in Visual Studio. This change is a part of the language with which we express ourselves when talking to the database. My rational is LINQ.

LINQ is simply understood by unpacking the acronym: language integrated query. From a syntactical point of view in ADO.NET we can obtain a reference to the database and retrieve a collection of objects that represent what's inside.

I think this is a huge revelation - something that goes well beyond even the Object Relational stuff I hear about from time to time simply because it's not just objects, it's syntax.

Around LINQ as a syntactical approach to getting data from the database is the ability to create what is now called an EDM diagram which is essentially a mapping of the database to the class types that will be used to represent the internals. The EDM diagram can be manipulated so that you can do trivial things such as changing a column name reference in the object versus what's in the database, to complex things such as consolidating content from tables in order to avoid SQL JOIN expressions.

On keynote night the topic of Microsoft "innovation" came up and based on what was delivered, it didn't seem as though there was much in the way of newness to Microsoft's portfolio. But LINQ in all it's forms - for xml, for databases, and for that which implements IEnumerable, this is an innovation indeed.

I'm definitely staying tuned to the LINQ project and the Microsoft Data Access blog.

}

Tuesday, June 13, 2006

Rob Relyea on WPF

{

The timelag on posts is due to several 4 hour nights in succession while partaking in the festivities at TechEd. Here is a quick recap of Monday.

First session was WPF presented by Rob Reylea. WPF seems to be coming together more and more; Rob demonstrated new controls and old controls with new features: the listbox is quite a standout – textboxes that support spellchecking, controls having the ability to embed any other controls (button in a button). Another new feature is in the ability to do screen layout: flow layout, grid layout, and others besides the traditional absolute layout most WinForms developers are used to. Databinding in WPF is also quite improved, and learned from the web world: there is a repeater type approach to it now possible as well as functionality in the new listbox control. Vectors, fonts – there was a lot to the presentation. Rob has a blog, so it’s something to watch as the WPF things consolidate more.

After the session was finished I asked Rob whether they were watching other projects like Mozilla’s XUL/XPFE stuff since, in my own thinking, they were similar in approach. He was a bit dismissive here in the sense that he didn’t see why WPF and XPFE should be compared. Since we didn’t have the same assumptions, I withdrew the question although here is my own thinking:

  1. XAML is like XUL, both are a special markup for describing presentation.
  2. XPCOM provides hooks into the operating system functionality, making the client thick just the way that Windows Vista is going to have a special understanding and capability with XAML and the code associated with WPF applications.

There are some big differences for sure: XPFE uses javascript and CSS, WPF does not. XPFE relies on RDF, and I’m not sure that they’ll be any configuration involved in WPF applications since the runtime should handle much of that for the developer. I am not sure about this. Another set of differences are the vectors and rendering of WPF - XPFE does not, to my knowledge, have an equivalent. However, the basis for my assumption was that they both attempt at solving similar problems - extend the web aware application to the desktop to give it a more "client app" functionality and feel. Leverage better controls and have more flexibility than HTML/DHTML and so on. And yes, this is from the perspective of WPF/e - the use in web based applications.

There is much to learn, and much to be seen of WPF, I’ll stay tuned to Rob’s and other blogs that follow the development.

}

TechEd Keynote

{

I’d been looking forward to the keynote for a while since I found out that Ray Ozzie was going to be speaking. Unfortunately his piece of things was quite small – I imagine I wasn’t the only person disappointed by this. The meaning of the keynote was the general direction and strategy of Microsoft and how we “IT people” fit into that.

It made me think a lot of Macintosh ads and how differentiated the corporate strategies of Microsoft and Apple differ. Microsoft has taken the rather difficult (and not necessarily sexy (in a geek sense)) undertaking of “people-centric” software for business. The idea is to make people more productive in an organizational setting with software.

This reminds me of Paul Graham’s evocation of young people to pick hard problems to work on. The word “hard” is subject to semantic lashing but in this case, the idea of making people work better together is a very difficult problem, especially because it’s difficult to do without reinventing the wheel and causing new problems with current fixes.

Although it’s not explicitly stated, it seems that Microsoft’s approach here is not to “innovate” necessarily, but to commoditize new technologies that are proving themselves and package them for masses at all levels: masses in systems administration, masses in development, and, of course, the “mass” of society.

One other thing about Ozzie’s keynote: there is now a conversation about “smart client” applications which represent something that I began to suspect when I first installed Google Earth: the possibility of leveraging a thick client that was intensely web aware. Of course this notion has been around for a long time – yes, I do play MMOs on occasion – but now a technology like that could possibly be commoditized by Microsoft moving developers away from the traditional web based application to a more controlled, powerful “experience” the developer can produce. Web applications still have their place but essentially the XAML WPF/e notion. Kind of cool in the sense that fewer “fix the back button” types of issues in an internal web based application are possible but also a bit sinister since this is a big move away from “standards” to the proprietary, Windows choke-hold environment.

Lots of other thoughts, and some larger context as TechEd gets underway.

}

Thursday, June 08, 2006

Thinking Atlas

{

One thing I'm very interested in hearing about at TechEd is going to be the Microsoft Atlas framework. Ajax is haute couture and Atlas seems to be at the center of Microsoft's strategy. On my current project I took a look at using Atlas but never really "got" the benefits of the technology. The declarative side of things seems to be designed for the IDE, and without the IDE here it's a bit of a non-intuitive hassle to hand code things out. The second thing that made me leary was the direction Atlas took towards web services. The tasks I needed to perform were very simple and I shuddered when I thought about how much overhead there would be, say, for a webservice whose only job was to send me a filtered list of things for a dropdown. In the end I used my own XmlHttp and a bit of POX (I love that acronym, "Plain Old XML") to send things back and forth. Also courtesy of the O'Reilly Ajax Hacks book I got a handle on JSON and how awesome it is when it comes to sending things from the server and handling it with client side javascript.

Today I listened to Ken Alstad interviewed on .NET Rocks concerning Atlas and it confirmed my suspicions on Atlas leveraging web services and how easy it was to "bind" data from the server using javascript.

It's interesting that there seem to be two directions here - looking on the open source side of things, Prototype seems to be generating quite a buzz. I ran into Prototype in December courtesy of 24 ways and it took about 35 minutes to really "get" it. Prototype is getting mixed in with a lot of JSON and other javascript libraries and techniques for some pretty cool stuff like script.aculo.us.

On the Microsoft side we're waiting for Atlas to become standardized, complete, (marketable?). It's declarative, more IDE friendly it seems, and at least for me, less intuitive.

Anyway, part of the problem might be my ability to understand it and see where I can leverage it so I'm going to be in Jeff Prosise's session on Atlas at TechEd. A few questions I'm thinking of are as follows:

1. How to control when data is bound, doing filtering and other operations using javsacript.
2. Will Atlas play well with JSON? Not JSON being shoehorned into some Atlas app, but more like the ability to return JSON style strings from the server.
3. What sort of IDE interface can we expect with Atlas's release? Can we expect any improvements to javascript editing in Visual Studio as a result?

... I'm sure there are more, and I'm sure that after the session I'll have a much clearer picture of Atlas and it's future in web apps for Microsoft developers. I am pretty sure we made the right choice on the current project, but a year from now I could be singing praises for Atlas.

}

Tuesday, June 06, 2006

Code as Design: Implications for Architects

{

I've just got to Jack W. Reeves thoughts on Code as Design in his seminal article originally in the now defunct C++ Journal, and now republished on developer.*. I really liked his thoughts and although I can't necessarily say it's been something intuitively sitting in the back of my mind, its implications are definitely something I've thought for a very long time.

The basic premise of his article is stated early: final source code is the real software design. From the source code design specification, a compiler and linker do the manufacturing work to implement the software from what one could term the design document of source code. He continues to discuss some implications of this that are well thought out and, from my experience, very true.

A great thing about the article is the return to the notion of engineering and software development being treated together. These days I see a lot of writing about how the words software and engineering could never go together, but as Reeves shows, there is a very real relationship between disciplines especially if we think of our code as a design document.

But the real implication for me, beyond the ones stated by Reeves, has to do with the title "Software Architect" - which I happen to hold (not overly meaningful, by the way - everyone at my company is a "Software Architect"). People with the title, who wield Visio, Use Cases, and management-speak exclusively, aren't the real architects of the system. Of course these tools are very useful, and of course general direction is always necessary for a project, but for the notion of a real "Software Architect" one has to stay close to the code - close to the actual design document - to really shape the manufacturing process. Although staying close doesn't mean, to me, writing every line of code oneself, it means understanding and being a part of the process of making it.

}

Monday, June 05, 2006

TechEd 2006

{

I'm very, very excited to be going to Microsoft's TechEd conference this year with my boss. Now I'm counting down the days - we leave for Boston on June 10, and the conference runs from June 11 - 16. The first conference I was able to talk my way into going to was VBITS 2000, and as I think back upon my years training and consulting for my previous employer, that was among the best.

I got to rub shoulders with some pretty amazing people, and learned many valuable lessons. I'll never forget sheepishly asking Aaron Skonnard what he thought of XML Data Islands in IE 5, or Bill Vaughn's theatrics (and knowledge) of data access.

I think my approach and goals at the conference may be a little different from some people who are looking forward to a week off to fraternize and network. I'm hoping to learn as much as possible since I'm not sure when next I'll get the opportunity to go to a conference on my employer's expense.

The biggest trick is going to be separating the Fire & Motion from the sessions that will give me knowledge and direction for the work I do on a daily basis. Of course it's good to be aware of what's upcoming, but I've always been really reluctant to spend much of an investment in something that is subject to change. Beyond that I usually prefer to wait when adopting something for a little while (let others be the bug testers) so that also pits me against things that are a bit too futuristic.

With that said, here is my schedule for the week. There are a few things I'd like to see this year (list is totally subject to change, like, on a minute by minute basis):

1. More ASP.NET 2.0
Deeper on the new features, Personalization API, Web Parts, Internals

2. XML / XQuery / LINQ
Some ideas on where these are in the pipeline so I can start using them on projects

3. Workflow
I have DVDs of the last TechEd, and this came up a bit. I'm interested again on seeing an angle to take on this tool.

4. Sharepoint and Biztalk
I signed up for a few sessions but this is the part where I get leary; I'm not sure when the 2007 versions will be out and about. I know there are many, many opportunities to use the current versions of these products and would probably benefit from seeing that kind of stuff right away. But I'm hoping to glean and perhaps get a few tidbits to stay ahead of the curve when the new versions are released.

5. Team System
We are using it in house, so I need to understand it - I also want to get an accurate picture of how Team System can be leveraged by small teams. Most descriptions (and the pricing!) seems to put it in the "enterprise" category but most of what I've worked on in the past, and probably for the forseeable future will be software projects with less than 20 people involved.

6. IIS 7
I use IIS every day, and it's been like an old friend since the early versions. I'd like to see where the product is headed, and how its path meets with ASP.NET 2.0 and all the other pieces of web application development.

7. Architecture Talks
I signed up for a few that will hopefully be interesting and useful. I'd also like to get a better handle on SOA, "contracts," and the like. Distributed architecture makes a lot of sense to me, but I'm a bit wary of the architecture astronauts when it comes to enterprise application architectures - I try to translate that stuff into what I do on a daily basis (enterprise app for a publicly traded company of 5000+ employees) and still sometimes miss the mark. Perhaps I'll get a chance to meet some people in this environment as well who I can maintain contact with.

I'm hoping that I'll be able to change sessions as well during the conference. I'm fairly pleased with what I have, but the flexibility would be nice.

As the week progresses I'll hopefully write down some things I'll be hoping to answer, as well as some pre-conference reading.

TechEd 2006, here I come!

}

Dino says...

{

I think it was a bit of a rub off from me liking Francesco Balena after being very impressed with him at my first tech conference, VBITS 2000 in San Francisco, but Dino Esposito is another of those intensly smart Italian programmers living right on the edge of that Microsoft technology curve.

Anyhow, Dino, in response to lots of developers like myself, wanting to get better wrote the following:

"Some people here at the conference asked what I feel to recommend to do NOW. Pretty easy job.

I do recommend to learn as much as possible about ASP.NET 2.0 internals. For example: handlers, modules, providers, lifecycle, script-oriented API around the Page class. To learn as much as possible about best practices for control development.

In this regard, I wrote quite a few articles for the ASP.NET DevCenter in the past months to form a sort of crashcourse on control development. "
That's some great advice and it exposes a few personal areas that could see growth.

}

Friday, June 02, 2006

How good are you?

{

In my teaching years I'd often run into people who thought they understood things that they really didn't. Today, spreading like a fire I found a series of "do you know" posts that measured levels of understanding in three technologies most people think they understand: HTML, Javascript, and CSS.

Of course a personal evaluation leaves one open to questions but I think I'm doing okay level-wise. I wasn't at the top in any of the posts, but just a notch below.

When it comes to technologies, even those that I use on a daily basis (like the above) I'm always loathe to say I have a maximum level of knowledge because I am well aware of those who sit on the top of the food chain in whatever areas of knowlege it might be: I'm no Eric Meyer when it comes to CSS, I'm no Thomas Fuchs when it comes to javascript, and although I know much of what there is to know about HTML, I haven't spent (what I consider to be a waste of) time navigating differences in rendering on different browsers and standards support unless it's been a big problem on a project.

Well, here's to all of us who are still learning...

}

Friday, May 26, 2006

RadioButtonList Javascript Accessible

{

I recently was trying to write some javascript that interacted with the ASP.NET 2.0 RadioButtonList. My first attempts at obtaining a handle to the control via document.getElementById were successful but unsuccessful. Successful in that they weren't giving me a "null" reference back, but unsuccessful in that I was not getting the selected value of the radio buttons.

It turns out the RadioButtonList is rendered as an HTML Table element, with the table getting the corresponding id of the server control and the radio buttons getting id values that had an increment on the end. Their name attribute, which groups them, was the same as the RadioButtonList id.

Simple example: you have a RadioButtonList you give an id of myList. ASP.NET 2.0 renders a table with the id attribute of "myList." You'll have your radio buttons inside, named myList_0, myList_1, and so on. These radio buttons, rendered as getElementsByTagName("input") to get your radio buttons. Test to see which is selected and you're all done. The following function encapsulates that logic, and we've begun reusing it all over the place. The radioList argument should just be the ClientId of your RadioButtonList:

function getRadioSelectedValue(radioList){
var options = radioList.getElementsByTagName('input');
for(i=0;i<options.length;i++){
var opt = options[i];
if(opt.checked){
return opt.value;
}
}
}

}

Tuesday, May 23, 2006

Crypto with Schneier II: One Way Hash

{

My reading of Schneier has continued. He still proves to be a very accomodating writer; consider the following on the "One-Time Pad," a encryption scheme that can be literally unbreakable:

"Many Soviet spy messages to agents were encrypted using one-time pads. These messages are still secure today and will remain that way forever. It doesn't matter how long the supercomputers work on the problem. Even after the aliens from Andromeda land with their massive spaceships and undreamed-of computing power, they will not be able to read the Soviet spy messages encrypted with one-time pads (unless they can also go back in time and get the one-time pads)."
In the second chapter he is discussing the basics of protocols and describes the one-way hash: "a function, mathematical or otherwise, that takes a variable-length input string (pre-image) and converts it to a fixed-length output string. Essentially, a computed hash represents a fixed length byte array that is unique for whatever its input stream was. This is interesting and useful beyond cryptography.

Here's a simple idea from Steve Oualline's book "Wicked Cool Perl Scripts," but implemented in C#: you can compute a hash to check to see if two files are different or the same.

The following code uses the System.IO and System.Security.Cryptography namespaces:

private static bool CompareFiles(string path1, string path2) {
byte[] hash1 = GetMD5Hash(path1);
byte[] hash2 = GetMD5Hash(path2);
for (int i = 0; i < hash1.Length; i++)
{
if (hash1[i] != hash2[i])
{
return false;
}
}
return true;
}

private static byte[] GetMD5Hash(string pth)
{
MD5 hasher = MD5.Create();
byte[] fileBytes = File.ReadAllBytes(pth);
byte[] hash = hasher.ComputeHash(fileBytes);
return hash;
}

I was curious about the performance of this technique - I was originally testing it on 40MB files. I extracted some old database backup files - about 200MB a piece and the comparison took somewhere on the order of 20 seconds. My laptop has a P4 3Ghz with 1GB of RAM. Nice, but not out of the ordinary (especially these days). I've also got suspicions that the speed was not necessarily on the hash computation, but rather on reading out the byte array in the file. I'll test sometime to see...

}

Saturday, May 20, 2006

Personal Projects

{

One of my jedi masters, Darren Neimke, posted the following about having personal projects:

"One of the questions that I always ask is for the applicant to tell me about their favorite personal project that they have going right now. It's a bit of a loaded question I suppose because of how it assumes that they do have a personal project - but that's almost my point. Having a personal project (or more than one) is a trait that is shared by every developer that I respect and so I rate it rather highly."
Interesting, because my latest "personal" project is a tool I called Palantir which let's the developers browse around the database getting schema information much more quickly and effeciently than writing queries like:

select * from information_schema.columns where table_name = 'foo'
or
select * from information_schema.columns where column_name like '%foo%'
It pleasures me to no end when I walk through our work area and see it running on everyone's machines. Usually in the evening I add features that are in response to feedback and what I think will make it more effective of a tool. For example, one screen, devoted to exposing stored procedures, displayed TSQL without syntax highlighting and it became a request. That evening I spent some time with regular expressions and search/replace to get a "pretty" version of procedure definitions into the software.

Invariably the question of why I wrote Palantir comes up, and my response usually a bit of surprise; I thought everyone had little pet projects of software they worked on at home. In fact, most don't. In fact, as I ask around, I find that I'm quite unique in that environment for working on my own stuff at home.

I don't think it necessarily defines me as a better programmer but I know that it's when I write my own stuff that I get that free reign to improve my skills instead of working against a spec and a deadline. My projects give me a chance to do things with regular expressions, backreferences, web services, RSS, XML, and a ton of other things that don't come up in the regular work day.

I'm still considering what to do with Palantir; I want to keep it personal for now so that I can work in some more features and leave it with my personal vision at its core. Then I may work up the courage to put it up on CodePlex or SourceForge.

}

Redirect to Self (ASP.NET)

{

It's easy to reset a page to it's initial state in ASP.NET by redirecting to itself. Here are 3 ways you can do it:

1. Response.Redirect(Request.Path);

In which the path to the request is presented in the following form: /MyApp/MyFile.aspx

2. Response.Redirect(Request.RawUrl);

In which not only is the path exposed, but also any querystring parameters like:
/MyApp/MyFile.aspx?foo=bar

3. Response.Redirect(Request.Url.ToString());

In which not only is the path and querystring parameters exposed, but made available as an absolute reference in the form:
http://MyServer/MyApp/MyFile.aspx?foo=bar

Interestingly enough, if you have a named anchor in the form of <a name=#test, this is not exposed by any of these methods! (You'll see how I know a post or so from now, but suffices to say that you can still get this information from the client side by parsing the window.location object:

alert(window.location);

}

Sunday, May 14, 2006

Crypto with Schneier

{

A coworker loaned me Bruce Schneier's Applied Cryptography. So far it's a very interesting book, and surprisingly readable. I may see if I can work my way through various forms of encryption but translate his samples to C#. Here's a version of a substitution cipher that uses XOR operations in C# (make sure you're using System.Text):

private static string Cipher(byte key, string plainText)
{
byte[] plain = ASCIIEncoding.ASCII.GetBytes(plainText);
byte[] ciph = new byte[plain.Length];
for (int i = 0; i < plain.Length; i++)
{
ciph[i] = (byte)(++key ^ plain[i]);
}

string cipherText = ASCIIEncoding.ASCII.GetString(ciph);
return cipherText;
}

To decrypt, if you have the key:

private static string Decipher(byte key, string cipherText)
{
byte[] ciph = ASCIIEncoding.ASCII.GetBytes(cipherText);
byte[] plain = new byte[ciph.Length];
for (int i = 0; i < ciph.Length; i++)
{
plain[i] = (byte)(++key ^ ciph[i]);
}

string plainText = ASCIIEncoding.ASCII.GetString(plain);
return plainText;
}

Back to my earlier comment on Schneier being readable, his comments on this approach are as follows:

"... the list of software vendors that tout this toy algorithm as being "almost as secure as DES" is staggering... An XOR might keep your kid sister from reading your files, but it won't stop a cryptanalyst for more than a few minutes."


}

Tuesday, May 09, 2006

AAARGH!!!

{

Can you spot the mistake?

string where = PathContext.Value += "\\" + subfolder;

Another night of programming my little mistakes away...

}

Sunday, May 07, 2006

Mac Adverts

{

The most recent Mac advertisements have two guys, side by side: a chubby guy that looks like a dishevled Bill Gates and a young hipster. You can guess who represents the PC and who represents the Mac.

But truth is a little bit more boring than fiction: Macs are vulnerable too. They are expensive too - I was salivating over a MacBook until I priced one out.

Luckily I have an iBook courtesy of the company that I can use. I love it, but I don't have that kind of money - or rather, I'd drop it on a nice Thinkpad or Alienware and keep that extra money I had left over.

I always liked Mac ads (Remember the "switch" campaign?). Who else would get folks like De La Soul and Liza Richardson for an endorsement?

But alas, here I sit in the coffeehouse: a monstrosity of a HP laptop in front of me, upon which I write code in javascript, perl, C#, VB.NET, and C++, running my RSS aggregator, messenger, and of course, of course Firefox amongst other things in the toolbox. And I'm not in a bad suit either.

}

Thursday, April 27, 2006

C# Dynamic Instantiation with Reflection

{

In our case it was a control that needed to be placed in a GridView column, but this could be used anywhere:

System.Type t = AnyControl.GetType(); // the control or class of your choice
object o = System.Activator.CreateInstance(t);
System.Web.UI.Control newControlOfType = o as System.Web.UI.Control;

}

Sunday, April 23, 2006

Development Abstraction Layer

{

Joel is at it again. In his most recent essay, The Development Abstraction Layer, he asserts that management at a software company should build an "abstraction layer" that eliminates all distractions from the programmers except programming. Programmers are to be cushioned in the best environment possible to think:

A programmer is most productive with a quiet private office, a great computer, unlimited beverages, an ambient temperature between 68 and 72 degrees (F), no glare on the screen, a chair that's so comfortable you don't feel it, an administrator that...

Okay stop Joel! That is the perfection that I dream of but have yet to really be placed into. In a different thread, however, I get my answer as to why:

But of course, it really depends on where you are in the foodchain. For Developers, I've always considered it to be:

Bottom - Coroporate IT Department Developers. Developers are a cost center

Middle - Internet Company. Developers are part of the core business strategy.

Top - Shrinkwrap Vendors. Developers are the profit center.
Generally speaking this seems to be true. Because my experience has primarily to do with corporate environments, there is a vast difference between that programmer experience and that of, say, your average programmer at Google.

My current employer is good to us, however - most of that seems to come from the fact that the principal is himself a programmer. As a result we have excellent hardware, software, beverages, chairs, and reading material.

}

Saturday, April 22, 2006

Motives

{

Toby Segaran, of Lazybase and tasktoy fame, recently emitted the following on motivation:
"The truth is that I don't make any money from these applications. They were never intended to be a business. I wrote them because I wanted them, it was an opportunity to learn something new, and like most people I love creating things. I determined that for less than I spend on coffee, I could put them online and share them with everyone."
In a recent conversation with a person from work I spoke about an idea for RSS aggregation I had that would be different from current tools but make for better use. As cool as it was, I said, I doubted I could build a business model around it. When it was suggested I came up with the thought as a way of making money, it gave me pause -

Not really, not at all, in fact. Things I write like iTunesBuilder, antiPod, Hobbitwerk:::pwd, Hobbitwerk::PIdigit, phoDak all had some personal problem or interest that prompted me to make them.

Pekka Himanen's book, The Hacker Ethic, does well on this note by giving "Hacker" culture three main attributes (from Wikipedia, I'd suggest you actually read the book):
1. enthusiasm, passion about work that is enjoyed

2. creativity, wish to realize oneself and one's ability, often in teams that are formed spontaneously (project orientation)

3. wish to share one's skills with a community having common goals, along with the need to acquire recognition from one's "tribe"; one is motivated by inner zeal rather than external awards: the fruits of one's work are donated to everybody for their advances and further developments
I would scarcely deign to mention myself in the same sentence as guys like Linus Torvalds or Toby Segaran, I understand this a lot from the stuff that I am trying to do. I'm hoping one of these days to have a good enough idea to make a contribution to programmers and people who use software.

}

Thursday, April 06, 2006

Northwind, Pubs on SQL 2005

{

It's a strange thought but these databases are like old friends. If you, like me, are disappointed not finding them with SQL Server 2005, and you have Visual Studio 2005 installed, navigate to:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Samples\Setup\

You'll find scripts to generate your old friends for another round of programming.

}

Friday, March 31, 2006

Thursday, March 30, 2006

Remove Carriage Return, Line Feed, Tab in TSQL

{

-- remove carriage return, line feed, and tab from a field in tsql
REPLACE(REPLACE(REPLACE(MyField, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')

}

Saturday, February 25, 2006

Simple is the new robust

{

I first got this vibe from Jason Freid of 37 Signals while listening to a podcast from Venture Voice (I'm not that into VV; it's a bit too "MBA" for my more technical tastes - I found msyelf there only because Joel Spolsky was interviewed).

This is by recollection but he spoke of simple tools designed to do a single thing well. Now, a few months out from that I see the following on Noise Between Stations:

Robust tools are seductive, but their complexity quickly results in diminishing returns. Adopt tools with as many features as you need, and no more. Usually a few essential features will enable you to do many things well.
Interesting and thought provoking. One thing I'd add is to have tools that let you do things fast and terse. What about a class designer for Visual Studio that let you design a class skeleton with as little as the following:

class Person:
p string FirstName
p string LastName
p int ID
m DoSomething(int paramA, string paramB)
m DoSomethingElse(string[] p, ArrayList p2)
language C#

would emit:

public class Person{
private string m_FirstName;
private string m_LastName;
private int m_ID;
public string FirstName{
get{
return m_FirstName;
}
set{
m_FirstName = value;
}
}
// and so on
}


The challenge of something like that would be leveraging plain text without becoming too esoteric. I would have assumed a lot of tools that would automate things like this but Visual Studio 2005's "class diagram" tool seems to disprove that.

}

Saturday, February 04, 2006

What's in a name?

{

Apparently there is an RFC on naming conventions! Here is the thread is on JoS. Gadgetopia also had a thread concerning the naming of things.

I've always liked more creative naming conventions, even though an argument can be made for the sensible but boring "Computer01"... type approach.

My machines were named after places in Middle Earth, like Minas Tirith and Isengard. Pretty soon I'm going to have to clean things up and the new names will probably have some vague reference to Neal Stephenson (Raven, Hiro, Ng, ...). But that's probably something hard to explain to the Judy in accounting types.

I'm glad scientists and discoverers are creative with their names. The solar system, our human anatomy, different species, all are named well, and not "XXX01", "XXX02", "XXX03."

}

Friday, February 03, 2006

MeWare

{

Eric Sink of SourceGear has an article, Yours, Mine, and Ours, about writing software that other people use. Over the years I've noticed that massive chasm in the "personal" software developers write for themselves and the software that people actually find useful.

I've written lots of simple utilities for myself but it's been ever so rare that I've made something that other people find useful. Perhaps my biggest flop in this was an online link database that I had hoped my friends would jump in on and use to spread and keep those funny, cool, and useful snippets of the web that we are constantly emailing and instant messaging to each other.

I still use the utility (it's proven quite useful to me), but after a few logins from friends it died as a "public" tool. I haven't talked much to people about it but here's a few reasons I think they didn't like it:

>> It required login/registration.
Even though they were my friends, no one seems to be looking for Yet Another Password Website. Worse yet, I required an email address thinking in future I'd createa mail list with all the links that had been recently submitted.

>> It was buggy.
There were a few things I knew it had problems with. It's embarrassing to say but there was one area where I did a database insert by manually constructing the "INSERT... " and therefore if any content had an apostrophe, it would break. As non-developers they all didn't have time to hear the reason why it broke, I think most, after one error just never came back.

>> It didn't organize well.
I figured out a way to organize things that worked for me personally but never got outside input for how things worked.

>> I wasn't the best evangelist
I did fix some of the bugs, and even though it got a bit better I didn't really know who to tell. So apart from some close friends who tried it and left, it lived in isolation.

>> The URL sucked
It was an offshoot of my main site, easy for me to remember, but a big pain for other people.

So anyhow, Eric's essay resonated with me. I've got some "new" personal projects that I am really hopeful will become Usware. The thing that I find encouragement in is that with each new piece of software I write in my spare time, things get a little better and a little smoother when I show them to other people. Oh, and I'm better at keeping my mouth shut until it's actually working.

My big questions for public consumption are what other deliberate steps one can take away from Meware to Usware, especially with the limited resources of an individual? Or are there any good stories of strategies used to transport Meware to Usware?

}

Monday, January 30, 2006

Throwaway Design

{

Joel Spolsky, software pundit of Joel On Software is writing a series of articles on "Great Design." In his most recent article draft he talks about "star" products - his examples include Brad Pitt, the iPod, and the Herman Miller Aeron.

Here is my short rebuttle, not because I think he's wrong, but because I think sometimes good design is boring as ever:

>> It's interesting how iPods and Aerons always come up when it comes to "good design" but no one is crazy enough to talk about Wal Mart and design.

Joel asserted as much himself in his previous article describing design that as a discipline it's focuses on a lot more than the aesthetic.

But one of the things that is impressive to me about good design is invisibility.

Wal-Mart is a perfect, but scandalous example of this. No one wants to bring them up because it's not as chic as, say, an iPod, but when we are honest with ourselves it seems as though this "proletariet" design seems to contact us more than something like an Aeron chair.

How fashionable is it to talk about the design of throw aways, or the design of "just good enough?" I think Visual Basic and Wal-Mart have a lot in common: they touch *everyone* (have a look at the POS (no pun intended) system at the next store you visit and chances are it was written in VB), but they don't jump to the front of one's mind when they think of (capital D) Design.

Is the Wal Mart throwaway an excellent example of design?

Okay, how about this for a change of direction. What car do people pick out of a crowd for "great (capital D) Design?" Audi? BMW? But what car silently makes the profits of these vehicles like chump change (some boring car that *everyone's* got, like a Honda Civic). By design? <<

What is to be said of throwaways and invisible design?

I'm sure people are going to respond to my post here.

}

Sunday, January 29, 2006

Good Design is Hard

{

Joel Spolsky has begun a new series on design. I'm looking forward to it because I find myself having to refocus on the discipline of good design quite often.

The one thing I have begun to understand about design is that in order to do a good job you've got to be absolutely tenacious. If it means *exactly* 172 pixels, you use every means necessary to use 172 pixels. Not 171, nor 175, exactly 172.

His first article, "What is Design?", does a good job of dispelling the myth that design is something mystically done by "artsy" people. It will be interesting to see where he goes from there.

I managed to get the company where I did my last project to use Fogbugz, Joel's bug tracking software. At the time it seemed like simplistic software - I had a hard time believing that this "guru" of software development only had Fogbugz to show for himself. However, I've been able to understand more of the design behind Fogbugz now; we use Serena Teamtrack and although it *seems* like it has more functionality, it's missing a lot of the ease, flexibility, and philosophy of Fogbugz. The best designs are like the best special effects in a film; they are so good you don't realize they are there.

}

Wednesday, January 18, 2006

10 years, not 10 hours

{

Most programmers hope they are smart, myself included. Especially at the chastisement of Joel, or some other pundit, we bristle defensively or let it go to our heads whether we meet the criteria of "smart" for the day.

What's even more taboo is to say "I don't know" or "I don't understand." To avoid this many people broaden their exposure so that they can claim they know something of HTML because they've written a tag in notepad, or they claim they "know" C++ because they've written a Hello World.

Out of this a whole cottage industry of 24 hour / 21 day books have flourished to mock what it really means to know something technical. I'm sure the authors of such books aren't claiming to transmit a full understanding of thier topic but that's irrelevent here; it's how books like this are used.

I read an excellent essay by Peter Norvig which confirms an intuition that I had: it takes many years to really know a programming language. For the last five or so years I don't think I've gone more than a week without writing something in C# and I still learn knew things all the time about the language. If someone asked me if I "knew" C#, it would be awkward; I know the answer they'd be looking for is the simple yes or no, but I wish I could stop them and say, "hey, I've been programming the .NET Framework for a while and I feel like I'm getting there with C#."

Norvig's challenge to "know" a dozen programming languages is a formidable one.

"Learn at least a half dozen programming languages. Include one language that
supports class abstractions (like Java or C++), one that supports functional
abstraction (like Lisp or ML), one that supports syntactic abstraction (like
Lisp), one that supports declarative specifications (like Prolog or C++
templates), one that supports coroutines (like Icon or Scheme), and one that
supports parallelism (like Sisal)."

I'm a few languages short but that's where I'm headed.

}

Painful Growth

{

Raganwald has an excellent essay on failure in software development. In a world where everyone seems to be talking about how programmers ought to be smart, this is a dose of reality in which we realize that the line between success and failure depends on so much more.

I've been on two failed projects. Each time there's a bit of painful growing. I know I'm not alone; there's that statistic of the majority of software projects failing; but I like honesty and candor with the attempt to become better.

}

Monday, January 02, 2006

Rumble in the Jungle with Joel

{

In his latest essay, Joel Spolsky has taken the gloves off for a rant against what he calls "Java Schools"; schools that use Java as the implementation language for various Computer Science courses.

Joel's always been a point of love/hate for me: I love his writing style, his lack of fear in pointing out what's wrong, and how he's been a good model of the loud programmer that pisses people off, but who is, more often than not, right. I've taken a bit of pleasure exposing his venture capital articles to business types around me.

It's a bit different when you're at the end things. I lack a formal computer science degree from even the likes of a "Java School" and he seems to sneer at those of us who weren't part of the brotherhood at Yale or MIT. He didn't even spare Penn, which in it's own right is a pretty good school.

It's been interesting to see the responses come, some which look past the vitriol and point out the truth of what he's saying, as well as others I've enjoyed which involve people as educated and smart as Joel putting many of his comments in their place. My favorite thus far has been one from a UPenn professor delivering a bit of a lashing in Joel's direction.

The real question is what I do with what Joel says, which in essence is that good programmers understand recursion, algorithms, and pointers extremely well, and that the best languages to cultivate that understanding are C++ and LISP.

On the first point I agree. I use recursion on a regular basis (lots of XML and heirarchies with my work), but instead of pointers I've been the user of references since I've been using C# and Java. Although I've implemented lots of my own data structures and applied a few well known algorithms, they've been within the safety (and usefullness) of my non-C++ language pool (C#/Java/Javascript/Visual Basic/SQL/Perl etc... ). Maybe there is some reason for me to revisit some of these concepts in the "harder" language of C++ with the use of pointers. And perhaps it's time for me to pick up that dusty copy of LISP, by Patrick Henry Winston, with a compiler and a notebook. I'll never be able to claim that I went to MIT, or Yale, or even a Java School. But I'll be a better programmer for it.

However, there's another thing that all the good programmers I know of seem to understand well and that is regular expressions. And, another thing that intuition tells me is that to learn them well I need a language in which using a regular expression is as easy as a breath of air.

}

Sunday, January 01, 2006

New Year's Day for my night language

{

Each year, as many people gear up for their New Year's resolution that they will ultimately fail, I make my own doomed promise that this will be the year that I become proficient in perl. As the year wears on I get more engrossed in project work and "lose" time. Or I work on my own pet projects which I can prototype and finish so much more quickly in C#, or whatever else I know well.

But my encouragement for the upcoming year's attempt is coming from all directions.

One is YAPC, which will be in Chicago this year. That's within reach, and it's not so expensive that I can't afford to be there.

Another has been Josh McAdam's perlcasts. While I'm at work moving pixels or writing C# I've been listening to quite a few prime hackers in the background.

The second encouragement came from a post on Joel On Software about having a "night time" language:
"For the purposes of this argument I am assuming the programmer uses the language he likes best at night, and maybe not his favorite during the day. If you wish to debate this, start another thread and I will. Why does the programmer like the language that he likes at home so much? I would argue that it is largely about efficiency in the language. If you can do something quickly in a language you get that feeling of control that I think most programmers enjoy. " - threaded here
It's nice to know that other people out there feel as I do, and have their own "night" languages.

Long live the night language.

}

Thursday, December 01, 2005

24.

{

24 ways is a new way to countdown to Christmas: web development tricks to impress your friends. This is worth a little application. Now the trick is just to apply some of these techniques instead of just linking to it.

The gnome behind it all is Drew McLellan. His blog is phat too.


}

Monday, November 28, 2005

Centered DIV

{

I'm used to the align attribute, but my recent CSS conversion has me doing things a bit different. Instead of table align="center" I've discovered the same affect with:

margin-left: auto;
margin-right: auto;


}

Tuesday, November 22, 2005

WinFX horizon

{

What does WinFX bode for smallfolk like me? At this point I'm given to think of Visual Studio 2005 and what sort of placement it will have in the product. I haven't done deep digging, but something tells me a WinFX designer is not going to be a part of Visual Studio 2005.

It goes back to my wariness of the concept of a "release cycle." Microsoft will reap another set of good earnings from a forthcoming release of a Visual Studio 2006 (or whatever) that has a WinFX designer for Vista's windowing system.

If you're designing a desktop application on .NET 2.0, what does this bode? Think hard about your strategy, and look over your shoulder at those slick COM applications.

I've posted on Joel on Software, hopefully someone will have a good response.

}

Get Executable Directory with .NET

{

What directory am I in again?

string dir = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

}

Strip Time Off SQL Server Date Variable

{

DECLARE @DOUT DATETIME
SET @DOUT = CONVERT(DATETIME, CONVERT(CHAR(10), GETDATE(), 101))
PRINT CONVERT(DATETIME, @DOUT)

}

Wednesday, November 09, 2005

Technology or Tools, Visual Studio 2005

{

The big release is upon us. But it begs a question that I think those of us who use commercial development tools have to ask ourselves, something our Open Source brothers and sisters do not to the same degree. The question is whether we are driven by technology first, or whether we are led by tools.

Microsoft is driven to release products on a cycle that will earn them a consistent amount of revenue; sometimes the "new" product is hardly new at all.

Visual Studio 2005 looks good from my very preliminary browsing about, but I'm still approaching it with some caution. It's really cool to do "push button" refactoring, but is refactoring something we need to really think deeply about? A part of an underlying structure that must be designed carefully? Something that can't fix code that is already structurally defunct?

The class designer and snippets are cool too, but when I see the IDE eating up 800MB of memory on "Hello World" type projects, it makes me nervous.

My first stop is going to be new language features. After that I'm going to delve a little bit more heavily into the IDE. The ASP.NET features look good and somewhat different. But I'm a skeptic until I see the power for myself.

It's such a contrast to other worlds - to return to the idea of Open Source - technology there is more likely to evolve because of a need that must be met or a new idea. It is independent of the goons in sales & marketing.


}

Thursday, November 03, 2005

ASP.NET Control Trees

{

Debugging a problem today I wrote this, which may be useful to someone. It displays all the controls on an ASP.NET Page in a tree structure. You can actually call it from any control, it will recursively traverse the heirarchy below it. I tested it on ASP.NET 2.0, and it works fine:

Call it with the following:

DisplayControlTree(this.Controls, 1, 30);

Incidentally, the problem I had (and still have) comes from dynamically loading User Controls. Once they've been loaded using LoadControl("... path") they don't seem to persist themselves in the ViewState. I think my best hope for now is to save entries made to the User Controls by parsing the Querystring or Form collection manually.


}

Wednesday, November 02, 2005

Buzz Watch: Ruby on Rails

{

Ruby on Rails is getting more and more buzz each time I open my browser. This time it was Bruce Tate claiming that Java is dead ("like COBOL, not Elvis") and that he was turning to Ruby on Rails as his framework for application development.

A few days ago I also noticed a define/tutorial on Ruby on Rails over at O'Reilly. More and more of these seem to be popping up of late.

The most interesting thing about this buzz, however, seems to be the shift in the pendulum swing to a language that is light and airy, one which isn't belabored by the stiffness of strong types.

I remember the process of learning Java - there seemed to be a lot of people coming from a C/C++ background who perpetually scowled at the VB/Microsoft/Webby/Scripter types like me. Now many of this camp are turning away from that rigidity and heading back to the land of "dynamic" typing.

Pendulum swing... a few days ago I met with a prospective client and they showed me an app they were using that was written in PowerBuilder. I don't know much about PowerBuilder but the app seemed quick, flexible, and tightly coupled with the database. What's most ironic is that the reason I was there was to help with stored procedures and triggers that would let them add business logic to the otherwise light and airy environment in which their application came into being.

Deja vu, all over again.

I've got Ruby on Rails on my watch list. Go to the official website and there's even a movie amongst the tutorials.

}

Tuesday, November 01, 2005

Remedial CSS

{

I've been doing web development for a long time. Long enough to have developed lots of patterns and habits for how I'd approach putting together a website. Because most of my work is done with server side code, I've also yielded most layout thinking to the Panels, Grids, and User Controls I create in ASP.NET.

So it's a bit of a surprise now that I find that my habits are wrong, horrid even when it comes to web development. My effortlessly thinking in tables goes against the grain of any CSS ideologies out there. Having just redesigned my personal site, this is a bit of a drag.

As I read up on layouts with CSS, it's funny to see things turned back on themselves:
  • Absolute Positioning - I used to tell everyone to avoid this because of different screen resolutions
  • ul/li tags - Which were so passe, and used as an example of the obscure tags one didn't need anymore.
  • Tables - frown upon for anything other than displaying tabular data. Read: no layouts, thank you.
So I'm beefing up again. I need to learn the particular advantages of these newer layout strategies - after messing around today a bit I don't seem to gain anything over my older methods. I'm sure this will change.

I did some surfing and checked out various sites... most of them are using DIVs and CSS for layout, not tables. Curiously, Yahoo! Picks is one site that seems to have kept things the way they were.

}

Monday, October 31, 2005

Hunting for the elusive column, table, proc, ...

{

One of our clients has a Microsoft SQL Server table with 284 fields. So when I'm given a spec that references the "OrigLoanAmount" field, it's sometimes difficult to ascertain where that field lives. On some systems, especially if you've got familiarity where data are likely to be stored, you can make an educated guess. But if you're interested in some quick digging, try these queries from the Information Schema views:

-- find that elusive column
SELECT * FROM Information_Schema.Columns WHERE Column_Name LIKE '%MyColumn%'

-- list out the tables
SELECT * FROM Information_Schema.Tables

For procedures, views, and functions, I've just queried sysobjects. I learned this from a guy who was in my class once; I used to be one of the hapless Enterprise Manager users until I saw him digging effortlessly with queries like:

-- show me all stored procedures
SELECT * FROM syobjects WHERE type = 'p' AND name NOT LIKE 'dt%'

-- show me all views
SELECT * FROM sysobjects WHERE type='v'

-- show me all user defined functions
SELECT * FROM sysobjects WHERE type='FN'

... and so on.

}

Web Developer Tools

{

Glad I found about Chris Pederick's Web Developer Extension. It's a set of tools that will run inside Firefox or Mozilla revealing the underlying structure of any site you pull up in your browser.

Some of my favorite things:
  • Displaying borders on table structure
  • Displaying borders on frame and iframe elements
  • Showing dimmensions of images on screen
  • Adding your own user stylesheet
  • Displaying stylesheets for a site within your browser

Now to find an IE version...


}

Sunday, October 30, 2005

Office Interop with .NET

{

Are you still doing VBA with Office even though you know you should be doing your coding with the .NET Framework? Probably like many I did things the old way rather than dealing with COM Interop, especially since this was particularly daunting with Office.

It isn't as of a while ago, but you, like me, may have been a bit too busy to notice.

First, you must download the Office Interop Libraries from here. The instructions are clear; run the register.bat from the VS.NET command prompt. After that you can make a reference to the application interop assembly of your choice, such as Microsoft.Office.Interop.Excel.dll.

Reference the namespace in your app:
using Excel = Microsoft.Office.Interop.Excel;


Code away:

Excel.Application app = new Excel.Application();
Excel.Workbook book = app.Workbooks.Open(@"c:\data\Daita.xls",Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets[1];
for(int i=1;i<10;i++) j="1;j<7;j++)" rg =" (Excel.Range)sheet.Cells[i,j];">

A few interesting things:
  • The Type.Missing passed for all those COM-esque optional parameters. Ugh.
  • Casting the cell you are on into a Excel.Range when you need to access its contents.

Finally:
Many more articles can be found
here, on MSDN.

}

Saturday, October 29, 2005

Try. Fail. Try again. Fail better...

{

After months of neglect, I'm going to try this again. No more epics, just short snippets of developer talk.

}