The Daily Parker

Politics, Weather, Photography, and the Dog

In other Chicago news...

Eddie Lampert's reign of terror against Sears continued today when the chain announced the closing of their very last store in Chicago:

Sears, founded in Chicago and facing mounting troubles, is closing its last store in the city.

Employees at the store at Six Corners in the Old Irving Park neighborhood were told of the closure Thursday morning, spokesman Howard Riefs said in an email. The store will close in mid-July after a liquidation sale set to begin April 27. The Sears Auto Center will close in mid-May.

The store was one of 265 properties sold to Seritage Growth Properties in a 2015 sale-leaseback deal.

“For more than 120 years, Sears has called Illinois home and that is not changing,” Riefs said. “Although we are disappointed by this last store closure in Chicago, by no means does this change our commitment to our customers and presence to Chicago’s residents.”

Of course it doesn't change their commitment to Chicago; they haven't had one since 2005.

Howard, Eddie: I'm thinking of a phrase that ends with "...and the horse you rode in on."

Disappearing Midwestern accents

Edward McClelland essays on the decline of the white blue-collar Midwest, as expressed linguistically:

The “classic Chicago” accent, with its elongated vowels and its tendency to substitute “dese, dem, and dose” for “these, them, and those,” or “chree” for “three,” was the voice of the city’s white working class. “Dese, Dem, and Dose Guy,” in fact, is a term for a certain type of down-to-earth Chicagoan, usually from a white South Side neighborhood or an inner-ring suburb.

The classic accent was most widespread during the city’s industrial heyday. Blue-collar work and strong regional speech are closely connected: If you were white and graduated high school in the 1960s, you didn’t need to go to college, or even leave your neighborhood, to get a good job, and once you got that job, you didn’t have to talk to anyone outside your house, your factory, or your tavern. A regular-joe accent was a sign of masculinity and local cred, bonding forces important for the teamwork of industrial labor.

The classic Chicago accent is heard less often these days because the white working class is less numerous, and less influential, than it was in the 20th century. It has been pushed to the margins of city life, both figuratively and geographically, by white flight, multiculturalism and globalization: The accent is most prevalent in blue-collar suburbs and predominantly white neighborhoods in the northwest and southwest corners of the city, now heavily populated by city workers whose families have lived in Chicago for generations.

There’s a conception that television leveled local accents, by bringing so-called “broadcaster English” into every home. I don’t think this is true. No one watched more television than the Baby Boomers, but their accents are much stronger than those of their children, the Millennials.

What’s really killing the local accent is education and geographicmobility, which became economic necessities for young Rust Belters after the mills closed down. But as blue-collar jobs have faded, so has some of our linguistic diversity.

McClelland adapted his CityLab essay from his 2016 book How to Speak Midwestern, which is obviously now on my Amazon wish list.

K is for Key-Value Pairs

Blogging A to ZThe Blogging A-to-Z challenge continues on Day 11 with key-value pairs and simple tuples.

A tuple is a finite ordered list of elements. In mathematics, you usually see them surrounded by parentheses and delineated with commas, like so: (2, 3, 5, 8, 13).

.NET has several generic Tuple classes with 2 through 7 items in the sequence, plus a KeyValuePair<TKey, TValue> structure that is the equivalent of Tuple<T1, T2>.

I'm actually not a fan of the Tuple class, though I get why it exists. I prefer naming things what they actually are or do. If you're doing mathematics and need a 3-item tuple, use Tuple<T1, T2, T3>. But if you're doing geography and you need a terrestrial coordinate, create an actual Node<Easting, Northing, Altitude> class and use that instead. (Or just add the Inner Drive Extensible Architecture from NuGet to your project and use mine.)

You probably can't avoid the KeyValuePair<TKey, TValue> structure, however. It's coupled to the Dictionary<TKey, TValue> class, which you will probably use frequently.

Example:

#region Copyright ©2018 Inner Drive Technology

using System.Collections.Generic;

#endregion

