Ten years at SHI

I happened to notice my five year work anniversary post earlier this week, and thought I should write a ten year anniversary post. I hit my ten year anniversary about a week ago. I guess it’s kind of a big deal, since this is only the second job I’ve had that’s lasted this long. The previous one was NMS, where I worked for around 13 years (1996-2009). I probably would have hit 15 years there, if the company hadn’t got out of business.

A lot has changed at SHI since that five-year mark. A lot of those changes happened in 2022. I switched to a new boss, then back to the old boss. There have been a lot of management changes within IT in 2022. And I got promoted to “IT Solutions Manager,” whatever that means. I now have three direct reports, all CRM developers (which is kind of awkward, since I don’t really know our CRM system).

I’m doing less AX 2012 development, and am gradually moving into more Dynamics 365 development. We’re just in the planning stages of moving off of on-prem AX 2012 to Dynamics 365 F&O. And, since the CRM devs have been moved into our group and now report to me, I’m learning about our Dynamics 365 CRM environment. It’s all going pretty slowly, but we’re a big company and there’s a lot going on. (And yes, I know that F&O apparently isn’t called F&O anymore and CRM isn’t called CRM anymore. I can’t keep up with Microsoft’s crazy product naming shenanigans…)

I think there’s a good chance I’ll still be with SHI in five years. (Though I worry that saying that out loud will jinx it…) There have been a lot of layoffs at tech companies recently, but I don’t think SHI is planning any. And it seems like there’s a lot of opportunity there to do interesting work.

I’m realizing now that I’ll be 60 years old in five years, and 65 in ten years. I don’t know if there’s any point in thinking that far ahead, but it seems to me like there’s a real chance I could finish out my working years at SHI.

There’s a lot more I could say about my job right now, but there wouldn’t be much of a point to it. I’m relatively content where I am. There’s a lot of uncertainty, but there’s uncertainty everywhere. I think I have some good coworkers, and I think I’m in a pretty good situation.

New Year’s Day 2023

It’s 8 AM on New Year’s Day, and here I am again writing my traditional New Year’s Day post. I have a bit of a headache today, not because I was up late partying, but because I had trouble sleeping. I went to bed at 9:30 last night, and slept reasonably well until around 11, when nasal congestion and random noise from outside woke me up and pretty much ruined my sleep until around 4 AM, when everything quieted down and my nose cleared up, and I managed to get a couple of hours of sleep. I got out of bed at 7. I guess I have enough coffee in me now that I can get through the day, but I think I’ll need at least one nap today, and I’ll probably need to go to bed early again.

I’ll start this post out with links to some previous posts:

  • Last year, I blogged on Jan 2.
  • And here’s 2021, 2020, and 2019.
  • And probably my earliest New Year’s Day overview post, from 2008.

And I’ll break this post down into sections, since it might get a bit lengthy.

Health, Weight, and Sleep

I started seeing a new doctor this year, and she wasn’t interested in seeing me more than once this year, so I only had a single doctor’s visit in 2022, in May. My blood work was fine, and I guess my general health is fine.

I got two COVID booster shots this year, in April and September. The second one was the bivalent booster. As far as I know, I still haven’t gotten COVID. I might have gotten a mild case once or twice; I’ve certainly been sick a few times. But never bad enough to see a doctor. (And I usually test myself for COVID if I’m sick, and I’ve never had a positive test.)

I do feel like I got sick more often than I’d like last year. I’ve noticed that doing pretty much anything that involves being out in a crowd for a nontrivial amount of time results in me getting sick the next day. I’ve always been like that, to some extent, but I think it’s getting worse.

My sleep has been good and bad this past year. In the last couple of weeks, it’s been more bad than good. but for a few weeks prior to that, I’d been sleeping quite well. So I’m not sure what’s going on there. I think that a lot of it is sinus problems.

My weight has gone up a bit this year. I started 2022 at 140 pounds, and I’m now at 150. I’d intended on drawing the line at 140, but I’ve just crept up to 150, and I haven’t really cared enough to commit to getting it back down. I’m not sure if I need to, really, if I can actually draw the line at 150. I think that’s a reasonably healthy weight for me. My problem over the last year is that I’ve been eating a lot of cookies, to be honest.

