Wednesday, March 15, 2023

It takes a lot of people to ship a complex product

 I'm a Program Manager (PM) for one of Those Big Companies. I don't actually program except as a hobby, and I don't manage. Where I add value is making sure that what we're building is what our customers need.

"I could build a replacement with just ___ people"

No, you couldn't, if it's a complex project. I was recently reminded of the true history of the automobile: a long, hard slog by an enormous number of people to get each element of a car to actually work. In particular, take a look at Motor-Car Principles on Project Gutenberg. Among the many, many things that had to be painfully figured out


How to stop a car. The book lists a whole series of brake types (none of them disk brakes like in modern cars) 



How an axle works. Car axles are not wagon axels, and you can't use one instead of the other.

Building a transmission. This is something steam engines, for example, simply don't have. A steam engine on a train is directly connected to the wheels with no intervening transmission.



Making a piston. Steam engines, in contrast to car engines, are forgiving: as long as the timing is roughly correct, the steam engine will work. A gas engine has much higher tolerances.

The book goes on with a long, long list of technologies that are unique to cars.

Moral of the story: some projects are pretty simple and can be done with a small team (or even just one person). But once you get to new technology, it's a quagmire that requires an extraordinary amount of work just to know what needs to be done, and from there to co-ordinate the work so that all the parts show up on time.

Thursday, March 2, 2023

Fixing "The type or namespace 'Windows' could not be found" error CS0246

"The type or namespace 'Windows' could not be found" solution!

Every time I install a new version of Visual Studio, I run into just a metric hand-full of errors from previously working projects. The projects haven't changed, but suddenly Visual Studio is seemingly incapable of finding the "Windows" namespace.

My Solution: run the Visual Studio Installer". Pick your installed version and click Modify. The modification you probably want is to under Universal Windows Platform development in the Optional section. Look at the list of available Windows SDK and just install them all (assuming you have enough disk space).

There's no harm (AFAICT) in getting them all, and it will save you heartache and frustration down the line.

This entire process is just a cluster. What's more common than building apps for Windows using the compiler tools from Microsoft that are specifically designed to build Windows apps? Well, the only thing more common then developing windows apps is seeing yet another place where Visual Studio once again makes development more painful.

For me, the #1 reason I get the error is that I don't have enough of the Windows SDKs installed. By default, the Visual Studio installer only installs the "most recent" SDK. You might think that's enough, but it's not.

Each project will have a reference path that looks like this:

    <Reference Include="Windows.Foundation.UniversalApiContract">
      <HintPath>..\..\..\..\..\..\Program Files (x86)\Windows Kits\10\References\10.0.22010.0\Windows.Foundation.UniversalApiContract\14.0.0.0\Windows.Foundation.UniversalApiContract.winmd</HintPath>
    </Reference>

Note how the HintPath specifies exactly one particular SDK. If you have a more recent version, it doesn't count even though the contracts are specifically designed to be upwards compatible.

What's worse, Visual Studio loves to kind of silently update your project files, so you'll silently be updated, potentially breaking the project on a different computer.

Error CS0246 The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)

Sunday, February 5, 2023

Wi-Fi Performance samples

 Wi-Fi Performance, broadly

Number 2 in a series on Wi-Fi performance. This time, Wi-Fi (and networking in general) is compared in difference places is compared. Sneak preview: Bluetooth PAN is the slowest :-)