namespace InnerDrive.DailyParkerAtoZ.WeekOne
{
	public class KeyValuePairs
	{
		public void Add(string name, Room room)
		{
			_rooms.Add(name, room);
		}

		public Room Find(string name)
		{
			return _rooms.ContainsKey(name) ? _rooms[name] : null;
		}

		public void Remove(string name)
		{
			if (_rooms.ContainsKey(name)) _rooms.Remove(name);
		}
		
		private readonly Dictionary<string, Room> _rooms = new Dictionary<string, Room>();
	}
}

Under the hood, the Dictionary<string, Room> object uses KeyValuePair<string, Room> objects to give you a list of rooms. Note that the key must be unique inside the dictionary; you can't have two rooms called "cupboard under the stairs" or it will throw an exception. Also note the safety features in the code above: the demo class won't throw an exception if you try to find or remove a room that doesn't exist. (There's a philosophical question buried in there: why should or shouldn't it throw?)

As always, download and play with the code samples for more fun and enjoyment.

J is for JetBrains

Blogging A to ZFor day 10 of the Blogging A-to-Z challenge, I'd like to give a shout out to a Czech company that has made my life so much easier over the past five years: JetBrains.

Specifically, their flagship .NET accelerator tool ReSharper makes .NET development so much easier I can't even remember life without it. (If you've downloaded the code samples for this challenge, you may have seen either in the code or in the Git log references to ReSharper, usually when I turned off an inspection for a line or two.)

I'm just going to quote them at length on what the product does:

Code quality analysis

On-the-fly code quality analysis is available in C#, VB.NET, XAML, ASP.NET, JavaScript, TypeScript, CSS, HTML, and XML. ReSharper will let you know if your code can be improved and suggest automatic quick-fixes.

Code editing helpers

Multiple code editing helpers are available, such as extended IntelliSense, hundreds of instant code transformations, auto-importing namespaces, rearranging code and displaying documentation.

Code generation

You don't have to write properties, overloads, implementations, and comparers by hand: use code generation actions to handle boilerplate code faster.

Eliminate errors and code smells

Instant fixes help eliminate errors and code smells. Not only does ReSharper warn you when there are problems in your code but it provides quick-fixes to solve them automatically.

Safely change your code base

Apply solution-wide refactorings orsmaller code transformations to safely change your code base. Whether you need to revitalize legacy code or put your project structure in order, you can lean on ReSharper.

Compliance to coding standards

Use code formatting and cleanup to get rid of unused code and ensure compliance to coding standards.

Instantly traverse your entire solution

Navigation features help you instantly traverse your entire solution. You can jump to any file, type, or member in your code base in no time, or navigate from a specific symbol to its usages, base and derived symbols, or implementations.

I can't endorse this product strongly enough. Use ReSharper whenever you're using Visual Studio. It's worth it.

I is for Interface

Blogging A to ZDay 9 of the Blogging A-to-Z challenge brings up one of the key concepts in object-oriented design: the interface.

In object-oriented design, rule #1 is "program to interfaces, not to implementation." In other words, when interacting with an object in your system, you should care about what behaviors and data you need to use, not what the object actually does with them.

Going back to last week's room-and-window example: the original problem was that I want to close all the windows in the house with one method call. The solution on Saturday involved having a Room class that exposed a list of Window objects which you could iterate over and call the Close() method on each.

That's great, but what if I want to close all the windows, doors, fireplaces, and anything else that I can close, because of the zombie apocalypse? In Saturday's implementation, I need to know that rooms have windows, doors, fireplaces, and other things specifically. That is, I need to know how each room is implemented.

I really don't care whether the thing is a window, a door, or a squirrel's mouth; I want it closed now, before the zombies get in.

So let's do this instead: define the behavior of a thing that I can close, and operate on the behavior rather than the thing itself. In C#, I can define an interface, which would look like this (and refer back to Saturday or the code sample file for the rest of the implementation):

namespace InnerDrive.DailyParkerAtoZ.WeekOne
{
    public interface ICloseable
    {
	    void Close();
    }
}

