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)

}