Feed fabulous-adventures-in-coding Fabulous adventures in coding

Favorite IconFabulous adventures in coding

Link https://ericlippert.com/
Feed http://ericlippert.com/feed
Updated 2024-04-27 22:31
Ask me anything!
The nice people at the programmerchat section of reddit have asked me to do an Ask Me Anything, and of course I am happy to do so. Thanks to reddit for the invitation. For those of you unfamiliar with the … Continue reading →
A different copy-paste error
I briefly discussed copy-paste errors in code earlier; though this is a rich area of defects that I will probably at some point go into more detail on, that’s not for today. Though this is a trivial little issue, I … Continue reading →
When everything you know is wrong, part two
Now that we’ve looked at a bunch of myths about when finalizers are required to run, let’s consider when they are required to not run: Myth: Keeping a reference to an object in a variable prevents the finalizer from running … Continue reading →
When everything you know is wrong, part one
Finalizers are interesting and dangerous because they are an environment in which everything you know is wrong. I’ve written a lot about the perils of C# finalizers / destructors (either name is fine) over the years, but it’s scattered in … Continue reading →
Wizards and warriors, part five
We’ve been struggling in the last four episodes to encode the rules of our business domain — which, recall, could be wizards and warriors or papers and paycheques or whatever — into the C# type system. The tool we’ve chosen … Continue reading →
Flat-pack sawhorses
You’ll have to wait until Monday for the thrilling conclusion to my Wizards and Warriors series. Today on fun-for-Friday FAIC, some thoughts on sawhorses. I made these light-duty sawhorses out of some scrap two-by-fours in 1997: (Click for a larger … Continue reading →
Wizards and warriors, part four
Last time we saw that in order to decide what code to call based on the runtime type of one argument — single dispatch — we could use virtual dispatch. And we saw that we could use the inaptly-named Visitor … Continue reading →
Wizards and warriors, part three
So let’s digress for a few episodes here. We’ll temporarily leave aside the problem of how we can have both a Player that has a Weapon and a Wizard that has a Staff. (Or Dagger.) Supposing that we can figure … Continue reading →
Wizards and warriors, part two
In this series we’re exploring the problem “a player can use a weapon, a wizard is a kind of player, a staff is a kind of weapon, but a wizard can only use a staff”. The best solution we’ve come … Continue reading →
Wizards and warriors, part one
A common problem I see in object-oriented design is: A wizard is a kind of player. A warrior is a kind of player. A staff is a kind of weapon. A sword is a kind of weapon. A player has … Continue reading →
DRY out your policies
Occasionally I’m asked to review code that has a lot of repetition in it. Like, for instance, someone is writing a function memoizer: static Func<A, R> Memoize<A, R>(this Func<A, R> function) { var cache = new Dictionary<A, R>(); return argument … Continue reading →
Long division, part two
This is a sequel to my 2009 post about division of long integers. I am occasionally asked why this code produces a bizarre error message: Console.WriteLine(Math.Round(i / 6000000000, 5)); Where i is an integer. The error is: The call is … Continue reading →
Defying gravity
No tech today, but some fun for Friday. The 2015 Moisture Festival is over; if you’re not familiar with the festival, it’s a month-long celebration of old-timey and modern vaudeville, comedy, variety, burlesque and circus arts at multiple venues here … Continue reading →
Interview with dev.life
Gareth Wilson from Fog Creek interviewed me the other day for their series on the lives of developers; we talked about playing Dam Buster on the Commodore PET and typing in programs in WATCOM VI and all kinds of stuff. … Continue reading →
What is the unchecked keyword good for? Part two
Last time I explained why the designers of C# wanted to have both checked and unchecked arithmetic in C#: unchecked arithmetic is fast and dangerous, checked arithmetic is slightly slower but turns subtle, easy-to-miss mistakes into program-crashing exceptions. It seems … Continue reading →
What is the unchecked keyword good for? Part one
One of the primary design goals of C# in the early days was to be familiar to C and C++ programmers, while eliminating many of the “gotchas” of C and C++. It is interesting to see what different choices were … Continue reading →
Too many hobbies
Hey all, apologies for the sudden and very long break there. A number of people asked me if I was OK, falling off the face of the earth like that — thanks for your concern, I am fine, just over-busy. … Continue reading →
Nostalgia, horror, and a very old bug
My next article about graph traversal is pre-empted by this breaking news; I’ll pick up that series again soon. Yesterday morning a coworker forwarded to me an article about a recently patched security hole in Windows, and wondered if I had … Continue reading →
Traffic light UX
We interrupt our series on graph traversal for the following question. Here are some UX elements from a “quiz” program I used recently: In this series of activities, select whether each person should: Stop now because the action is inappropriate … Continue reading →
Graph traversal, part four
Let’s return now to our modified Zork graph fragment from a couple episodes back: It is pretty obvious just from looking at this graph that if you start from the Troll Room and follow the arrows, there are four rooms … Continue reading →
Graph traversal, part three
Last time we made a little recursive algorithm to walk around a directed acyclic graph, or DAG. I made that algorithm a member of the graph class, but did you notice something about it? It did not access any private … Continue reading →
Graph traversal, part two
Last time we built an immutable structure representing a labeled directed graph, and then built a directed acyclic graph stolen from Zork: (click for larger) The question at hand is: given a node in a finite DAG, what are all … Continue reading →
Graph traversal, part one
There are lots of topics in both practical and theoretical computer science that deal with graphs, lots of different kinds of graphs, lots of ways to represent a graph as a data structure, and lots of operations you’d want to … Continue reading →
Producing combinations, part five
Previously we enumerated all the combinations of a particular size from a sequence by observing that the sequence {50, 60, 70, 80, 90} had combinations of exactly three elements as follows: { // 50, 60, 70, 80, 90 {50, 60, … Continue reading →
Eclipse viewing in Seattle
There’s a partial eclipse starting in about ten minutes, and wonder of wonders, it has cleared up in Seattle! I didn’t expect this would happen so I didn’t bring any eclipse-viewing equipment with me. That means it’s time to improvise. (Click … Continue reading →
123456