That defines a single behavior that a class can do. (Interfaces can also define data and events, but that's beyond the scope of this post.)

Now I can add the interface to the Window class:

public class Window : ICloseable
{
	public void Close() { }
	public void Open() { }
}

And then refactor the Room class so that you can add and close all manner of closeable things:

public class Room
{
	public void Add(ICloseable closeable)
	{
		_closeableThings.Add(closeable);
	}

	public void CloseEverything()
	{
		foreach (var thing in _closeableThings)
		{
			thing.Close();
		}
	}

	public IEnumerable<ICloseable> Windows => 
		new List<ICloseable>(_closeableThings.Where(p => p is Window));

	private readonly List<ICloseable> _closeableThings = new List<ICloseable>();
}

Well, that looks different. Instead of adding windows to a room, I can now add anything that can be closed. And because of that, at lines 16 and 17, in order to make sure the Windows list still works, I have to change the code so it only returns windows.

It's still a dumb piece of code, but you can start to see how powerful interfaces are. If in the future I create some new class with a Close() method, I can apply the ICloseable interface to it and stick it in a room. (Books, maybe? Escrow accounts? People named Glenn?)

There are many, many implications to all of this. But this is one of the foundations of OO design. I don't care what the thing is, I care what it does or knows. Program to interfaces, not to implementations.

H is for Human Factors

Blogging A to ZThe Blogging A-to-Z challenge enters its second week with a note about you, the human.

Last week I discussed several topics that you probably thought were about computers. They weren't. They were about how you interact with computers.

Computers don't need programming languages. This is a perfectly runnable program for the 6502 microprocessor:

0600: a9 01 8d 00 02 a9 05 8d 01 02 a9 08 8d 02 02

The human-readable version looks like this:

$0600    a9 01     LDA #$01
$0602    8d 00 02  STA $0200
$0605    a9 05     LDA #$05
$0607    8d 01 02  STA $0201
$060a    a9 08     LDA #$08
$060c    8d 02 02  STA $0202

Imagine looking at that all day and trying to debug it. You'd go insane. I know, because back in the day, I wrote that kind of code for 6502 chips and, well, you have evidence about my sanity in these pages.

This is why we use high-level languages instead of low-level ones. We try to abstract away all the crap. Instead of writing for the machine to read, as you do with assembly language (and even there you have a thin abstraction layer), you write software for a human to read.

And the languages continuously improve. Here, below, is some of the first code I ever plagiarized wrote that lived in a production application. You might understand what it does from reading it:

day=VAL(MID$(dtee$,4,2))
month=VAL(LEFT$(dtee$,2))
year=VAL(RIGHT$(dtee$,4))
hour=VAL(LEFT$(ttee$,2))
minute=VAL(MID$(ttee$,4,2))

MDYTOJULIAN:
   julian!=INT(365.2422# * year + 30.44 * (month-1) + day + 1)
   t1=month - 2 - 12 * (month<3)
   t2=year + (month<3)
   t3=INT(t2/100)
   t2=t2-100*t3
   weekday!=INT(2.61*t1-.2) + day + t2 + INT(t2/4)
   weekday! = (weekday! + INT(t3/4) - t3 - t3 + 77) MOD 7 + 1
   t4=julian! - 7 * INT(julian!/7)
   julian!=julian!-t4+weekday!+7*(t4<weekday!-1)+1721060#
   day$=dow$(weekday!)+","+STR$(day)+" "+month$(month)+STR$(year)
   h=hour-12
   IF h<0 THEN julian!=julian!-1:_
      h=h+24
   ju#=CDBL(julian!)
   ju#=ju#+(h/24)+(minute/1440)

That language is called QuickBASIC, which Microsoft published from 1985 until 1991, when Visual BASIC took over. It's a subroutine that converts a date into its Julian day number. I developed it because in QuickBASIC there was no way to do simple date calculations, but in astronomy, there was.

Here's the C# version:

public static double ToJulianDayNumber(this DateTimeOffset date)
{
   return date.ToOADate() + 2415018.5;
}

Forget that this is a naïve implementation, as there are a ton of special cases before the 19th century; and also forget that it uses a magic number that depends on understanding a bit of .NET and Windows internals (like, for example, that JD 2415018.5 is 30 December 1899, which is the epoch date for OLE automation).

The point is, I can abstract away all the calculations and create an extension method which allows me to get any Julian day number just by calling that method on any date-time struct:

var julian = DateTimeOffset.UtcNow.ToJulianDayNumber();

As a human, I'd bet you find that a lot easier to read and understand than the MDYTOJULIAN subroutine above.

But C# makes it even easier to calculate the difference between two dates, obviating the Julian day entirely, unless you're writing software specifically for astronomers:

var otherDay = new DateTimeOffset(2017, 01, 20, 17, 0, 0, TimeSpan.Zero)
var days = DateTimeOffset.Now.Subtract(otherDay).TotalDays;

Because really, you're trying to get the total days between two dates. The Julian day is a required abstraction when you don't have date arithmetic built in. But when you can just do date.Subtract(otherDate) to get a TimeSpan object, the code is a lot easier for humans to read.

Let the compiler worry about the machine. You worry about other humans.

Further reading:

G is for Generics

Blogging A to ZFor day 7 of the Blogging A-to-Z challenge, I'm going totally generic.

A generic in C# allows your code to "defer the specification of one or more types until the class or method is declared and instantiated by client code." In other words, you can declare a class that takes a type to be named later.

Imagine you have a program that represents a house. Your house has rooms, and the rooms have windows, doors, and in some cases, fireplaces. They also have furniture. And sometimes headless corpses. (Don't ask.)

If you were using C# 1.0, you'd need to design structures to hold all of these things, and you'd probably wind up using arrays, like this:

#region Copyright ©2002 Inner Drive Technology

using System.Collections;

#endregion

namespace InnerDrive.DailyParkerAtoZ.WeekOne
{
	public class Window
	{
		public void Close() { }
		public void Open() { }
	}


	public class RoomV1
	{
		public void Add(Window window)
		{
			_windows.Add(window);
		}

		public IEnumerable Windows
		{
			get
			{
				return new ArrayList(_windows);
			}
		}

		private readonly ArrayList _windows = new ArrayList();
	}
}

The only problem is...you don't really know for sure whether the things going into or coming out of the _windows array list are actually windows. That's because the System.Collections.ArrayList class only stores objects, not specific kinds of objects.

Generics allow you to impose type safety on the collection of windows through the use of a type parameter. Now you can do this:

public class Room
{
	public void Add(Window window)
	{
		_windows.Add(window);
	}

	public IEnumerable<Window> Windows => new List<Window>(_windows);

	private readonly List<Window> _windows = new	List<Window>();
}

(Notice also the nifty shorthand on line 8 that eliminates the get method.)

This works because the List<T> class takes any object type for T, leaving it up to the compiler to work out what type it should contain. The prototype for the class looks something like this:

public class List<T>
{
	public void Add(T input) { }
}

The type parameter T can be anything. (You can restrict what T can contain, which I will leave as an exercise for the reader.)

Generics simplify a lot of programming tasks. But just wait until Tuesday when I show you how to make object-oriented designs really fly in C#.

Housekeeping note: The A-to-Z Challenge takes Sundays off. The next post in this series will be on Monday. Enjoy your weekend!

F is for F#

Blogging A to ZWe're up to day 6 of Blogging A-to-Z challenge, FFS.

The last few days I've written about the two main object-oriented languages that come with Visual Studio and .NET: C# and VB.NET. Today I want to diverge just a little into Microsoft's functional language, F#.

At first glance, F# looks a lot like C#. It is, in fact, a flavor of C#; and as it runs on the .NET CLR, it uses .NET constructs. But as Microsoft says, "F# is a programming language that provides support for functional programming in addition to traditional object-oriented and imperative (procedural) programming." Part of this support is the ability to express functions as first-class values. That means you can pass functions around as variables, and do things with them, in ways you can't with C# or other object-oriented languages (sort of—C# can do this too as of 4.7).

Here's an example:

let celsius (f: float) : float = (f - 32.0) * (5.0 / 9.0)

[<EntryPoint>]
let main argv =
    let c = 68.0
    printfn "%f Fahrenheit is %f Celsius" c (celsius c)
    0;;

This is just one step up from "Hello World," in that it actually does something. Two interesting bits: (a) You don't actually need to run this using the EntryPoint identifier; you can run it interactively; and (b) More importantly, celsius is just a variable.

I would love to spend another hour on this post, but I can't do the topic justice. Scott Wlaschin, on the other hand, will show you how to use F# for fun and profit. I recommend his site if you want to learn more.

But here's the sad truth: it's not very practical yet. And C# allows you to pass functions as parameters, even anonymously, so F# no longer has a monopoly on functional programming.

Remember, these A-to-Z posts aren't meant to exhaustively describe the topics. I'm only hoping to outline them and provide some follow-up reading links. And with F#, after a 45 minutes on one post, that's about all I'm up for today.

Construction complication in Dunning

No, not the Dunning of Kruger fame; Dunning, the community area on the far northwest side of Chicago.

Workers building a new school in the neighborhood discovered that not only was it the former site of a poor house, but also that 38,000 people may be buried there:

“There can be and there have been bodies found all over the place,” said Barry Fleig, a genealogist and cemetery researcher who began investigating the site in 1989. “It’s a spooky, scary place.”

Workers have until April 27 to excavate and clear the site, remediate the soil and relocate an existing sewer line. The school is scheduled to open in time for the 2019-20 academic year, though a spokesperson for Chicago Public Schools would not say what type of school it will be.

Fleig said he’s “nearly certain” there are no intact caskets buried underneath the proposed school grounds — bodies were primarily buried in two formal cemeteries, though scattered human remains have been discovered during previous construction projects near the campus.

In 1854, the county opened a poorhouse and farm and gradually added an insane asylum, infirmary and tuberculosis hospital to the property. At its peak, a thousand people were buried on the grounds each year.

The state took over in 1912 and changed the official name to Chicago State Hospital. Buildings were shuttered in 1970 and operations moved west of Oak Park Avenue to what is now Chicago-Read Mental Health Center. 

In 1854, the site would have been a few hours' ride from the city. So I'm glad to see that the American tradition of dumping the poor in places where they can't possible thrive was as strong then as now. I'm a little shocked that a pauper's cemetery acquired so many corpses in sixty years, though.

Not that this is news

In addition to crapping on the norms of office that have kept our Republic functioning for centuries, the Trump Administration has lowered the bar for standard written English in politics:

Amid all the chaos in the White House — including West Wing personnel drama, the Stormy Daniels scandal and Mueller’s Russia investigation — some wayward spellings and inaccurate honorifics might seem minor. But the constant small mistakes — which have dogged the Trump White House since the president’s official Inauguration Day poster boasted that “no challenge is to great” — have become, critics say, symbolic of the larger problems with Trump’s management style, in particular his lack of attention to detail and the carelessness with which he makes policy decisions.

On Monday, for example, the White House rolled out an executive order from Trump aimed at cutting off U.S. investment in Venezuela’s digital currency as a way to pinch strongman Nicolás Maduro’s regime. But in the headline on the public news release, the White House wrote that Trump was taking action to “address the situation in America.”

“Freudian slip????” wondered Rosiland Jordan, a reporter for Al Jazeera.

Liz Allen, who served as White House deputy communications director under President Barack Obama, said in an interview that the press office under the 44th president sought to be as rigorous as possible. Releases typically were proofread for accuracy and content by at least four or five people. Announcements that dealt with domestic policy issues and foreign affairs were vetted by experts at federal agencies and the National Security Council, she said.

“We felt a burden and responsibility to get it right,” Allen said. “We were acutely aware of the integrity of our platform. We took it seriously. No one should meet a higher bar than the White House. They are the ultimate voice.”

Read through to the punchline.

But Allen makes the main point, I think. The Administration's written communications reflect a deeper antipathy to "getting it right." They just don't care. And our allies and adversaries alike have noticed.