I’ve done well with exercise this year, I think. I’ve been pretty consistent about getting a lot of walking done. In fact, it’s nice enough out that I should probably take a break from this blog post and go out for a walk right now.

Work

…and now I’m back from my walk and it’s a little after 9 AM. So my next section is going to be about work. I’m still working for SHI, and I’ll hit my ten-year mark this month. My longest time at one job was NMS, where I worked for around 13 years. So SHI is in second place, and may surpass NMS, if I manage to stick around for a few more years.

After being in pretty much the same position, with the same manager, for most of my time at SHI, there were a lot of changes in 2022. In April, there was a bit of a shake-up, and my group got moved under a different manager, in a different group. Then, in July, we had the data breach. And in August, there was another management shake-up, and I got moved back under my old manager. And in November, I was promoted to “IT Solutions Manager” and am now responsible for managing three programmers. Additionally, these programmers work on our CRM system, so I’m (gradually) moving from working primarily on AX to working on CRM.

And that’s a simplified timeline. There’s a lot more going on than what I described there. I guess it’s mostly good, and we’re on a good path for growth in 2023? I’m not really high-level enough to have a good picture of the company’s overall health, and whether or not we’re on the right path. I guess I’ll stick with “cautious optimism.” I’ve updated my resume, but I’m hopeful that I won’t need it in 2023.

In terms of professional development, it’s good that I’ve been promoted into management, I guess. I’m still basically a hands-on programmer, and my three reports are doing their own thing, for the most part. I may take more of an active hand in 2023, but that’ll depend on how things shake out.

Looking at the books I’ve read and courses I’ve taken in 2022, I put a fair bit of effort into learning scrum earlier in 2022. There was a big push for scrum that went along with the April management changes. That kind of fizzled out after the data breach and the August management changes, but we’re still (kinda) doing scrum. I also put some effort into working on programming fundamentals, reading a few books related to “Clean Code” and refactoring. And, for specific technologies, I’ve been trying to learn a bunch of random stuff that’s all directly related to projects I’m working on. I could get into all that, but then this post would get way too long.

The New Normal

…for lack of a better title. COVID is still a thing, regardless of whether or not people want it to be. SHI has us working in the office two days a week now. For me, that’s Tuesday and Thursday. It’s not too bad, I guess. I wear a mask when I’m not at my desk. There aren’t too many other people who still do, but there are a few.

They might let us keep to the two day schedule through 2023, but they also might try to get us to come back full-time, or maybe four days a week. I’m not sure. I’m really hoping they stick with the two day per week plan. I’m not ready to go back to the office full-time.

I don’t go out nearly as often as I used to. My only trip to NYC this year was in March, when I took the train to Albany for a funeral. (I switched from NJ Transit to Amtrak in NYC, so it was just a brief visit.) And that trip was really my only trip out of NJ. I almost had my E-ZPass canceled this year, because I haven’t used it since 2019. I got them to keep it active for another year, but I should probably give it up. Similarly, I should probably give up on my memberships to the Met and MoMA. I haven’t used either this year.

I had bought a badge for NYCC in October, but I decided to skip it and got a refund. I’m pretty sure that was a good idea, and that I would have gotten horribly sick if I’d gone. I may be done with comic conventions entirely now. I’m really not sure.

Books, Movies, TV, Music, Etc.

So this is the fun part of the post. (Maybe.) I’ll start with a link to my Goodreads Year In Books for 2022. I read 76 books this year. A lot of them weren’t really books, per se. I started the year with a bunch of Big Finish Doctor Who audio dramas, for instance. Looking at the list, I think I read around 20 actual novels in 2022.

I gave up on trying to read any classics in 2022. Instead, I put some effort into putting a dent in my backlog of random Kindle books, reading stuff that I got from old Humble bundles and stuff like that. There was some good stuff in there, but also some stuff that was OK but forgettable. I also got back into a couple of my favorite book series, The Dresden Files and The Laundry Files. I’d last read a Dresden book in 2015, and a Laundry book in 2017. I didn’t read a lot of comics in 2022. Probably my favorites were the two Hilda books I read.

