Blog - Title

  • Fabulous Adventures In Coding

    Aargh, Part Five: Comment Rot

    • 24 Comments
    Gripe #6: Comment Rot If you've been reading my SimpleScript code you might have noticed that there are very few comments in my code. That's deliberate. Why do we have comments in the first place? We have comments because sometimes the semantics...
  • Fabulous Adventures In Coding

    What are closures?

    • 23 Comments
    JScript, as I noted yesterday, is a functional language. That doesn't mean that it works particularly well (though I hope it does) but rather that it treats functions as first-class objects. Functions can be passed around and assigned to variables just as strings or integers can be. A reader commented yesterday that "closures are your friends". Well, actually there are important situations where closures are NOT your friends! Let's talk a bit about those. First off, what's a closure?...
  • Fabulous Adventures In Coding

    When Are You Required To Set Objects To Nothing?

    • 52 Comments
    A quick follow up on my earlier entry on the semantics of Nothing in VBScript. I see code like this all the time: Function FrobTheBlob() Dim Frobber, Blob Set Frobber = CreateObject("BitBucket.Frobnicator") Set Blob = CreateObject("BitBucket.Blobnicator...
  • Fabulous Adventures In Coding

    References are not addresses

    • 76 Comments
    [NOTE: Based on some insightful comments I have updated this article to describe more clearly the relationships between references, pointers and addresses. Thanks to those who commented.] I review a fair number of C# books; in all of them of course...
  • Fabulous Adventures In Coding

    Continuing to an outer loop

    • 39 Comments
    When you have a nested loop, sometimes you want to “continue” the outer loop, not the inner loop. For example, here we have a sequence of criteria and a sequence of items, and we wish to determine if there is any item which matches every criterion: ...
  • Fabulous Adventures In Coding

    Syntax, Semantics, Micronesian cults and Novice Programmers

    • 48 Comments
    I've had this idea in me for a long time now that I've been struggling with getting out into the blog space. It has to do with the future of programming, declarative languages, Microsoft's language and tools strategy, pedagogic factors for novice and...
  • Fabulous Adventures In Coding

    Comma Quibbling

    • 277 Comments
    [UPDATE: Holy goodness. Apparently this was a more popular pasttime than I anticipated. There's like a hundred solutions in there. Who knew there were that many ways to stick commas in a string? It will take me some time to go through them all, so don...
  • Fabulous Adventures In Coding

    Benford's Law

    • 28 Comments
    While I was poking through my old numeric analysis textbooks to refresh my memory for this series on floating point arithmetic, I came across one of my favourite weird facts about math. A nonzero base-ten integer starts with some digit other than zero...
  • Fabulous Adventures In Coding

    Guidelines and rules for GetHashCode

    • 37 Comments
    " The code is more what you'd call guidelines than actual rules " - truer words were never spoken. It's important when writing code to understand what are vague "guidelines" that should be followed but can be broken or fudged, and what are crisp "rules...
  • Fabulous Adventures In Coding

    Anthimeria weirds languages

    • 23 Comments
    A little non-technical rant for a Friday. Professor Thingo, in a recent blog entry, decries the use of "Gestalt" as a verb and asks " Does the English language now allow parts of speech to be used entirely interchangeably? Did I miss a memo? " Though...
  • Fabulous Adventures In Coding

    It's still essential!

    • 3 Comments
    I am pleased to announce that Essential C# 5.0 by Mark Michaelis, and, new for this edition, yours truly , is available for pre-order now . It will be in stores in early December. As long-time readers of this blog know, I was one of the technical editors...
  • Fabulous Adventures In Coding

    Computing a Cartesian Product with LINQ

    • 18 Comments
    And here we have yet another post inspired by a question on StackOverflow : how do you compute the Cartesian product of arbitrarily many sequences using LINQ? (*) UPDATE: Ian Griffiths has an interesting series of articles that approaches this question...
  • Fabulous Adventures In Coding

    Eric's Complete Guide To BSTR Semantics

    • 35 Comments
    If you've ever done any C++ or C programming that used COM objects, you'll certainly have seen code like this: STDMETHODIMP CFo:Bar(BSTR bstrABC) { // ... What is this BSTR thing, and how does it differ from WCHAR* ? ...
  • Fabulous Adventures In Coding

    Inside or Outside?

    • 4 Comments
    Here's a question I was asked recently which I got wrong. This is why I always encourage Microsofties to ask the entire C#/VB/whatever-interest-group their question, rather than directing it to me specifically. The question was which is "better"? ...
  • Fabulous Adventures In Coding

    Binary Files and the File System Object Do Not Mix

    • 33 Comments
    OK, back to scripting today. But before I get back to scripting issues, one brief correction. An attentive reader noted that "The Well-Tempered Clavier" was in fact designed to sound good on a "well tempered" instrument, not an "equally tempered" instrument...
  • Fabulous Adventures In Coding

    What's the Difference between WScript.CreateObject, Server.CreateObject and CreateObject?

    • 21 Comments
    A reader asked me last week I have always used Server.CreateObject in ASP scripts and WScript.CreateObject in WSH scripts, because I was unable to find any *convincing* information on the subject and therefore assumed that they were there...
  • Fabulous Adventures In Coding

    Putting a base in the middle

    • 134 Comments
    Here’s a crazy-seeming but honest-to-goodness real customer scenario that got reported to me recently. There are three DLLs involved, Alpha.DLL, Bravo.DLL and Charlie.DLL. The classes in each are: public class Alpha // In Alpha.DLL { public virtual void...
  • Fabulous Adventures In Coding

    Should C# warn on null dereference?

    • 35 Comments
    As you probably know, the C# compiler does flow analysis on constants for the purposes of finding unreachable code. In this method the statement with the calls is known to be unreachable, and the compiler warns about it. const object x = null; void Foo...
  • Fabulous Adventures In Coding

    How Many Passes?

    • 50 Comments
    Large bodies of code written in the C/C++ languages typically divide up the code into “header” files, which are just declarations of methods and types (and definitions of macros). The actual bodies of those methods and types are in completely different...
  • Fabulous Adventures In Coding

    Is C# a strongly typed or a weakly typed language?

    • 36 Comments
    Presented as a dialogue, as is my wont! Is C# a strongly typed or a weakly typed language? Yes. That is unhelpful. I don't doubt it. Interestingly, if you rephrased the question as an "and" question, the answer would be the same. What?...
  • Fabulous Adventures In Coding

    Bankers' Rounding

    • 25 Comments
    A number of people have pointed out to me over the years that VBScript's Round function is a bit weird. It seems like it should be pretty straightforward -- you pick the integer closest to the number you've got, end of story. But what about, say, 1.5? There are two closest integers. Do you go up or down?...
  • Fabulous Adventures In Coding

    Locks and exceptions do not mix

    • 39 Comments
    A couple years ago I wrote a bit about how our codegen for the lock statement could sometimes lead to situations in which an unoptimized build had different potential deadlocks than an optimized build of the same source code. This is unfortunate, so we...
  • Fabulous Adventures In Coding

    Graph Colouring, Part Five

    • 14 Comments
    I said last time that I was interested in finding colourings for graphs that have lots of fully connected subgraphs, aka "cliques". For instance, I'd like to find a four-colouring for this sixteen-node graph: Yuck. What a mess. What this graph...
  • Fabulous Adventures In Coding

    Murky Research

    • 18 Comments
    No computers today, but some interesting - and important - math. (And, happy Canada Day, Canadians!) " Car Talk " is a popular weekly phone-in program that has been on National Public Radio for several decades now, in which Bostonian brothers Tom and...
  • Fabulous Adventures In Coding

    Do not name a class the same as its namespace, Part One

    • 25 Comments
    (This is part one of a four part series; part two is here .) The Framework Design Guidelines say in section 3.4 “do not use the same name for a namespace and a type in that namespace”. (*) That is: namespace MyContainers.List { public class List { … ...
Page 2 of 32 (783 items) 12345»