Your browser may have trouble rendering this page. See supported browsers for more information.

Contents

273 Articles
13 Comments

Search

1 year Ago

Stop trying so hard to use pattern-matching

Published by marco on

In the article Why tuples in C# are not always a code smell by Dennis Frühauff (dateo. Coding Blog), the author writes the following code for calculating a discount.

The requirements are as follows:

  • Premium customers get 20% off.
  • Gold customers get 30% off.
  • Regular customers, when they are students (< 25 years), get 10% off.
  • Regular adult customers get no discount.
  • All regular customers get 15% off during happy hour (3 to 8 p.m.).

The author’s original version

public decimal CalculateDiscount(Customer customer, DateTime time)
{
 ... [More]

You should be using a GUI for Git

Published by marco on

 I’ve seen this Noob question: Does anyone use things like git gui? by Collekt (Reddit) again and again.

“Just curious as I’m learning and getting familiar with git. Do real production teams use any kind of tools for git like “git gui” or others? Or does everyone just use it from command line? Thanks for any insight. :)”

You almost certainly have several use cases for your source control:

  • clone/push/pull
  • commit
  • amend/squash/rebase interactive
  • merge
  • diff
  • code forensics (log/blame, cross-reference, find changes)... [More]

Terminology for CSS values

Published by marco on

 The article ”Thousand” Values of CSS by Karl Dubost (Otsukare) clarifies the definitions for the various types of value in CSS. While there aren’t a thousand different kinds of value in CSS, there are quite a few. Each has its raison d’ĂȘtre.

The article is informative, but lists the values in what I consider to be an unintuitive order. I’ve changed the order and consolidated a bit. Each term links to the W3C documentation[1] and each definition starts with the official description, a layman’s translation, and a simple... [More]

How to evaluate dependencies

Published by marco on

As software developers, we are constantly making the decision between make or buy.

Deciding to make something carries with it the obligation to design, develop, test, document, and support it. You’ll have everything under your control, but you’ll also have to do everything yourself.

If a component is not part of your project’s core functionality, then it’s often a good idea to look around and see if you can find someone who’s already built that functionality. Optimally, the component you find... [More]

C# 11 Features

Published by marco on

The articles Twelve C# 11 Features by Oleg Kyrylchuk and Welcome to C# 11 by Mads Torgersen (Microsoft .NET Blog) provide an excellent overview with examples of new features in C# 11, available with .NET 7.0.

I include my own notes below.

Interesting and obviously useful

“Obvious” to me, at least. The terms link to examples in one of the articles linked above.

Native UTF-8 Strings
You can now append u8 to the end of a literal string to make it UTF-8 instead of the system-standard UTF-16. For example, “Test string”u8 will be encoded by the... [More]

2 years Ago

Waterfall vs. Agile vs. “Wagile”

Published by marco on

The article Agile Projects Have Become Waterfall Projects With Sprints by Ben Hosking (ITNext) argues that a lot of projects using agile aren’t agile at all, but are “more like waterfall projects with upfront requirements, fixed deadlines, sprints and 2 weekly demos.”

Overall, I understand where the author is coming from, but I found the tone pretty overwhelmingly negative. I can only imagine what the author has seen to have put them in such a dark place. 😐

I thought that this was an interesting comment in the... [More]

Applying the rule of least power in practice

Published by marco on

Some asked is there a js library that animates the text word by word like shown? by DemDavors (Reddit).

A bunch of people answered “just do it with CSS!” and one or two recommend using GSAP (Green Sock Animation Platform). I’d just heard about that library in the following instructive video and had had a chance to investigate how it works.

FLIP animations | HTTP 203 by Google Chrome Developers

I’d like to expand on the comments recommending to use the “rule of least power”. They are absolutely correct, but you have to consider the entire task:

  • Learning how to use... [More]

New feature for C#: Anchored types

Published by marco on

I recently answered the question What features from other languages would you like to see in C#? by BatteriVolttas (Reddit)

I think Anchored Declarations and Qualified Anchored Declarations from Eiffel would be very useful.

I like the name “anchored” because you’re anchoring the type of one thing to another. Instead of using int throughout a class, you can just make e.g. a field named _id be an int and then make all other types (e.g. for the parameter passed to a method) refer to the anchor with like _id or typeof _id.... [More]

Quick CSS: text-decoration

Published by marco on

The article When to Avoid the text-decoration Shorthand Property by Šime Vidas (CSS Tricks) makes a couple of interesting points. Basically, you have a lot of control over how underlines are drawn on text.

The “Hustle” culture in Software Development

Published by marco on

Have you noticed that there is more and more content available to help you learn how to program? For every topic under the sun, there seems to be a blog article or video of superficially reasonable quality. For every question on StackOverflow, there’s an effusive answer with examples.

This is all pretty great, honestly.

However, with the increase in content. there is also the need to be able to wade through it.