For movies: I still haven’t been back to a theater, since 2019. So I only watched movies at home. From my Letterboxd stats page, I can see that I watched 84 films in 2022. That’s less than 2021, when I watched more than 100 films. My highest-rated films from 2022 were My Father’s Dragon, Turning Red, and Doctor Strange in the Multiverse of Madness. My highest-rated re-watches were Howl’s Moving Castle and Who Framed Roger Rabbit, both of which I bought on Blu-ray in 2022.

For music: I mostly listened to music via Apple Music this year, so (in theory) my Apple Music Replay ’22 page should be pretty accurate. In practice, it’s a little weird. My top track for the year is the first track on Max Richter’s Sleep, which is probably because I put it on sometimes when I’m taking a nap on my sofa. My second most-listened track is Heavy Heart, by Bartees Strange, which makes sense, I guess. I do like that song.

Beyond that, I’ve listened to a lot of Bombay Bicycle Club, Bibio, and a few others. If I was going to pick my favorite album from 2022, it would probably be Bibio’s BIB10. Replay doesn’t tell you how many albums you’ve added to your library during the year, but I keep a list of those in Evernote, and I see I added over 50 albums in 2022. So I’m definitely listening to a lot of new stuff. (And old stuff too.) I guess I’m getting my money’s worth out of Apple Music.

For TV: I don’t keep track of the stuff I watch on TV the way I do with books and movies. I’ve definitely watched a lot of TV in 2022, but I can’t think of anything in particular that stands out. I’m still subscribing to Netflix, Disney+, and Paramount+. I switched to the Disney Bundle in 2022, so I get Hulu and ESPN+ too now. I’m not particularly proud of the amount of TV I watch these days, but there are times when I’m just too tired to do much else.

Summary

I feel like there’s more I wanted to write about here, but it’s almost 11 AM now, and I’m running out of steam. I should wrap this up, and maybe go out for another walk. I’m not making any resolutions for 2023. I’m planning on just playing it by ear. If I can manage to lose a few pounds, that’d be nice. If I can move forward on some professional stuff, that’d be good too.

a little PowerShell

It’s been a while since I’ve posted any PowerShell code. I had to write a quick script today to run some SQL, save the output to CSV, then ZIP the CSV file. And I had to loop through and the run SQL multiple times, one for each month from January 2021 until today.

That forced me to look up some stuff that I didn’t know how to do in PowerShell, off the top of my head. (In fact, most of it was stuff I didn’t know off the top of my head. I don’t use PowerShell enough to remember anything…) So here’s an edited version of the script, simplified somewhat. It might come in handy some time, if I ever need to do this again.

# CustInvAll-export.ps1

#Requires -Version 7
#Requires -Modules SqlServer

$dateFmt = 'yyyy-MM-dd'
$sqlServer = "MyServer"
$dbName = "myDB"

$curDate = [DateTime]::Today
$startDate = [DateTime]'01/01/2021'
while ($startDate -lt $curDate) {
    $endDate = $startDate.AddMonths(1)
    $startDateFmt = $startDate.ToString($dateFmt) 
    $endDateFmt = $endDate.ToString($dateFmt)
    
    $exportSQL = @"
    SELECT *
    FROM MyTable
    where [INVOICEDATE] >= '$startDateFmt' and [INVOICEDATE] < '$endDateFmt'
"@
    $exportFile = "CustInvAll-$startDateFmt.csv"
    $exportFileZip = "CustInvAll-$startDateFmt-csv.zip"

    echo "Exporting from $startDateFmt to $EndDateFmt to file $exportFile"

    # Invoke-Sqlcmd -ServerInstance $sqlServer -Database $dbName -Query $exportSQL `
    # | Export-CSV -Path $exportFile -NoTypeInformation  -UseQuotes AsNeeded

    # Compress-Archive -LiteralPath $exportFile -DestinationPath $exportFileZip

    $startDate = $endDate
} 

It can also be found in a Gist.

Programming Potpurri

I’ve been meaning to write a blog post or three about some of the programming-related stuff that I’ve been doing at work recently. But I keep putting it off. I’ve got some energy today, and a little spare time, so I’m going to try to write up some random notes.

Razor Pages

