In today’s post: An obsession with primitive types can be a problem; Ways to refactor to introduce semantic types; WSL now supports GUI apps and it’s wonderful; Lessons from Japanese martial arts; How to prepare to break a habit; Spam blogs; Why your sleep excuses are wrong; Morning habits and happiness; and Phil Haack’s most excellent CodeMania 2012 keynote.

Sharpen the Saw used to be an email newsletter of information I published for the professional development of software developers. Now it’s a series of blog posts. While targeted primarily at developers working with the Microsoft technology stack, content covers a wider range of topics.

Technique

Always a way to improve the code you write every day.

Design Smell: Primitive Obsession

Consider the fundamental data types built into your language. Typically they are int, double, string, char, and bool, though the exact set depends on your language. Go includes complex, C# includes DateTime, C++ doesn’t include string, and so on.

Of course, they are extremely useful, but sometimes they’re the wrong solution, often because they admit too wide a range of values.

Over reliance on primitive data types is known as Primitive Obsession and it’s a subtle source of bugs. In this blog post, Mark Seemann gives some good definitions, as well as some useful links for further reading.

Read more: https://blog.ploeh.dk/2011/05/25/DesignSmellPrimitiveObsession/

Code Smell – Primitive Obsession and Refactoring Recipes

Over on the NDepend blog, Patrick Smacchia makes the case that while primitive types are the real building blocks of your application, over reliance on them can lead to problems.

Within the .NET base class library, a file path is often represented as a string, with a large number of helper methods to work with the path. It turns out that a proper encapsulation (such as that made available via the NDepend.Path NuGet package) is surprisingly complex.

My experience shows the introduction of a simple semantic type to replace use of a primitive type will almost invariably flush out some bugs in the application.

Read more: https://blog.ndepend.com/code-smell-primitive-obsession-and-refactoring-recipes/

Software & Updates

A new or upgraded tool can be a beautiful thing.

The Initial Preview of GUI app support is now available for the Windows Subsystem for Linux

This is exciting - you can now run Linux that require a GUI within WSL2 without having to install a separate X-Server and fight with Windows firewall settings.

Aside: I’ve had an X-Server installed on my work machine for some months, but every time I want to use it, I have had to go back and fight with the Windows Firewall settings because the required exclusions keep getting reset. With this release of WSL2, I don’t have that problem any more, everything just works.

So far I’ve used both GoLand and GitKraken under WSLg and they’ve worked flawlessly.

The only difficulty is that it’s only currently available on the Windows Insider Dev ring, so you have to opt in to a certain amount of instability to get access.

Read more: https://devblogs.microsoft.com/commandline/the-initial-preview-of-gui-app-support-is-now-available-for-the-windows-subsystem-for-linux-2/

Being Professional

A great developer does more than just write great code.

Shu-Ha-Ri

From Japanese martial arts, Martin Fowler teaches us about the ideas of Shu-Ha-Ri - describing how a person passes through three stages of gaining knowledge. This is both a good way to assess your own progress towards mastery of a subject, but also a good way to think about how to pass on what you now to others.

Read more: https://martinfowler.com/bliki/ShuHaRi.html

Four Questions to Ask Before You Try to Make or Break a Habit

Whether it’s New Year, your Birthday, Lent or some other date on the calendar that’s of significance to you, making resolutions as a way to improve your habits is common. Gretchen Rubin thinks the key to making resolutions that work is to understand what kind of person you are before you begin.

Read more: https://lifehacker.com/four-questions-to-ask-before-you-try-to-make-or-break-a-1785984612

Security

Staying safe online and writing secure systems are both harder than we think.

The Abercrombie and Fitch Brown Pants Fiasco, “Splogs,” and you

There are tools out there for creating spam blogs - or splogs. In this article from 2012, Scott Hanselman diggs into one such fake site and finds literally hundreds of clones, all leeching off the Abercrombie and Fitch branding.

Scott summarizes it well: “The internet is way, way, more screwed up than you ever thought.

The goal of the scammers is simple: to get your credit card details and steal from you (or, some variation of the above).

Staying safe on the web is even more of a challenge today than it was back in 2012.

Read more: https://www.hanselman.com/blog/technical-analysis-the-abercrombie-and-fitch-brown-pants-fiasco-splogs-and-you

Wildcard

Sometimes the answer is random.

3 Excuses You Make for Not Getting Enough Sleep (and Why They’re All Wrong)

It’s difficult to over estimate the value of a good nights sleep. If you’re like most people, you don’t get enough sleep - and you can point to a dozen reasons why that happens. In this article, the author argues that they’re actually in control of their three most common reasons.

Read more: https://medium.com/thrive-global/3-excuses-you-make-for-not-getting-enough-sleep-5306931b7091

5 Things You Should Do First Thing In The Morning To Be Happier All Day

How good is your mental health first thing in the morning? If you, like many people, would like a better start to your day, here are five suggestions:

  • Pick a wellness habit, then link it to an a.m. ritual you already have.
  • Get your phone out of your room.
  • Talk to yourself…
  • … and somebody else.
  • Incorporate gratitude.

Read more: https://www.huffpost.com/entry/morning-routine-happiness_l_6081c788e4b0e7cb020c99a4

Video

Take some time to feed your mind.

CodeMania Love To Code Keynote

Back in 2012 the keynote for the very first CodeMania conference was delivered by Phil Haack - and it’s purely wonderful.

Audience: Everyone Duration: 27m

Read more: http://haacked.com/archive/2012/08/27/codemania-love-to-code-keynote.aspx

Watch now: https://www.youtube.com/watch?v=HYnEhDOKoxA

Comments

blog comments powered by Disqus
Next Post
Fixing GitHub Authentication  28 Nov 2021
Prior Post
Gesticulation Driven Development (GDD)  24 Jul 2021
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
July 2021
2021