How old is that StackOverflow answer? How appropriate is the answer to your... [More]

CSS Speedrun

Published by marco on

If you want to test or hone your CSS skills, check out the CSS Speedrun. It lets you warm up with a relatively easy “intro”, then takes you through ten levels. Generally, each level tests a different feature of CSS (usually a specific selector). The final question (pictured) makes you combine what you’ve learned or used from other levels.

The image below is from my second time through. The first time through I needed about nine minutes; the next morning, I got through much more quickly. I... [More]

TIL: nth-of-type() and na+b in CSS

Published by marco on

I’ve known about nth-child(n) for a long time. It selects the nth child from a structure if that child happens to match the given tag. You can always select the nth child by omitting the tag.

For example, div :nth-child(2) (two selectors) will match the second child of any div, regardless of type. However, div span:nth-child(2) will only match if the second child is also a span.

You cannot write a selector that says “select the second span” using nth-child. That’s where nth-of-type(n) comes... [More]

Accessibility is important

Published by marco on

 I recently read through the a11y myths. They’re quite interesting and should be required reading for managers running projects that develop web sites.

From it, I learned about the evils of overlays (see the Overlay Fact Sheet) and that there are really good resources out there, like Understanding Conformance (W3C) with WCAG 2.0 (Web Content Accessibility Guidelines).

“All WCAG 2.0 Success Criteria are written as testable criteria for objectively determining if content satisfies them. Testing the... [More]”

TIL CSS border-radius lets you define ellipses

Published by marco on

I hadn’t ever really thought about it because I don’t use the API very much, but it turns out that the border-radius property is not only a shorthand for setting all four corners at once, but also sets the horizontal and vertical lengths simultaneously. To set them individually, use a / between two values.

The corner radii are then calculated using ellipses as shown in the following visualization,

 Border-Radius with ellipses

The article CSS Border-Radius Can Do That? by Nils Binder on October 9, 2018 (9 elements) has many more examples. It also introduces a Fancy-Border-Radius... [More]

Real Hacks are not easy

Published by marco on

Most of us know “hackers” from the media—either the news media, television shows like Mr. Robot, or movies like Swordfish. But the fast and easy way of hacking presented in the media actually does a disservice to how incredibly clever these hacks really are.

Less-complex techniques—like guessing or brute-forcing passwords—still work super-well. And you’ve always got social engineering hacks, like just asking someone for their credentials in an official-sounding way. But real, technical... [More]

State of CSS 2021

Published by marco on

I just finished reading through the State of CSS 2021. It’s a well-presented[1] summary of a developer survey about CSS.

I liked the following sections:

Features
the sub-sections have a pretty fine-grained listing of CSS features, usage, caniuse and MDN links, if you’re interested in finding out what you might be missing
or want to be smug about all of the CSS features you know about and use.
Technologies
The rankings in the sub-sections are broken down by “Satisfaction”, “Interest”, “Usage”,... [More]

CSS sub-grids (and grids) with Kevin Powell

Published by marco on

I’ve been using CSS Grids for a while now. I’ve found many instances where I had used flexbox, where grids turn out to be much more appropriate. That is, the grid layout algorithm lets me specify what I want without fiddling about with flex-base and flex-grow, etc. Flexbox definitely has its place, but I think we all ended up abusing it a bit in our rush to leave tables-for-layout behind.

But that’s all in the past because now we have CSS grids available everywhere and all is well with the... [More]

Why can’t identifiers start with a number?

Published by marco on

The video I’m not sure how much longer I can wait! by Kevin Powell is an excellent introduction to sub-grids in CSS. But I was more interested in the fact that he told his viewers that,

“you can use numbers in classes, but if you have a class or id that starts with a number, it’s invalid. [
] It’s one of those weird things in CSS that sometimes trips people up.”

I immediately thought to myself, “it’s not weird. Every programming language is like that.”

Then, I thought, “I bet this guy only knows CSS, so he... [More]

3 years Ago

C# 10 Features

Published by marco on

The article Introducing C# 10 by Ken Bonny discloses some incremental but very welcome changes to the C# language in the iteration that will be released with .NET 6 in November.

In no particular order:

  • field in property accesses to manipulate the backing property without having to define it. This is a welcome improvement that will clean up useless boilerplate for properties that need to do something with the value before storing it (e.g. field.Trim())
  • The required keyword for properties in any of the... [More]

Handling Dependencies in Functional Languages

Published by marco on