A while back, we had an old SharePoint 2013 page stop working. The page uses a control that I wrote in C#. The control really has nothing to do with SharePoint; it’s basically an old-fashioned ASP.NET web form that makes some web service calls, populates some controls, gathers user input, then makes another web service call, then redirects the user to another page. The only reason it’s in SharePoint is… well, that’s complicated. Let’s not get into that!

Anyway, fixing the page would take about five minutes. I’m pretty sure all I needed to do was increase a timeout, and increase the max receive size on a certain web service call. But… my SharePoint development VM got nuked in our security incident back in July. So the actual time to fix the error would be more like several days, since, at this point, I have no clue how to build a SharePoint 2013 development machine from scratch. I’m pretty sure I could do it, but it would take a lot of time and effort.

So I decided to just rebuild the page as a single-page ASP.NET Razor Page project, which seemed like it would be a fun thing to do, and might be a good model for moving some other stuff out of SharePoint. At the time, I wasn’t too busy. Of course, that changed, and now I kind of regret diving into this. But I did, and managed to learn enough about Razor to get the page done and into production.

I’d known a bit about Razor already, and had messed around with it on and off over the last few years. But most of my recent ASP.NET work has been web services, so there’s no need for Razor there. First, I was surprised to realize that Razor has been around since 2010. Scott Guthrie’s blog post announcing it is from July 3, 2010. I’ve still been thinking about it as “new,” but I guess it’s not. Heck, I guess it could even be considered “legacy” by some folks. (I guess maybe Blazor is what the cool kids are using now?)

Since it’s been around awhile, there are some reasonably good resources out there for learning it. But, also since it’s been around awhile, a lot of it is scattershot, or out of date, or not really relevant to what I was doing. The best resource I found is the Learn Razor Pages site. I almost bought the related book, ASP.NET Core Razor Pages in Action, but before I got around to it, I was pretty much done with the project, and had to move on to other stuff.

Dynamics 365

So, with the changes that are going on at work, it looks like I’ll have to be doing a lot more work with Dynamics 365. D365 is a pretty big topic. It looks like I’ll probably be mostly concerned with Dynamics 365 Sales (formerly known as CRM). I took a three-day class on Power Platform back in 2020, which is kind of the underlying technology for D365. Power Apps and Dataverse in particular are important. (The terminology on this stuff is really annoying. When I took that class two years ago, Dataverse was called “Common Data Service” and some of the other related terminology was different. It’s hard to keep up…)

I now have Pluralsight and LinkedIn Learning access via work, so I watched some videos on those sites, and on Microsoft’s Learn site, to refresh my memory from previous efforts to learn this stuff, and pick up on the new stuff. I guess I’m now almost at the point where I could be useful…

VSTO and EWS

Related to all that, I’ve been assigned to work on an Outlook plugin that ties into D365, and a console app that does some back-end processing related to the plug-in. So now I also need to learn VSTO, which is how the add-in was built, and EWS, which is used in the console app.

VSTO is a bit out of date, but not yet deprecated. If I was going to do a major rewrite on the plug-in, I’d probably switch to Office Add-Ins, which is a bit more modern, I guess.

And EWS is also out of date but not yet deprecated. If I wanted, I could probably move from that to the Graph API.

The main thing I need to do with these projects is to get them to work with Exchange Online. (We’re in the middle of migrating from on-prem right now.) I think I won’t actually have to change the plug-in at all, since it’s working with the Outlook object model, and I don’t think that cares if the email came from Exchange Online or on-prem. There might be a “gotcha” or two in there, though, so I need to at least test it.

For the console app, EWS still works with Exchange Online, but I know I’ll have to change a few things there, including switching over to OAuth for authentication.

And both apps seem to need some cleanup in terms of logging and error-checking. I know that if I make changes to these apps, then people are going to start coming to me with support questions, so I’ll need to make sure I have enough logging to provide support.

There’s actually been a lot of overhead involved in getting up and running on this project. These programs were originally under a different dev group, part of which has gotten moved into my group, so they’re using some conventions and utilities and stuff that I don’t know, and need to learn (and in some cases, gain access to). And I don’t have Outlook on my dev VM, since that’s not normally allowed (for security reasons). And I can’t get to the Exchange Online version of EWS, since that’s blocked (for security reasons). And I need to set up a new app registration, so I can access EWS with OAuth, and that needs to be approved by a global admin. And so on.

