The Heavy Water War

If you enjoy WWII history, check out The Heavy Water War on Netflix. The Norwegian miniseries tells the true story of the Allied efforts to sabotage a factory which produced a critical ingredient for the Nazi nuclear weapons program–deuterium oxide–heavy water. A small team consisting of English and Norwegian soldiers was tasked with sneaking explosives into the basement of the guarded facility in the height of Scandinavian winter. They endured feats of unbelievable courage and made difficult decisions to carry out their orders.

Update on soldering

In order to prototype some circuits I thought it would be a good idea to build some boards which had NOR, NAND, AND, and OR gates pre built to speed things up. I bought about 300 through-hole transistors and resistors and started building the first board on a perforated board from RadioShack. It turns out this is a terribly slow way to prototype. I spent 8 hours soldering on the first board (only 13 NOR gates) and it’s not finished yet. I’m getting a lot better at soldering small connections though! I only had to break out the solder wick twice.

Instead of building these boards with perfboard, I’m going to stop and learn how to use KiCad to design a printed board using surface mount components. I’ll have to order the boards online but I’ll reflow solder them myself. I’m going to start with the same prototype board designs so I can learn how well this works.

There’s a new makerspace in town about ready to open up. They have a circuit board printer so I may look into that route eventually.

You should… A lesson from mentoring

When I started mentoring junior developers, I had a bad habit of saying things like “you should…<my opinion>”. When giving directions, it’s direct to the point, however I don’t think phrasing directions this way helps new developers learn as quickly as guiding them in a way that requires them to make decisions themselves. Today I find myself replacing those “you should” moments with phrases more like “Have you considered…?” or “In my experience…” or pointing them towards an article or specific MSDN page. Sometimes they’ll be able to explain what they want to do but don’t know the technical term for it. By supplying one it’s much easier for them to google for more resources. Once they have some good context on the problem, I’ve found that simply following a Socratic line of questioning about the details of the problem is very effective. Usually they interrupt with me with “Oh I have an idea now!”

Searching for a word in Visual Studio

I was trying to find all usages of a variable in a SQL script today, however the script contained many similarly named variables. Simply searching for @Foo would also find @FooBar and @FooCat which was cluttering up the search results. To get around this I used the regex search feature in Visual Studio. In the find usages window, check the “Use Regular Expressions” checkbox and then include the word boundary escape code (\b) in your search. I searched for @Foo\b which will only return @Foo and even find it in cases like @Foo<space>, @Foo) and @Foo=.

SQL INSERT vs UPDATE

I’m curious as to why the insert and update commands in SQL have different syntax. So far I have been unable to find any satisfactory explanation. I personally have a gripe with the insert syntax in that the column names are separated from the inserted value. In wide tables this makes it difficult to alter existing stored procedures since you have to manually count fields or come up with a commenting scheme. Even then, you aren’t guaranteed you’ll find a bug at runtime.

I propose that in addition to the normal syntax

INSERT INTO Foo (ColumnA, ColumnB, ColumnC)
VALUES ('First', 'Second', 'Third')

SQL also support an alternate syntax such as:

INSERT INTO Foo
SET
ColumnA = 'First',
ColumnB = 'Second',
ColumnC = 'Third'

This syntax is easily readable and much more maintainable than the existing syntax.

MySQL has already adopted this syntax but unfortunately SQL Server has not. In the meantime I’ll continue commenting my large inserts like this:

INSERT INTO Foo (ColumnA, ColumnB, ColumnC)
VALUES (
'First',  -- ColumnA
'Second', -- ColumnB
'Third'   -- ColumnC
)

I wish C# had this Java feature

In Java there is a feature called the Catch or Specify Requirement. This feature requires that each method specify what exceptions it may throw. Any caller to that method must either include a catch block for the exceptions or specify that it can pass the exceptions up the call chain. A Java application will not compile if all exceptions are not handled.

C# does not have any similar feature. When working with unfamiliar system classes, I typically refer to MSDN to learn what exceptions they may raise. Unfortunately if I miss something, the C# compiler does not provide any warning.

C# does provide the ability to document the exceptions using the <exception> tag, but this is only used to generate documentation and provide intellisense in Visual Studio. There is a ReSharper add-in called Exceptional which warns you about uncaught exceptions. I have not tried it, but according to feedback on Stack Overflow, it generates too much noise to be useful.

My general practice is to use generic exception handling blocks at the highest level of my code so errors can at least be caught, logged, and feedback given to the user.