I ran a simple speed test and gathered latency information (round-trip UDP times) in a variety of places and network. No surprise, Ethernet is the fastest and Bluetooth is the slowest. Airport Wi-Fi had generally high throughput (it's higher throughput than my house Wi-Fi network, although note that I have fiber with a low bandwidth cap) but with medium latency.

PAN? Bluetooth Personal Area Network? What's that?

Bluetooth PAN (Personal Area Network) is a technology that lets you share an internet connection from one laptop to another using Bluetooth instead of Wi-Fi. I'm not quite sure why people would do this, but it's still supported in Windows. It's got a non-winning combination of low speed and high latency. 

To actually share a network connection using PAN:

1. On the "host" laptop, open the Mobile Hotspot settings, and share your Wi-Fi (or Ethernet) connection with Bluetooth. 

2. On the "using" laptop, you need to get to the PAN settings page. AFAICT, there's only one way to do this: 

  • right-click on the Bluetooth icon and click "Join a Personal Area Network"
  • in the resulting Vista-era "Devices and Printers", select the "host" computer whose network you want to join. You might need to first pair with the "host" computer.
  • click connect using and select direct connection.


Wi-Fi: Is it faster on AC? Is it slower on Battery?

 Wi-Fi Performance: AC versus DC

One of a series of comparisons to learn what makes a difference in Wi-Fi performance.

TL/DR: they aren't difference, at least on my setup.

In the screenshot, I've done several latency, download, and upload tests against one specific server.

Test methodology: With the laptop plugged in, run all the speed tests twice with "AC" as the note. Then remove the docking station (the part that is plugged in) and run the same tests against the same server and mark them "DC".

Data Analysis: 
  • Download mean throughput increased from 16.2 Mbps to 18.4 Mbps going from DC to AC. This isn't a large difference.
  • Upload mean throughput decreased from 31.3 Mbps to 31.28 Mbps going from DC to AC. This is almost certainly not a real difference.
  • Mean Latency decreased from 12 msec to 10.3 msec. My stats program tells me this is probably a real difference. The DC had a little bit less jitter, but not by a real amount.
Conclusion: Wi-Fi is about the same speed on DC as it is on AC.

Tuesday, January 10, 2023

Adding Pivot Item causes massive crash in UWP XAML

 Surprise exception when adding PivotItem

Quick background: my Simple Wi-Fi Analyzer program is getting a hidden feature which is unlocked by manipulating the UX in a secret way. I won't say what the secret is, but you can always look for "Unlock" in the source code :-)

The Analyzer app uses the nice Pivot control: I define a bunch of tabs for different features, and the user picks the tool they want to use. The new feature is a hidden tab, and my unlock code simply unhides it.

Except it doesn't. You can't actually hide a PivotItem in a Pivot control; it's not supported. Instead you have to create the PivotItem in code and then add it to the pivot.Items collection, it is shows right up!

Except you actually get this Vista-era dialog:


The problem (not even on Stack Overflow) is simple: you can't update a pivot.Items collection while you're in a PivotSelectionChanged callback! The solution is to 

Instead add in code like this:

                    var task2 = this.Dispatcher.RunIdleAsync((arg) => {
                        MethodThatAddsPivotItem();
                    });


You don't have to wait for the task; it will just run when it's appropriate.


Saturday, January 7, 2023

Calculating Standard Deviation

 Calculating Standard Deviation 

The "classic" formulas aren't always the "easiest to program" formulas. Let's look at the classical formula to calculate a sample standard deviation:

σ = √ (Σ(xᵢ-x̅)²)/(n-1)

where σ is the standard deviation,  is the mean and n is the sample count. But note that we have to walk through the numbers twice: once to calculate the mean, and then again for the rest of the calculations. And yet, old fashioned scientific calculators with just a handful of registers (memory locations) could do this calculation by just entering in a column of numbers. What gives?

The answer is that although conceptually you are summing the square of the difference between each sample and the mean, you can actually do the calculation differently as long as you can keep track of n, the sum of x, and the sum of x². The resulting calculation is:

σ = √(Σ(xᵢ²) - ((Σxᵢ)² / n))/(n-1)

or, slightly more computery: for each new x:

1. n++

2. sumX += x;

3. sumXSquared += x*x;

4. varianceEstimate = (sumXSquared - ((sumX*sumX) / n) / (n-1)

5. stdDevEstimate = SQRT(varianceEstimate)


And you get a running estimate for the standard deviation. You also get the variance, but that's not often really needed.

Statisticians call these the "estimates" because the statistical theory is that there's a magic, universal reality for the actual population variance and standard deviation for which these samples provide an estimate. They aren't wrong :-)




Thursday, January 5, 2023

Handling the TITLE option

The information (i) element isn't any part of the Gopher RFC (most of Gopher is part of RFC 1436, and the Gopher URL is documented in RFC 4266), and therefore neither is the common practice of putting displaying an information element differently when a TITLE is put into the directory entry selector.

Thanks to a GopherSpace crawl, I know that out of about 2100 menus crawled, there were 305 information elements with a TITLE on them -- that's actually a pretty impressive percentage, and presumably it's driven by automated Gopher menu file creation. I'm wondering, though: as the programmer for a Gopher client, how many different Gopher client will render the TITLE elements specially? For that matter, how many Gopher pages put something into column 5, where the "+" in Gopher+ puts the Gopher+ indicator?

(I know that the first version of my own doesn't because I didn't know about the TITLE concept).

Let's start by analyzing pages that have too many columns (e.g., more than 5 columns, which corresponds to having more than 4 embedded tabs). There are five such directory entries in my GopherSpace crawl. Three are from a single page which, when I looked at is, is really an HTML page that's being served up as if it was Gopher. Of the remaining two entries, one has a user string consisting of three tabs instead of real data, and the other (from a different menu) has three tabs too many at the end of the line but and doesn't have any actual data in the columns.

We can also analyze the number of columns in directory entries

Almost all of the Gopher directory entries are the standard four columns. You can hardly tell the actual numbers, but 1907 entries were a single column, 9 were 2 columns, 895 were three, and 6590 were 5. There were 151840 entries with 4 columns.