Was there a point to this?

If there’s a point to all this, I guess it’s just that I need to keep learning new things and being flexible. I saw a funny comic strip recently about an old man whose doctor tells him that he can help keep his memory sharp by learning new skills. And the old man says that his memory isn’t good enough for him to learn new skills. And of course I can’t remember where I saw that strip now, so I can’t link to it here. It was probably on GoComics, which I recently re-subscribed to, after canceling my subscription almost a decade ago. I’ve decided that reading the comic strips every morning is healthier than browsing Facebook and Twitter, so that’s why I re-subscribed. (I may also sign up for Comics Kingdom too, but that’s a subject for a different blog post.) Anyway, since I can’t find the strip I was looking for, here’s a different one, along similar lines.

A Busy Day

As previously mentioned, I got my COVID booster shot today. I also picked up my new iPhone 14 from CVS, though I had to make a separate trip for that, since it hadn’t arrived yet when I went for the booster. I guess the phone had gone back to the depot on Friday, then sat there all weekend, then got put on a truck this morning for delivery to CVS. Sigh. Well, I’ve got it now, so all is well.

This booster is my fifth shot, overall. The last shot was in April. I’m hoping I don’t get any side-effects from this one, since I’ve got a pretty busy week at work, and I don’t want to have to take a sick day. (But I will if I need to.)

The iPhone setup was relatively easy. I think the only major thing I still need to do is the MS Authenticator setup, which I’ve previously complained about. I’ll try to do that in the office tomorrow, where I’ll have access to my work desktop PC and my office phone, just in case any of my accounts still have the office phone number as a backup. I’m anticipating that’ll take about an hour.

Meanwhile, I had also ordered a new router this weekend, and that showed up today. I ordered this one, from Amazon. It was $80. I didn’t do a ton of research, bit it seems to be a successor to one that had been recommended by Wirecutter. I also found a good CNET review of it. I don’t have much to say about it yet, since it’s still in the box, and will likely remain there until this weekend.

I bought my current router in 2017, so it was time for a new one. The old one still works, but it doesn’t support some of the more modern features and standards. Honestly, I haven’t kept up with all that stuff, so I couldn’t even tell you which ones are which, at this point, but I know I was time for a new router. So I’ll try to get that set up over the weekend, probably, and I’ll have more to say about it then.

On another subject, there are a lot of changes going on at my job right now, and it looks like one of them may snowball into a pretty big change for me. (Or not. Hard to tell.) Either way, I think I need to learn a lot more about Dynamics 365 and Power Platform and stuff like that. I’ve made some efforts at learning that stuff in the past, but I never wind up actually working on anything real with it, so the knowledge doesn’t stick. And of course everything changes, so the stuff I picked up two or three years ago is different now anyway.

A lot of the changes we made in April are getting, well, changed. I wouldn’t say “rolled back,” but I am back under the boss I had before the big changes in April. But she’s under a different boss. And we seem to be backing off on our enthusiasm for scrum a bit. And, as mentioned above, I guess I’m going to need to learn more about the Dynamics 365 side of things. Which is good, I guess, but right now, my head is spinning.

Visual Studio extensions and alternatives

Another (relatively) quick post for today: It just occurred to me that, since my work VM has been restored from an older backup, the changes I made to Visual Studio a week ago are all gone. And that’s fine. I wasn’t entirely convinced that CodeRush was something I wanted to stick with anyway.

Since my VM is a little messed up now, I’ve been thrashing around a bit the last few days trying alternate ways to test some stuff out. I have some PowerShell scripts that I usually run on my VM, and I thought it would be fairly easy to copy them over to my laptop or desktop and run them there. But the specific set of modules I need is apparently a little complicated, and I haven’t been able to exactly recreate my environment. I’m sure I could, given time, but oh well.