Out of curiosity, I looked up how dependency injection works in functional languages. I stumbled upon this amazing article series—Six approaches to dependency injection by Scott Wlaschin (F# for Fun and Profit)
—that presents five different techniques—from very simple and easily applicable to more complex, but potentially robust.

The article series applies various abstraction techniques to a program that reads input, processes it, and writes it out again. The reading and writing are impure operations and should be abstracted... [More]

CSS and HTML Toolbox 2021

Published by marco on

Over the last four months, I’ve been collecting interesting HTML/CSS techniques and ideas.

  1. I’m planning a bit of a make-over of the earthli style and stylesheets to replace some older cruft with more modern, simpler implementations.
  2. I’m planning a new curriculum for the JavaScript class I’ll be teaching again this coming winter.

For both of these goals, I’m focusing on leveraging as much of the power of the browser—especially CSS/HTML—as possible without getting mired in too much... [More]

Configuring and using Jetbrains Rider ...021.1.1 and Visual Studio 2019 16.9.4

Published by marco on

Visual Studio with ReSharper has been my main development tool for many, many years. I first started using it in 2008 or 2009.

Over the last several years, I’ve used many other IDEs, like Visual Studio Code for documentation, advanced search, and JavaScript/TypeScript or PHPStorm for PHP, Android Studio for Java/Android, XCode for Swift/iOS, or WebStorm for TypeScript/JavaScript.

JetBrains Rider came on the scene several years ago and was not, at first, a viable alternative, but it has gotten... [More]

Set a Git Tag on Azure

Published by marco on

As with installing a dotnet tool on Azure, there isn’t a standard task for setting a Git tag from a pipeline YAML configuration. The Pipeline UI has an option to easily do this, but that hasn’t translated to a task yet, nor does it look like it’s likely to, according to online discussions.

Setting a Git tag is relatively straightforward, but is complicated by permissions (as with installing a dotnet tool. To tag a build, you have to just execute the git commands in a script.

  − task:... [More]

Installing a dotnet tool on Azure

Published by marco on

I have a .NET solution (Quino) that contains a project that I publish as a `dotnet` tool. The tool calculates a version number based on the branch and version number found in the solution. I use it from Quino itself and also from other project pipelines.

In order to use it from any pipeline (including Quino itself), I need to install it from the Quino artifact feed. The original solution is a couple of years old: I’d had a secure file for NuGet.Config that included the PAT. This works fine,... [More]

A nice CSS demo that uses 350% CPU

Published by marco on

The article Getting the Mouse Position using CSS by Bramus talks about a neat trick that uses sibling elements to react to mouse events without using JavaScript. It also features some kick-ass translucency and animation effects with CSS transitions.

As you move the cursor around, the layer of “cells” change X and Y positions that the CSS text elements “watch”. This lets the central elements “follow” the mouse, transforming a stack of “CSS” texts in a nicely composed and layered stack. It looks like... [More]

TIHI: SmartGit’s new “Discard to Stash” Feature

Published by marco on

This a quick note for anyone else who’s downloaded the latest version of SmartGit (20.2.3 #16150) and is seeing mysterious stashes that they know they haven’t created.

There’s a new feature called “discard to stash” that is enabled by default.

 Discard to Stash selected by default

What this does is to stash every time you press ⌘ + Z to discard changes. I understand that this is a failsafe “just in case”, but I kept ended up with a dozen stashes I had no use for. On balance, I’d rather have the tiny risk of wanting changes... [More]

A breakdown of programming languages used in a week

Published by marco on

In one recent week, I realized I’d been working in many different areas and on many different projects, so I took an inventory.

For one project, I reconfigured a program with Delphi Pascal, using Delphi 7 (it’s a very old, legacy solution) to run on my local machine instead of in a VM that had swollen to 120GB. For that project, I also used SQL on SQL Server, running in a Docker container that I’d configured with YAML. The solution has several products, among which you can switch, so I wrote a ... [More]

Software without Process

Published by marco on

 A software product with undocumented or poorly documented commits and a patchy issue-tracker is akin to a shipping pallet with 100 boxes haphazardly stacked on it, all wrapped up in shipping cellophane. You can see some of the labels and some of them you can’t and some of the boxes definitely don’t even have labels at all.

 If it looks like the pallet to the right, then you already know you can’t ship it. That’s an obvious train-wreck of a project that’s going to blow up in everyone’s face. But... [More]

Set up PHP With Docker, PHPStorm, and XDebug

Published by marco on

Until now, PHP debugging involved a fragile balance between the IDE, the server, and the debugger, each with overly verbose configuration. On top of that, using Docker introduced the wrinkle that you were technically debugging on a remote server rather than on the “real” localhost.

It’s been a long journey, but it’s finally a lot easier to set up PHP debugging with a server running in a Docker container. Once you use the most modern tools, everything works with a couple of lines of... [More]

4 years Ago

A dynamically generated Groovy foot-gun

Published by marco on

Groovy is a dynamically typed programming language that executes on the Java Runtime. It mixes its own highly dynamic syntax with islands of Java code. The Android ecosystem and its IDE use Gradle for its build scripts. Gradle uses the Groovy programming language.

The Problem Code

A large project I’m working on contains quite a bit of custom Gradle code for integrating framework libraries, making obfuscated builds, configuring publication, and, finally, creating signed builds.

The signed... [More]