by ericlippert on (#9VVN)
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 →
|
Fabulous adventures in coding
Link | https://ericlippert.com/ |
Feed | http://ericlippert.com/feed |
Updated | 2024-11-21 11:30 |
by ericlippert on (#9SJ1)
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 →
|
by ericlippert on (#9FRG)
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 →
|
by ericlippert on (#991K)
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 →
|
by ericlippert on (#8V0Y)
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 →
|
by ericlippert on (#8N28)
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 →
|
by ericlippert on (#8JRK)
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 →
|
by ericlippert on (#8BPY)
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 →
|
by ericlippert on (#84WM)
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 →
|
by ericlippert on (#7Y14)
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 →
|
by ericlippert on (#7NQK)
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 →
|
by ericlippert on (#7ED3)
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 →
|
by ericlippert on (#78YR)
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 →
|
by ericlippert on (#71CT)
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 →
|
by ericlippert on (#6ZA7)
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 →
|
by ericlippert on (#6QD4)
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 →
|
by ericlippert on (#6KBD)
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 →
by ericlippert on (#2XH3)
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 →
|
by ericlippert on (#2XH5)
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 →
|
by ericlippert on (#2XH7)
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 →
|
by ericlippert on (#2XH9)
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 →
|
by ericlippert on (#2XHB)
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 →
|
by ericlippert on (#2XHC)
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 →
|
by ericlippert on (#2XHE)
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 →
|
by ericlippert on (#2XHF)
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 →
|