Then I came up with the idea of installing LINQPad on my desktop and running some stuff there. That wasn’t terribly hard to do, but I’m referencing some DLLs in those that aren’t on my desktop, and, again, recreating the specific environment I needed got a bit too complicated and I gave up. That did get me thinking about upgrading my Pro license to a Developer license, so I’d have nuget support. I might still do that, but not right away.

And, finally, I have been looking at JetBrains Rider a bit lately. I noticed last week that their prices have gone up. Rider is still pretty affordable though. The old price was $139 for the first year (for personal use); the new price is $149. As a subscription product, that’s still enough that it’s not an impulse buy for me. I’d have to know that I was actually going to use it consistently, outside work. But lately I’m not doing enough programming outside work to justify it.

troubleshooting MSAL

This is just a quick one: in the aftermath of last weekend’s thing at work, they’re now blocking all outbound web traffic from my development VM. Which is kind of a problem when you’re trying to test out some web services on some restored servers, and you need to authenticate with MSAL. While trying to figure out exactly which addresses I needed to have whitelisted, I stumbled across an article on logging errors in MSAL.NET. This is a good example of something I needed, but didn’t know I needed until I stumbled across it, while looking for something else!

For now, I’ve just implemented this in my test program with the simple logging code included in the code sample, but, when things settle down, I might try to add MSAL logging into one or more of my programs as an option that I can turn on or off in the config, and log through Serilog (my current favorite logging library).

The end of a weird week

As I alluded to on Tuesday, we had a security incident at work over the July Fourth weekend, so we’ve been spending all week cleaning up after that. There’s a statement about it on my company’s blog. I won’t link to it here, since I don’t necessarily want this post to show up in searches or referral logs related to it. (I’m not going to post anything I shouldn’t be posting, and I don’t know enough about the details to say much anyway, but just in case…)

On Tuesday, we were told to just stay home and chill, basically. They didn’t give us any real info on what happened, so that was basically just a “snow day,” as I mentioned in my last post. On Wednesday, they had made enough progress with the initial mitigation that we could start working on our disaster recovery. So, since then, it’s been a lot of “hurry up and wait” work, where servers are getting restored or rebuilt, scanned, released, and then we can do final setup and testing. I’ve been in the office Wednesday and Thursday, but I’m hoping I can get away with working from home today.

There are a lot of people working very hard on this. For me, I’m primarily a programmer, with only limited admin responsibilities. There are only two servers that I’m “officially” responsible for (out of hundreds total across the company), so mostly I’m just waiting on other stuff, answering questions, and helping out where I can. I feel a little guilty, knowing that some people are sleeping in their offices while I’m going home and sleeping in my own bed, but of course there’s not much I can do to help those folks, other than to stay out of their way.

I had a bunch of other stuff to say about this, but I think I’ll just say that I think we’re doing a pretty good job of handling this thing. Everyone has been calm and professional through it all, at least from my limited vantage point. There’s still a lot of work to do, but we’re making steady progress.

Purely by coincidence, I read an article in Communications of the ACM last week that talked about the best way to handle outages in IT. The article is more about unintentional errors that cause outages, rather than security incidents, but there’s a lot in common. I like the idea that “DevOps celebrates mistakes.” I hope that, when we’re back up & running, we’ll get a good postmortem on this that we can learn from.

Visual Studio extensions and tweaks

I’ve been spending some time at work recently messing around with my Visual Studio setup. I’ve been fine with my current setup for awhile, but I started getting restless recently. I guess it started when I started reading Clean Code, and watching the associated videos. That got me thinking about automated refactorings, which got me looking at JetBrains Rider and Resharper. And looking at Resharper reminded me of the existence of CodeRush.

I’ve occasionally thought about trying out something like Resharper or CodeRush, but I never got around to it. There are a number of reasons for that, mostly around the cost and the possible performance penalty. But I noticed recently that CodeRush is now available for free, so I figured I’d give it a shot. (And I think Roslyn made it easier for extensions like CodeRush to work without a big performance penalty.)

My normal VS setup, which I’ve stuck with for a while now, is pretty basic, with Mads Kristensen’s Web Essentials, and DPack Rx. I use DPack primarily for the numbered bookmarks, and Web Essentials for a number of random things. CodeRush includes numbered bookmarks, so I thought I’d try removing DPack, installing CodeRush, and seeing how that worked out. So far, I’ve found that CodeRush’s numbered bookmarks don’t work quite as well as DPack’s. There are a number of other interesting features in CodeRush, but I’m not sure if any of them are compelling enough for me to keep CodeRush installed.

I also briefly considered uninstalling Web Essentials, and then just reinstalling the specific extensions from that collection that I’m actually using. But I couldn’t quite talk myself into that, so I’ve still got the whole collection installed.

On a related subject, I recently listened to an episode of .NET Rocks with Mads Kristensen on VS 2022 extensions. And another one with Mark Miller (author of CodeRush). I’m not currently subscribed to .NET Rocks in my podcast client, but I do check in on it occasionally to see if there’s anything interesting.

Getting back to the general subject of VS extensions and setup, I also revisited my work setup and tried to decide if I could switch from VS 2019 to VS 2022. I do my VS development at work on a VM that’s running Windows Server 2012 R2. That probably seems weird, but it’s necessary for Dynamics AX development. And VS 2022 isn’t supported on Server 2012, though I could probably get it to work. So I’ve been going back and forth on whether or not I should try to install it on my current VM, or maybe ask my boss for a new Windows 10 VM to use for VS 2022. I’ve decided to stick with VS 2019 for now, but I may need to ask for a new VM at some point. In part because I have a .NET 5 project in VS 2019, and .NET 5 is no longer supported. And .NET 6 isn’t supported in VS 2019. So it’s all kind of complicated. Asking for a new VM shouldn’t be a big deal, but I’m a little nervous about it, since I just got a new boss, and I’m now in a different sub-division of the IT department, and the rules about this stuff might be a little different than they were under the old boss, so I want to feel things out a bit before I start asking for stuff.

I did install VS 2022 on my personal laptop back in May. I do like it, and would love to be able to switch over to it. (Unlike some previous versions of VS, they don’t seem to have made any really bad UI decisions that make me want to stick with the older version…)

I also spent a little time messing with the default font in VS on Friday. I’ve stuck with Consolas for quite some time now. But  I was watching a LinkedIn Learning video on Friday where the teacher’s setup was using Cascadia Code, and it looked kind of nice. I’d read about Cascadia Code when it came out, but I never got around to trying it. So I switched over to it for a little while, but then decided to switch back to Consolas. The whole code ligature thing is interesting, but Consolas just seems to work better for me.

All of this fiddling around made me think about the balance between sharpening the saw and… pointless procrastination. (It’s bothering me that I know that there’s a clever metaphor similar to “sharpening the saw” that basically means “pointless procrastination”, but I can’t remember what it is.)

Well, I’ve now killed a bunch of time on a hot Saturday morning, drinking iced coffee, waiting on my grocery delivery, and writing a rambling blog post. My plan for the rest of the day revolves mostly around watching the last two episodes of Stranger Things on Netflix. Life is good, I guess.

Lazy initialization

My experience working my way through the Clean Code book and videos has gotten me interested in refactoring some of my old code. I have a large API project that I maintain at work, and it’s gotten a little out of hand over the last few years. In particular, there’s one class that got so large that I broke it up into multiple partial class files some time ago. Overall, it would have been around 5000 lines of code if I hadn’t broken it up. Of course, partial class files don’t really change anything; it’s still one big class, technically.

So I started looking for ways to break it down into actual separate classes. What I wound up doing was to leave stuff that was needed across all the code in the old class, then moving all the specific stuff from the partial classes into new “child” classes. I created a new base class for these child classes, then added code to the original (now “parent”) class to contain all of the children as singletons, instantiated as needed.

The code to do that looked a lot like the code in this Stack Overflow question. That was fine, but once I got all that done and working, I started looking around for ways to streamline or simplify the declarations. I tried out a few things, and decided on using the Lazy<T> class. I’m sure I must have stumbled across it before, but I’d forgotten about it and had never actually used it. It took me a little while to figure out exactly how I should use it, in my particular use case. I don’t have anything super-interesting to say about that, but I thought I’d just post a few links that I found helpful:

Overall, I think the code is a little better for having been refactored this way, though I’m still not quite satisfied that I’ve cleaned things up as much as I should.