<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gustav Wengel on Medium]]></title>
        <description><![CDATA[Stories by Gustav Wengel on Medium]]></description>
        <link>https://medium.com/@geewee?source=rss-61aaf5004b5b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*YSOuB_5uMSWPHZ-qjwWbPA.png</url>
            <title>Stories by Gustav Wengel on Medium</title>
            <link>https://medium.com/@geewee?source=rss-61aaf5004b5b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:56:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@geewee/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Azure Event Hubs Are Not Queues]]></title>
            <link>https://geewee.medium.com/azure-event-hubs-are-not-queues-ebf25bb3d49c?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebf25bb3d49c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Wed, 13 Jan 2021 12:26:04 GMT</pubDate>
            <atom:updated>2021-05-02T00:58:52.437Z</atom:updated>
            <content:encoded><![CDATA[<p>Unfortunately, I’ve seen quite a few people use <a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-about">Azure Event Hubs</a>, when what they really wanted was a queue.</p><p>Event Hubs are great for large-scale data ingestion, but if you just need to pass messages between your services — use something else. Here’s a few reasons why.</p><h3>Messages Block The Queue</h3><p>Event Hubs uses a partitioning model where messages sent to it are distributed among partitions.<br> Each partition has one reader that can read from concurrently, and the messages are always processed in order.</p><p>This means that if you have a message that’s taking a while to process, the rest of the messages on that partition are delayed.<br> It means that if you have a message that’s causing your application to crash, you can’t process anything else on that partition until you somehow deal with that message. Either by waiting and retrying, dropping the message or perhaps saving it somewhere else.</p><p>Contrast this with something like the Azure Storage Queue where you can lock a message and attempt to process it.<br> If you can’t process it or it takes a while you’re not holding anyone up. Other consumers don’t need to wait for you to process your message before they can continue.</p><h3>Checkpointing Makes Error Handling Hard(er)</h3><p>Event Hubs are batch-oriented. You receive a batch of messages and then when you’ve processed enough you create what’s called a <a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-features#checkpointing">checkpoint</a>.</p><p>A checkpoint is a way of writing down: This is how many messages I’ve processed. Checkpointing is something you do occasionally — it isn’t meant to be something you do every message.<br> If your application crashes between checkpoints it’ll start off at the last checkpoint and you’ll reprocess each message until you’re up-to-date again.<br> That means your systems have to be pretty durable to messages that are delivered multiple times.</p><p>While this is a problem with most queues (applications can always crash between receiving a message and processing it), often you’ll only process one message at a time, so there’s less harm done if something fails.</p><h3>Event Hubs Require An Extra Storage Account</h3><p>The partitioned readers use an Azure Storage account to coordinate checkpointing and <a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-processor-balance-partition-load">partition ownership</a> between them.</p><p>This means that you can’t read from an Event Hub without also having a storage account. It’s not a big deal, but it does add an extra connection string to manage, and an extra Azure resource to deploy.</p><h3>Local Development</h3><p>There is no way of running an Event Hub locally.<br> Contrast this with e.g. an Azure Storage Queue which you can run locally with <a href="https://github.com/Azure/Azurite">Azurite</a>, or many other queues which you can run in Docker.</p><p>Being able to run your dependencies locally is really nice. It means you don’t have to deal with spinning up Event Hubs for each developer.</p><h3>Reasons to use Event Hub</h3><p>I don’t hate Event Hubs. They’re a good tool if you need what it offers, such as the <a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-capture-overview">Event Capture Feature</a>, or you have large amounts of data.</p><p>But if you just need to send messages between services? Use something else.</p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/event-hubs-are-not-queues"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebf25bb3d49c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Ask Good Questions When Working Remote]]></title>
            <link>https://geewee.medium.com/how-to-ask-good-questions-when-working-remote-26bbd0dd4e79?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/26bbd0dd4e79</guid>
            <category><![CDATA[communication]]></category>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[communication-skills]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Fri, 27 Nov 2020 11:53:54 GMT</pubDate>
            <atom:updated>2020-11-27T11:53:54.255Z</atom:updated>
            <content:encoded><![CDATA[<p>At my current job with <a href="https://www.linkedin.com/company/scada-minds/">SCADA MINDS</a> I work with several different teams at the same time. That means I get to answer many questions. I’ve noticed that some teams are much, much better at asking questions and communicating than others.</p><p>Let’s take a look at two real interactions I’ve had that effectively illustrate the difference between good and bad communication in a remote setting. First, the example of bad communication. This was a question asked to me in private:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*rQyZ24L1CbRfsYck.png" /></figure><p>Next up — the better one. This was a question asked by an intern in a public development channel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*V99ZA79c-LsasJE7.png" /></figure><p>These two interactions are as different as night and day!</p><p>Let’s try to consider a couple of factors that will lead to asking good questions — and in turn getting good answers.</p><h3>Write One Self-Contained Message</h3><p>One of the most important rules when asking the question is to write <em>one</em>, self-contained, message.</p><p>While <a href="https://www.nohello.com/2013/01/please-dont-say-just-hello-in-chat.html?m=1">saying hello</a> before asking your question might seem polite in real-life, it’s awful etiquette when asking questions online.<br> Don’t write “Hello” in one message and then write your question. Whoever you write “Hello” to is going to get a notification disturbing them, and then sit and wait for you to formulate your question.<br> And definitely don’t wait for them to say “Hello” back before asking your question. That’s just going to delay the whole process even further.</p><p>Compose one message, that contains both the formalities and the question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/0*WnWeBdrsV_bKz-v6.png" /><figcaption>Something like this is a good starting point.</figcaption></figure><h3>Ask Questions In Public</h3><p>A lot of teams have a tendency to ask questions in private, because they know which person usually has the answers.<br> This will get the question answered — but it’s not the best way. Here’s why:</p><ul><li><strong>It leads to more work for the person who’s answering</strong><br> Someone else might have asked the exact same question last week, and maybe someone will next week. This person will end up answering the same question over and over.</li><li><strong>Your team doesn’t get smarter</strong><br> Anything that goes on in private chats or mails is invisible to the rest of the team who might be struggling with similar questions.</li><li><strong>Someone else might know better</strong><br> Even if you think you’re asking someone who you think knows the answer, they might not be the best person to answer it. Someone else might have much more expertise with a particular topic, but if you ask in private you’ll never find out.</li></ul><p>So instead of asking in private — here’s what you should do:<br><strong>Ask your question in the most public forum that the question is relevant to.</strong></p><p>This could be StackOverflow if you have questions that aren’t specific to your particular project or company, or it could be a company issue tracker or Q&amp;A platform. If you can ask it somewhere where it’s easy to find it later that’s best, but if not, the appropriate Teams or Slack channel is also fine.</p><p><strong>But if I do that, people don’t answer my question!</strong><br> Some teams have cultures where people are slower to help out if not explicitly asked, and some teams have cultures where people are eager.<br> You can still ask questions in public — just make sure to tag the people who you would normally write to in private.</p><p><strong>But I’m afraid to look stupid if everyone can see I don’t know something?</strong><br> That’s very human. But not knowing stuff stuff is part of the game. If you ask good questions, no one will judge you for them.</p><h3>Share The Answer</h3><p>Sometimes you can’t get your answer in a public forum. Maybe you’ll have to explain the problem in-person or do some extra troubleshooting with someone. That happens. When it does, you should always write down the answer where you asked the question.<br> Perhaps your colleagues who tried to help you are curious, or perhaps they will struggle with similar questions. Asking questions in public doesn’t help much if you don’t also share the answers in public.</p><h3>Ask Good Questions</h3><p>A lot of stuff has been written about asking good questions. <a href="https://jvns.ca/blog/good-questions/">This guide</a> is excellent and friendly, and <a href="http://www.catb.org/~esr/faqs/smart-questions.html">this guide</a> is also excellent — but much less friendly.</p><p>You should read those guides — but quickly summing up there’s two things you should consider when you ask someone a question:</p><p>Did you give them enough information to understand your question?<br> Your message should contain enough information that anyone reading doesn’t need to ask any follow-up questions to understand what your problem is. So read your message before sending it, and consider whether or not you’ve provided enough information.</p><p>Have you given them enough information to answer your question?<br> Most problems can have many potential issues. You need to explain whether or not you have any theories as to what’s going on, and what you have already tried to solve the problem.</p><p>If someone is going to answer your question, they’ll need this information. So either you’ll write it down at the start or they’re going to ask you for it. Let’s save them some time and give them all the information right off the bat.</p><p>Asking good questions is hard and a skill that takes a while to master. But we can always try to improve our communications. Try noticing if you often have exchanges where someone misunderstands your question or asks for clarification — and try to see if you can do better.</p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/how-to-ask-good-questions-remote"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26bbd0dd4e79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[On Inclusive Language In Tech]]></title>
            <link>https://geewee.medium.com/on-inclusive-language-in-tech-4bfda0816802?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bfda0816802</guid>
            <category><![CDATA[diversity-and-inclusion]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[diversity-in-tech]]></category>
            <category><![CDATA[twitter]]></category>
            <category><![CDATA[diversity]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 22 Nov 2020 11:37:23 GMT</pubDate>
            <atom:updated>2020-11-22T11:37:23.261Z</atom:updated>
            <content:encoded><![CDATA[<p>Twitter <a href="https://mobile.twitter.com/twittereng/status/1278733305190342656">recently announced</a> that they’re beginning to change many of the words they use, to “more inclusive” variants. They announced this on twitter. Which of course meant everyone wanted to fight about it.<br> How much of this is just white silicon valley folks changing words they think are offensive? Is this cancel culture just with words? Does this actually matter or is it just virtue signalling?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*4dWgn3l3DDLKVMOH.jpg" /></figure><p>The words twitter are changing, and what they’re changing them to.</p><p>Honestly I’m not sure how much the inclusive language matters in regards to minorities. I haven’t heard many members of actual minority groups say that this matters to them. But considering that tech has a huge diversity problem, perhaps this isn’t so surprising — there aren’t that many people to speak up.</p><p>So let’s sidestep that discussion for a moment, and talk about another argument for making these changes. Most of the new terms are <strong>better</strong>!<br> At least if <em>you don’t know the old ones already</em>. People naturally prefer the terms they’re used to, because things we’re used to seem natural and right.<br> But I think if you’re just getting into tech, many of the new terms are better. They’re more self-explanatory and descriptive:</p><h3>Blacklists and Denylists</h3><p>Using blacklist and whitelist have the advantages of piggybacking on &quot;regular&quot; english words. But we&#39;re creating technical terms here, so we don&#39;t <em>have</em> to use existing words, if a better alternative exist. Using allowlist and denylist have some wonderful advantages. They&#39;re self-contained and very explicit. The first time you read about an allowlist, you know exactly what it does.</p><h3>Masters or Leaders</h3><p>I particularly like changing the master/slave terminology to something that&#39;s more nuanced. Often it seems like every relationship where there&#39;s a primary (or master) instance, we describe it as a master/slave relationship. But we can do better than that. If we describe it as primary/standby, we get extra information. There&#39;s a primary instance, <em>and the role of the follower instance is to be a standby in case of errors</em>. Changing master/slave means that we get to use much more expressive terminology.</p><h3>Dummies vs. Placeholders</h3><p>I think placeholder value is a much better term than dummy value. It&#39;s much more explicit.<br> You might think dummy value is pretty explicit already - but I&#39;d argue it&#39;s not. As an international developer, I had no idea that you could &quot;dummy up&quot; something fake. I knew that dummy could mean something that resembled the real thing, but I&#39;d never made the connection between that and dummy value.<br> It was just one of those terms I used because <em>that&#39;s what we call it.</em> Contrast that with placeholder value - which says <em>exactly</em> what it is.</p><p>A lot of these new words meet resistance. Partly because they’re new, and partly because people disagree on whether or not they’re racist, and if it matters.<br> I think we should try to keep the broader picture in mind. Generations of people are going to have to learn these terms and use these words in the future. We owe it to them to pick the best damn ones.<br> Even if it does inconvenience us slightly.</p><p><em>Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/inclusive-language"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bfda0816802" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Microsoft Teams Kills Knowledge Management]]></title>
            <link>https://geewee.medium.com/how-microsoft-teams-kills-knowledge-management-20437dc0c6ea?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/20437dc0c6ea</guid>
            <category><![CDATA[knowledge-management]]></category>
            <category><![CDATA[remote-working]]></category>
            <category><![CDATA[microsoft-teams]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Thu, 19 Nov 2020 14:02:48 GMT</pubDate>
            <atom:updated>2020-11-19T14:02:48.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Microsoft Teams seems like it’s trying to be the one-stop tool for all your organisational needs. I think it works fine for chat and calls, but for knowledge management it is extremely unimpressive, often making things much harder than they need to be. Here’s four ways Teams is killing your knowledge management.</p><h3>Important and Irrelevant files are mixed</h3><p>Teams has a “Files” tab where you can save files that are relevant for a channel.<br> The concept is good, but unfortunately it’s plagued by an unfortunate decision: <em>If anyone posts a file inside a conversation it’s uploaded to the Files tab.</em></p><p>This makes it impossible to distinguish between these two scenarios:</p><ul><li>This file is here because someone consciously chose to save it so you could look at it</li><li>This file is here because someone needed to share it that one time</li></ul><p>Which means that the top level folder quickly becomes an interspersed mess of really important stuff™ and stuff that doesn’t matter at all.</p><h3>The Wiki Is Unsearchable</h3><p>Teams also has a wiki functionality where each channel gets its own wiki tab.<br> That’s wonderful — you and your team can share information and collaboratively edit it!</p><p>Except the information can be almost impossible to find again, because there’s no way to search for a specific wiki page or the content inside it.</p><p>This means that if you want to find something you have to either know exactly what channel and wiki page it’s located at, or go meandering through all the wikis of all your channels. Writing down stuff isn’t worth anything if you don’t easily let people find it again.</p><h3>You Can’t Search For Directories</h3><p>But for files, at least you can group them inside directories and then easily find those again right?</p><p>For example, we have a directory inside one of our channels called “Books” for, well, books. And if I want to find the books, I can just search for “Books” and Teams will surely get me the directory right? <br> Not a chance buddy. Teams only shows you files, not directories.</p><p>This means that to figure out what’s in a directory you either have to remember the channel it was in and find it that way, or go search through SharePoint, which luckily manages to get it right.</p><h3>You Can’t Archive Channels</h3><p>Often you create channels for projects or events, and those channels at some point become irrelevant.<br> Teams makes it very easy to be stuck with those channels forever. You can delete them — but what if there’s information in there you might need later?</p><p>There’s no way to mark that a channel isn’t active anymore. The best thing you can do is rename it and have everyone hide it so it doesn’t show up all the time — but that’s a real band-aid solution.</p><p>While Teams has come a long way for chat, it’s still lagging behind in regards to all the auxiliary functionality it offers.<br> It seems like it wants to do everything. Unfortunately it doesn’t do any of the things particularly well.</p><p>Many of these issues have been open on Microsoft UserVoice for years, with tens of thousand of votes, and no response from Microsoft.</p><p>So if you haven’t moved your wikis and file management to Teams yet — I’d suggest you wait a year or two. But if you have, like us, and the cost of switching away is too high, there’s nothing to do but arm yourself with a truckload of patience.</p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/teams-awful-for-knowledge-management"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20437dc0c6ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Death Spirals and Working Too Damn Hard]]></title>
            <link>https://medium.com/swlh/death-spirals-and-working-too-damn-hard-af885b140ea2?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/af885b140ea2</guid>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[work-life-balance]]></category>
            <category><![CDATA[work]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 11:37:04 GMT</pubDate>
            <atom:updated>2020-11-18T12:16:58.995Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I’ve been thinking a lot about what I call <em>Death Spirals</em>. The name might be a bit much but I like the dramatic flair.</p><p>A Death Spiral is a special kind of positive feedback loop. A positive feedback loop is something that’s self-reinforcing. Examples of positive feedback loops:</p><ul><li>When you have a lot of followers on social media, more people view and share your content. When more people share it, more people see it and follow you. The more followers you have, the easier it is to get new ones.</li><li>When you’re out of shape, exercise is harder so you’re less likely to do it. The less likely you are to exercise, the more you become out of shape, the less likely you are to exercise, and so it goes.</li></ul><h3>The Death Spiral</h3><p>A Death Spiral is special kind of positive feedback with some unique characteristics:</p><ul><li>Breaking out of it requires more resources than you currently have</li><li>The longer you’re in it, the harder it is to break out of it</li></ul><p>Death Spirals can happen for many reasons and hit both companies and individuals. Let’s take a look at two examples.</p><h3>Jane And Her Diabetes</h3><p>Jane has diabetes. She hasn’t responded well to any medicine and she’s feeling very sick. Her doctor tells her that exercise will help her.<br> Jane’s symptoms are so severe that after coming home from work she has no energy left to exercise.<br> Jane is in a Death Spiral. Her diabetes will continually get worse. As it gets worse, she gets and less energy for exercising. The longer she waits, the harder it becomes to break out.</p><h3>JojaCo: The Burnout Factory</h3><p>Death Spirals happen to companies too. One of my good friends used to work at a company <em>JojaCo</em>. JojaCo helped their customers manage technical infrastructure.</p><p>JojaCo employees were a little overworked. Then someone became long-term sick. Fewer people had to do the same work. To get all of the new work done on time, the employees had to cut some corners.</p><p>The company used to have documentation for each customer describing how to make changes in their systems. You usually updated this after interacting with a customer. This documentation slowly stopped being up-to-date as no one had time to update it anymore.<br> While not updating it saved time in the short run, helping the customer the next time took much longer. This meant that the employees got further behind, and had to cut even more corners.</p><p>In a stressful environment like this, people started falling ill due to stress. This left even more work for fewer people. At the end my friend was working 70+ hours a week. He was miserable. Everyone were sick or quitting, and new hires didn’t stick around for long.</p><p>So how <em>do</em> you break out of a Death Spiral? You somehow have to find energy and resources you don’t have. This can be extremely difficult, and if there is a step-by-step guide I haven’t found it.<br> These are my best bets:</p><h3>Do Less</h3><p>If you don’t have to do as much, you’ll have more resources to break free of the Death Spiral.</p><p>If you’re JojaCo you can call up some of your customers, and tell them that you can’t currently help them. They probably won’t be your customers in the future. But it might save you from losing other customers because your employees are burned out.</p><p>If you’re Jane, try to take some days off from your job and use them to start exercising. Or maybe you can do find a routine that requires less chores, or try some healthy meal box services.</p><p>“Do less” is advice that’s easy to give, but <em>really</em> hard to follow. It’s not always possible to do less. Your boss might not let you take days off. You might not be able to pay your salaries if you turn away some of your customers.</p><h3>Get help</h3><p>If you can’t reduce the amount of work, you might be able to share it among more people. More people to do the same work means there’s less work for everyone.</p><p>JojaCo could hire new employees or temps.<br> Jane could get someone to run with, or help her with some of the other responsibilities she has.</p><p>Getting help isn’t always easy though. Perhaps you don’t have the social support to find someone to run with. Maybe you can’t afford or find qualified people to work at JojaCo.</p><p>Death Spirals are particularly tricky because there’s often no easy way out once you’re in them. Often we keep struggling along, while hoping that something will change.</p><ul><li>Perhaps you’ll wake up one day, invigorated with new energy to start exercising.</li><li>Perhaps your employee will stop getting sick from stress soon.</li><li>Perhaps things will improve somehow, even though you’re not really sure how.</li></ul><p>I don’t think Death Spirals usually correct themselves until you hit rock bottom. We just stay in that slow, steady decline, because all the ways to break free are either impossible or requires choices we can’t get ourselves to make.</p><p>So here’s my plea to you: If you observe someone in a Death Spiral — say something. Breaking free without help can be extremely difficult. It’s okay to ask if someone needs help.</p><p><em>Do you have any experiences with death spirals? How did you get out of it? I’d really like to hear some other opinions or stories!Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/death-spirals"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af885b140ea2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/death-spirals-and-working-too-damn-hard-af885b140ea2">Death Spirals and Working Too Damn Hard</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Reasons to Not Use Observables in C#]]></title>
            <link>https://medium.com/swlh/5-reasons-to-not-use-observables-in-c-be757392a09e?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/be757392a09e</guid>
            <category><![CDATA[observables]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 08 Nov 2020 11:31:44 GMT</pubDate>
            <atom:updated>2020-11-12T19:28:12.724Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was first introduced to Observables in C#, they sounded pretty damn good. “They just model streams of data”, “It’s just data over time” and “It’s just the push equivalent of an IEnumerable”. After working with them for a little while, I don’t think they’re as good as I was told.</p><p>The statements above might be true. Observables might be simple from a birds-eye perspective. Unfortunately simple doesn’t always mean easy and there’s are some things that will end up biting you in the ass. Here’s five of them.</p><h3>The Framework Has No Consistent Name</h3><p>When searching for documentation and solutions to problems with Observables, I always felt like I didn’t know what to search for. Previously I’ve always known the terms to use, django {your-problem-here}, serilog {how-to-do-x} {framework}-{problem description}<br> However with Observables I had a lot of problems finding people encountering similar issues, and I was never really sure what to put for the{framework} part of my queries.</p><p>I spent a little time trying to figure out what the right term is. Turns out — nobody seems to know.</p><p>On Stack Overflow the most used tag is system.reactive, but looking official documentation and Stack Overflow questions, I&#39;ve seen it referred to as:</p><ul><li>Reactive Extensions <a href="https://docs.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh242985(v=vs.103)?redirectedfrom=MSDN">[1]</a> <a href="https://github.com/dotnet/reactive">[2]</a></li><li>Rx (short for Reactive Extensions) <a href="https://docs.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh242985(v=vs.103)?redirectedfrom=MSDN">[1]</a> <a href="https://github.com/dotnet/reactive">[2]</a></li><li>Rx.Net <a href="https://github.com/dotnet/reactive#flavors-of-rx">[1]</a> <a href="http://reactivex.io/languages.html">[2]</a></li><li>.NET Reactive Framework <a href="https://stackoverflow.com/questions/1596158/good-introduction-to-the-net-reactive-framework/1749252#1749252">[1]</a></li><li>ReactiveX <a href="http://reactivex.io/">[1]</a></li></ul><p>With all of these names that are subtly different — what am I supposed to search for?</p><p><em>We’ll call it Rx.Net in the rest of the post — at least it’s short</em></p><h3>The Documentation Is Hard To Find</h3><p>Finding documentation online for Rx.Net is pretty close to impossible. While figuring out the search terms to use is hard, finding comprehensive documentation is much, much harder.</p><p>Rx.Net is the .NET flavour of <a href="http://reactivex.io/">ReactiveX</a>, which luckily seems to have quite a bit of documentation! Unfortunately you pretty much have to know what you’re looking for already. If I want to read the documentation for how the C# Select works, I need to know that in ReactiveX, Select is called Map</p><p>When I know that, in the ReactiveX documentation I can find a language-agnostic explanation of what a Map/Select does. There&#39;s also language-specific documentation for each of the different flavours, including Rx.Net!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/0*zZU79UQ8aYrj81CT.png" /></figure><p>Just kidding</p><p>There’s also no API reference online anywhere. I can find the documentation in the editor, so I know it’s been <em>written</em> — but it isn’t hosted anywhere. The closest we get is this API reference from <a href="https://docs.microsoft.com/en-us/previous-versions/dotnet/reactive-extensions/hh244252(v%3Dvs.103)">MSDN</a>. From 2011.</p><h3>Observables are hard to debug</h3><p>Observables can be a pain to debug. Most debuggers aren’t particularly suited for tracing streams of data, and the stack traces you get are unimpressive. Let’s dive a little deeper into the stack traces. Take this piece of code which throws an error after a few integers have passed through the stream.</p><pre>[Fact]<br>public void ObservableTest()<br>{<br>   IObservable&lt;int&gt; observable = Observable.Range(0, 5)<br>       .Select(i =&gt; i * 2)<br>       .Do(i =&gt;<br>       {<br>           if (i &gt; 5)<br>           {<br>               throw new Exception(&quot;That&#39;s an illegally large number&quot;);<br>           }<br>       });<br><br>   observable.Subscribe(<br>       onNext: (i) =&gt; Console.WriteLine(i),<br>       onError: (err) =&gt;<br>   {<br>       throw err;<br>   });<br>}</pre><p>The humongous Stacktrace is as follows:</p><pre>Error Message:<br>   System.Exception : That&#39;s an illegally large number<br>  Stack Trace:<br>     at MyProject.Test.ObservableTest.&lt;&gt;c.&lt;Foo1&gt;b__0_3(Exception err) in /home/geewee/programming/MyProject.Test/ObservableTest.cs:line 30<br>   at System.Reactive.AnonymousSafeObserver`1.OnError(Exception error) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\AnonymousSafeObserver.cs:line 62<br>   at System.Reactive.Sink`1.ForwardOnError(Exception error) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\Sink.cs:line 61<br>   at System.Reactive.Linq.ObservableImpl.Do`1.OnNext._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Do.cs:line 42<br>   at System.Reactive.Sink`1.ForwardOnNext(TTarget value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\Sink.cs:line 50<br>   at System.Reactive.Linq.ObservableImpl.Select`2.Selector._.OnNext(TSource value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Select.cs:line 48<br>   at System.Reactive.Sink`1.ForwardOnNext(TTarget value) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\Sink.cs:line 50<br>   at System.Reactive.Linq.ObservableImpl.RangeRecursive.RangeSink.LoopRec(IScheduler scheduler) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Range.cs:line 62<br>   at System.Reactive.Linq.ObservableImpl.RangeRecursive.RangeSink.&lt;&gt;c.&lt;LoopRec&gt;b__6_0(IScheduler innerScheduler, RangeSink this) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Linq\Observable\Range.cs:line 62<br>   at System.Reactive.Concurrency.ScheduledItem`2.InvokeCore() in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\ScheduledItem.cs:line 208<br>   at System.Reactive.Concurrency.CurrentThreadScheduler.Trampoline.Run(SchedulerQueue`1 queue) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\CurrentThreadScheduler.cs:line 168<br>   at System.Reactive.Concurrency.CurrentThreadScheduler.Schedule[TState](TState state, TimeSpan dueTime, Func`3 action) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\CurrentThreadScheduler.cs:line 118<br>   at System.Reactive.Concurrency.LocalScheduler.Schedule[TState](TState state, Func`3 action) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\LocalScheduler.cs:line 32<br>   at System.Reactive.Concurrency.Scheduler.ScheduleAction[TState](IScheduler scheduler, TState state, Action`1 action) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Concurrency\Scheduler.Simple.cs:line 61<br>   at System.Reactive.Producer`2.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\Producer.cs:line 119<br>   at System.Reactive.Producer`2.Subscribe(IObserver`1 observer) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Internal\Producer.cs:line 97<br>   at System.ObservableExtensions.Subscribe[T](IObservable`1 source, Action`1 onNext, Action`1 onError) in D:\a\1\s\Rx.NET\Source\src\System.Reactive\Observable.Extensions.cs:line 95<br>   at MyProject.Test.ObservableTest.ObservableTest() in /home/geewee/programming/OAI/MyProject.Test/ObservableTest.cs:line 25</pre><p>Removing all the Rx.Net internal stuff, this is the only information in the stack trace we care about:</p><pre>Error Message:<br>   System.Exception : That&#39;s an illegally large number<br>  Stack Trace:<br>     at MyProject.Test.ObservableTest.&lt;&gt;c.&lt;ObservableTest&gt;b__0_3(Exception err) in /home/geewee/programming/MyProject.Test/ObservableTests.cs:line 30<br>     at MyProject.Test.ObservableTest.ObservableTest() in /home/geewee/programming/OAI/MyProject.Test/ObservableTests.cs:line 25</pre><p>We get the line number where we subscribed to the observable, and the function inside the chain where the error was thrown. I have no idea what transformations the data has gone through. If the stream has been dynamically constructed I might not even know what it looks like.</p><p>These issues aren’t unique to observables. Composing long LINQ-expressions suffer from the same issues. When composing several different functions together, the stack traces very quickly stop becoming meaningful. The below is the complete stack trace the Enumerable/LINQ version of the Observable code.</p><pre>Error Message:<br>   System.Exception : That&#39;s an illegally large number<br>  Stack Trace:<br>     at MyProject.Tests.ObservableTests.&lt;&gt;c.&lt;TestLinq_StackTraces&gt;b__2_1(Int32 i) in /home/geewee/programming/MyProject.Test/ObservableTests.cs:line 55<br>   at System.Linq.Utilities.&lt;&gt;c__DisplayClass2_0`3.&lt;CombineSelectors&gt;b__0(TSource x)<br>   at System.Linq.Enumerable.SelectRangeIterator`1.MoveNext()<br>   at MyProject.Tests.ObservableTests.TestLinq_StackTraces() in /home/geewee/programming/MyProject.Test/ObservableTests.cs:line 60</pre><p>It’s much cleaner, but it doesn’t give us any more information than the observable version.</p><p>The poor debugging and stack-traces are a perpetual thorn in my side when working with Observables. But if the same issues exist with long chains of Enumerable, why is that less of an issue? The short answer — I don’t know.</p><p>My best guess is that when using Observables there’s a strong tendency to keep everything as an Observable stream. The longer your streams are the harder debugging with a minuscule stack trace becomes.</p><h3>It’s Hard To Use Scopes</h3><p>A very common thing I need to do is attach some sort of context to a request or a series of events.</p><pre>var id = &quot;myCoolId&quot;<br>using (LogContext.PushProperty(&quot;id&quot;, id))<br>{<br>    // Every log statement in here will have the `id=myCoolId` attached <br>    await DoSomething(id);<br>}</pre><p>This is a very common usage patterns for logging, for example in Web Apps if you want to attach a specific GUID to a Request, so you can later correlate all logs for that specific request.</p><p>Something like this isn’t possible when using Rx.Net, as it’s threading model doesn’t carry over the ExecutionContext. <a href="https://github.com/dotnet/reactive/issues/14">[1]</a> <a href="https://stackoverflow.com/questions/51279665/net-core-asynclocal-loses-context-with-system-reactive">[2]</a> <br> This means that we can’t use something like an AsyncLocal or a ThreadLocal to keep context for a specific piece of data or stream. If we want the myCoolId to be attached to all of the logs, we&#39;ll need to pass it into every step of our observable chain, and manually pass it to every logging call. I know there&#39;s a value in being explicit, but this is a time where choosing Rx.Net locks you out of some pretty handy language features.</p><h3>It never really took off</h3><p>Looking at the timelines, it seems like Rx.net in the hype cycled peaked a few years ago. If it ever really took off.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/0*4hPXaaLw18fEoKDb.png" /></figure><p>Google Trends for system.reactive compared to the Javascript version of the ReactiveX framework.</p><p>Comparing it in google searches to RxJS it seems much less widely used. Looking at the Stack Overflow trends reveals a little more nuanced picture however:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/0*pHK-ajxnrFSy7Cta.png" /></figure><p>Stack Overflow trends for system.reactive compared to the Javascript and Java versions of the ReactiveX framework.</p><p>While still much less popular than RxJS and the Java ReactiveX version, Rx.Net does seem to predate their popularity by quite a few years. Microsoft was out early with the reactive paradigm but never really seemed to manage to make it take off.</p><p>Now while your technology choices shouldn’t be about how hyped something is — the popularity is always worth taking into account. Some old technologies are sturdy, battle-tested and well-documented. Then they don’t have to be shiny.</p><p>However with some of the pitfalls, particularly around the documentation issues, Rx.Net feels neither robust or shiny to me.</p><p>While this is a negative article, I’m not saying Rx.Net or the Reactive paradigm is <em>always</em> bad. Some of the issues are about the tooling and documentation. I mention that most debuggers aren’t suited for debugging streams, but this is a tooling problem and not inherent to the reactive paradigm. E.g. Jetbrains has an excellent <a href="https://plugins.jetbrains.com/plugin/9696-java-stream-debugger">Java Stream Debugger</a>.</p><p>Observables seems like a very natural fit for some languages and domains, like reacting to user interactions in JavaScript, as the large adoption of RxJs suggests. I’m just saying that it doesn’t feel like a particularly natural fit for C#, and if you have some data that can be modelled as either Enumerables or Observables, I would think twice about using Observables.</p><p><em>Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/5-reasons-to-not-use-observables"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be757392a09e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/5-reasons-to-not-use-observables-in-c-be757392a09e">5 Reasons to Not Use Observables in C#</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being In A Hurry Makes You Slower]]></title>
            <link>https://geewee.medium.com/being-in-a-hurry-makes-you-slower-404a1b0ca84f?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/404a1b0ca84f</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[time-management]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Tue, 03 Nov 2020 14:14:13 GMT</pubDate>
            <atom:updated>2020-11-03T14:14:13.614Z</atom:updated>
            <content:encoded><![CDATA[<p>Not too long ago I was working on an unfamiliar project, with a technology stack I didn’t really know. I had a short deadline, and (what I thought was) a pretty short assignment. Turns out it wasn’t. Every time I thought I was done the requirements shifted slightly and every time I thought I had solved the last bug a new one appeared.</p><p>Because I was pressed for time, I did two things:</p><ul><li><a href="https://www.gustavwengel.dk/death-spirals">I cut corners</a>. I didn’t refactor things I should have and I should have tested things I didn’t. I didn’t feel like I had time to do those things — but I also didn’t always know exactly how. This leads to my next point:</li><li>I neglected to learn the things I needed. I felt like I couldn’t justify the time spent to learn how to do X properly, when I didn’t have very much time to do X in the first place.</li></ul><p>In another world where the task had been as small as we thought, these could have been the right decisions.<br>However as soon as the task became just a little bigger than we thought, neglecting to <a href="https://www.franklincovey.com/the-7-habits/habit-7.html">learn my tools</a> properly made me much less effective. I traded a short-term benefit for a long-term loss.</p><p>I’m not saying you should always spend the time to learn how to do everything properly. But if you’re always in a hurry, and you never get the time to slow down, you might have an issue. Likewise, if you have a short deadline for something and you decide that it’s not worth the time, but then the deadline shifts — it’s time to re-evaluate. A deadline and scope that shifts once, will probably shift again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=404a1b0ca84f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing A Fast Queryable Storage with Apache Avro and Azure Block Blobs]]></title>
            <link>https://geewee.medium.com/implementing-a-fast-queryable-storage-with-apache-avro-and-azure-block-blobs-c6b130f3e413?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6b130f3e413</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[apache-avro]]></category>
            <category><![CDATA[azure-blob]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 10:31:55 GMT</pubDate>
            <atom:updated>2020-11-26T01:53:59.253Z</atom:updated>
            <content:encoded><![CDATA[<p>At my employer <a href="https://www.linkedin.com/company/scada-minds/">SCADA MINDS</a> we’re currently working on implementing a data pipeline for one of the larger wind companies in the world. Wind turbines have <em>a lot</em> of sensors, that generate a lot of time-series data. For the amount of turbines we need to support, we need to be able to process upwards of 1GB/sec.</p><p>This is a blog post about how, using Azure Block blobs, we’ve made a performant API that can handle that amount of data, and still maintain a respectable latency when queried (&lt;500ms for most cases)</p><p>When considering solutions we had a few criteria that needed to fulfill:</p><ul><li><strong>We need to allow querying on a given sensor for a given time interval</strong><br> Each sensor on a wind turbine has a unique sensor id. When you need to query this storage, you always query for a <em>sensor id in a specific time interval</em>. This is the only query type we need to support.</li><li><strong>We need to allow incremental updates of the data</strong><br> Sometimes sensors go offline or turbines are a little slow to catch up. This means that for a given interval, we’re not sure when we’ll have all the given sensor data. Our solution needs to be able to handle updating the data efficiently.</li><li><strong>Our solution must be cost-efficient</strong><br> We also need to keep an eye towards cost. While we could fulfill all the other criteria by dumping all of our data inside a managed time-series database, it’s going to end up being <em>very</em> expensive.</li></ul><p>We ended up with a solution where we store .avro files in <a href="https://azure.microsoft.com/en-us/services/storage/blobs/">Azure blob storage</a> in a way that effectively allows us to only update and fetch parts of the file. Let&#39;s zoom out a bit and look at the two major components of the solution.</p><p>An .avro file is a row-based open source binary format developed by Apache, originally for use within the Hadoop. Officially the avro format is defined by the very readable <a href="https://avro.apache.org/docs/current/spec.html">spec</a>, but you can also think of it as a more advanced.csv file.</p><p>Like a csv file an avro files also has a header and multiple rows. Unlike csv files, rows in an avro file are compressed and can contain a variable amount of data. Let’s dive a little more into the two parts of an avro file.</p><p>The file header consists of metadata describing the rest of the avro file. It contains the avro schema which is JSON describing the format of the rest of the file. The file header ends with a sync marker, which is a randomly generated block of sixteen bytes. The sync marker is used internally in an Avro file at the end of the header and each data block.</p><p>The sync marker is randomly generated when writing a file. It&#39;s unique within the same file but different between files.</p><h3>Avro Row</h3><p>After the header the avro file consists of multiple rows. Each row contains encoded data as specified by the header schema. At the end of each block is the sync marker - so we can tell where one row ends and another begins. These are officially called data blocks, but as we have another type of block later, we&#39;ll stick to calling them rows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/0*lCEYHE0Gt9zaPuxW.png" /><figcaption>The structure of an avro file</figcaption></figure><p>The fact that Avro files are designed this way means that they’re very good at being sliced into pieces and stitched back together again. As long as you know the schema and the sync marker, the rows can both be <em>read</em> and <em>written</em> independently.</p><p>We’ll be using that property to construct a storage that efficiently handles both incremental updates, and partial reads of these files.</p><p>But first, we need to know a little more about Azure Block Blobs.</p><h3>The structure of an Azure Block Blob</h3><p>The next component we’re using is the Azure Blob Storage, which is a blob-based storage service. However it has a few more tricks up its sleeve than just being able to upload and download arbitrary blobs. It has <a href="https://docs.microsoft.com/en-us/rest/api/storageservices/understanding-block-blobs--append-blobs--and-page-blobs">three different types of blobs</a>, each with their own characteristics. The ones we’ll be using are called <em>block blobs.</em></p><p>A block blob is a blob/file, that consists of several different pieces which are called blocks. Each block consists of some data, and it has a unique block id which we can specify. We use the block id to refer to the block later.</p><p>A blob consists of one or more blocks. By re-ordering, replacing or adding blocks to a blob, we’re able to efficiently update and change files with a minimum of work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*F1gi_CbocLbYYTOcHkpF0w.png" /><figcaption>The structure of an Azure Block Blob</figcaption></figure><p><em>A word on words: While the “official” terms are </em><em>blocks and </em><em>blobs, where one </em><em>blob consists of multiple</em><em>blocks, I feel the two terms are a little too close to each other, and I certainly often get confused. From here-on I&#39;ll call the blobs</em><em>files. It&#39;s less-correct, but hopefully harder to get them mixed up.</em></p><h3>Writing files</h3><p>Writing a file via the block blob interface consists of two parts.</p><h4>Stage your blocks</h4><p>The first step is staging the new blocks you want to be part of your blob. You upload some bytes, tag them with a block id, and you&#39;re golden. You can upload any number of blocks, but they&#39;re considered uncommitted, which means they don&#39;t really do anything.</p><h4>Commit the blocks</h4><p>The next step is committing the blocks which creates a fully formed file. You commit the blocks by sending a list of block ids to be committed. The file will then consist of these blocks, in the order that the block ids are provided. The block ids can either be uncommitted blocks we’ve staged via the previous steps or blocks that already exist in the file.</p><p>This means that if we want to write a block and put it in the middle of a file, we’d do the following:</p><ul><li>Stage the block with a unique id</li><li>Ask the blob for all the current block ids</li><li>Put our new block id at the appropriate place in the list of current block ids</li><li>Commit the list of block ids with our new block id in it</li></ul><h4>Reading from block blobs</h4><p>We can query an Azure Block blob for the list of blocks and how many bytes are in each.</p><p>The Azure Blob Storage API allows you to specify only a range of bytes to fetch. This means that using the list of blocks, we can figure out what byte range a given block exists in. Using these two mechanisms together, we’re able to fetch any given block from a file if we know the block id.</p><p>The general structure we’ve created is as follows:</p><p>For each 10 minute interval, we create a new .avro file in our blob storage. The file names contain the time interval, e.g. 2020-01-01T13:30:00--2020-01-01T13:40:00 represents data between 13:30 and 13:40 on January 1st 2020.</p><p>The avro file consists of multiple rows. Each row corresponds to a sensor id, and contains the time-series data for the sensor in the given interval.</p><p>We split the avro file up into blocks as follows</p><ul><li>One block for the avro header. The block id is something unique such as $$$_HEADER_$$$</li><li>One block for each row in the avro file. The block id here is the sensor id.</li></ul><p>Each row in the avro file corresponds to a block in the Azure Block Blob. They’re even both called blocks!</p><h3>Querying For Specific Sensor Data</h3><p>We allow querying for a time interval on a specific sensor id. First of, we have to calculate which files are relevant, when given an interval to search for. Depending on the interval you search for this could be multiple .avro files.</p><p>We do that by listing the file names in the blob storage. As each file name contains its interval, finding the right files is a matter of some reasonably simple string matching.</p><p>We can then use the unique properties of the block blobs and avro files to only fetch the data we need. As the sensor id is the block id of the block, we can quickly see which block contains the data for a particular sensor.</p><p>The process of extracting data for a specific sensor is then:</p><ul><li>Use the block list to figure out which block contains the avro row</li><li>Fetch the header block and the block containing the sensor data</li><li>Stitch the two blocks together to form a complete avro file.</li><li>Parse the avro file and return the result</li></ul><h3>Writing and updating</h3><p>The first time we’re writing data to an interval is pretty straightforward. We generate a header and stage that in the first block. Afterwards we stage each row of our avro files in a separate block. We then commit all the blocks we just staged.</p><p>Later on when we get new data for an interval, all we need to do is stage blocks with the new data. As mentioned previously when writing a row to an avro file, all we need is the schema and the sync marker.</p><p>So we can update our intervals like this:</p><ul><li>We fetch the header block from the existing file, and extract the schema and sync marker</li><li>We stage each new row with the sensor id as the block id, using the schema and sync marker retrieved from above.</li><li>We commit the old block ids along with the newly staged ones. This allows us to update the old file with the new data, without ever touching the old data.</li></ul><h3>In Summary</h3><p>Our old system was based on the same principles of saving avro files to a blob storage, but didn’t use any of the fancy block functionality. This meant that when we had to query for a specific tag, we had to fetch the entire file, and then parse it on the client.</p><p>It also meant that when we wanted to append to a file, we had to download the old file, and merge it with the new data, taking much longer than it needs to.</p><p>Using some of the more advanced functions in the Azure blob storage allowed us to scale our API response time from 5s~ to less than 500ms, for large amounts of data while keeping the whole thing at a reasonable cost.</p><p><em>Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/azure-blob-block-avro-storage"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6b130f3e413" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Checklist For Evaluating New Technology]]></title>
            <link>https://geewee.medium.com/a-checklist-for-evaluating-new-technology-239111d2af8a?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/239111d2af8a</guid>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 25 Oct 2020 10:22:15 GMT</pubDate>
            <atom:updated>2020-10-25T10:22:15.596Z</atom:updated>
            <content:encoded><![CDATA[<p>New technology often comes along with a lot of promises. All the hard things? They’re <em>easy</em> now. All of your troubles? <em>Shh, they’re all better now.</em></p><p>The reality is, of course different. New technology sometimes solve problems in wonderful ways, but just as often it doesn’t live up to the hype. It can be hard to determine whether something looks great because it solves a real problem or just because it’s new and shiny.</p><p>I work at <a href="https://www.linkedin.com/company/scada-minds/">SCADA MINDS</a>, a consultancy company primarily doing green-energy software projects. We’re in the process of streamlining how we evaluate when to adopt new technology. We’ve created a checklist for evaluating the pros/cons of new technology and I’ve added my personal thoughts about each point.</p><h3>Does it solve a problem you’re actually having right now?</h3><p>Many goats have been sacrificed on the altar of “We absolutely need this in the future.”</p><p>I’ve seen enough things we need in the future, never being needed at all. <a href="https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it">You ain’t gonna need it</a>, is as true as ever. Both for actual code, but also for new technology. There’s a value in <strong>defaulting to dull.</strong> Go for the battle-tested un-sexy technologies until they fail you. The best time to adopt a new technology is when you <em>need</em> it — not before.</p><h3>Does it come with any advantages?</h3><p>New technology often promises many things that might, or might not, turn out to be true. It might solve the simple cases, but have issues with the more complex scenarios you’ll actually encounter in daily life.</p><p>Of course, consider the advantages new technology gives you. Just keep in mind they are much fluffier and harder to evaluate than the point above. It’s always easier to evaluate whether or not the technology solves a problem you have currently, than how much any “new advantages” are worth.</p><h3>Does it come with any downsides?</h3><p>It’s easy to only think about what you can get out of something new — but you often lose something as well. Does this new technology lack integrations with the services you use? Is it opinionated in a way that doesn’t align with how you already do things? Is it really time-consuming to learn? We should always consider both the downsides and the upsides of the new technology.</p><h3>Is it easily replaced?</h3><p>If it turns out your bet on this technology is wrong — how easy is it to replace it? Is it contained in one part of your application or does it leak into every part?</p><p>If you find a new cool in-memory caching library, there’s a pretty good chance it’ll be easy to rip out and replace with something else. Libraries like that rarely leak into much of the code.</p><p>It’s a little different if you decide to adopt a new web framework, a new database system or perhaps a reactive library that’ll be used everywhere. Things like that leak. They become entangled with every part of your application, and almost impossible to replace.</p><p>Be careful when adopting things that are hard to replace. They’re a lot more expensive to get wrong.</p><h3>Can it be evaluated quickly?</h3><p>Some technology is reasonably quick to evaluate. If you’re evaluating a new templating language, you can reasonably quickly determine whether it’ll do the things you need.</p><p>This isn’t true for all technology though. I know people who have favourably evaluated <a href="https://www.gustavwengel.dk/serverless-or-not">Serverless</a> frameworks and used them for many months, only to run into some major scalability and pricing problems months down the road.</p><p>The technologies you can evaluate in two weeks are mostly harmless. It quickly becomes apparent whether or not they’ll work for you. It’s the technologies that you have to use for six months before you find the pointy edges that are dangerous.</p><h3>Is the project/technology popular and well maintained?</h3><p>There’s a certain charm to being bleeding edge. There’s less charm in being being stuck with a technology nobody uses and nobody can help you with. When evaluating a project, check whether or not it’s still active. Does it have many answered questions on StackOverflow? If it’s on Github — when was the last commit? Are issues resolved?</p><p>A project that isn’t super active doesn’t necessarily make it bad. However if you find a two-star project on Github that was last updated in 2016 but promises you the world — you might want to tread carefully.</p><h3>How mature is it?</h3><p>New technologies often showcase very compelling happy-paths. Then you start tweaking it and everything falls apart. Evaluating how mature a technology is, particularly in a field you don’t know much about is hard.</p><p>I’ve used and evaluated a lot of ORMs, so I know some of the things that indicate if it’s immature. I know to look for how they handle migrations, what their transaction support is like and how they deal with lazyloading and complex queries. I know this because I’ve used a lot of immature ORMs, and I’ve been bitten in the ass by each one of these things.</p><p>Being able to evaluate technology often comes with experience in a particular domain. That’s how you know where the pointy edges are. But you can often use age as a proxy for maturity. A technology that has been used and updated over two years, is usually more mature than one that has only been out for six months.</p><h3>Can we scale this effectively inside the company?</h3><p>This is probably more specific towards consultancies or teams that juggle many projects and technology stacks at once. Sometimes there’s a technology that solves a problem really well in your particular project, but which is really hard to understand or learn.</p><p>You might have a few developers that’s proficient in it. However if you don’t succeed in making these skills common-place, you’ll essentially end up with areas of your applications that only a few people dare touch. You’re going to have a low <a href="https://en.wikipedia.org/wiki/Bus_factor">bus-factor</a>, and you’re going to have developers grumbling about <em>“that stupid thing that is way too complex for the problem it’s solving”</em></p><p>It’s also worth keeping in mind that software projects usually live for years, and someone else might have to maintain them. This means the time to learn something new will probably have to be paid many times over. We should balance the rewards new technology gives us with paying the price of learning it many times over.</p><h3>Can it be maintained?</h3><p>We often have to write code that our clients have to maintain in the end. When you know someone else has to take over a project it can be important in writing something they can understand. If your client works primarily with Java, they probably wouldn’t appreciate a project written in OCaml very much.</p><h3>Can you afford it?</h3><p>Does it have a permissive license both for development and production usage? If it costs money, are the potential advantages worth the cost?</p><p><em>Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/evaluating-new-technology"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=239111d2af8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Static Factory Methods vs Constructors In C#]]></title>
            <link>https://geewee.medium.com/static-factory-methods-vs-constructors-in-c-b20d15b9da89?source=rss-61aaf5004b5b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b20d15b9da89</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Gustav Wengel]]></dc:creator>
            <pubDate>Sun, 18 Oct 2020 09:22:21 GMT</pubDate>
            <atom:updated>2020-10-18T09:22:21.374Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently while pair programming with a colleague, we got into discussing the best way to initialize new objects in C#. I’ve always just implemented constructors and left it at that, while he tended to favour static factory methods. This led to a lot of discussion and back-and-forth about the pros and cons of each type.</p><p>Just to clarify what I’m talking about, here’s an example of both</p><pre>// Using the constructor<br>SqlConnection myConnection = new SqlConnection(connectionString);<br><br>// Using a static factory method<br>IDbConnection myConnection = SqlConnection.FromConnectionString(connectionString);</pre><p>I’ve never considered implementing these static factory methods before and I naturally scorned what I didn’t understand. I’ve since changed my mind — let’s dive into the pros &amp; cons.</p><h3>Pros of Static Factory Methods</h3><h4>No need to return a new instance</h4><p>In constructors you always have to return a <em>new</em> object.</p><p>You can’t use a cached object or return null if the object creation fails. I think for most application code, you probably don&#39;t need to do this, but the ability is certainly nice. Particularly if you&#39;re writing library code, you might appreciate the flexibility in the future.</p><h4>You can use method references</h4><p>If you’re inclined to write your C# more in a functional way — you might appreciate that you can pass a reference to the method (or “method group” as they’re officially called) in your code. Contrast this:</p><pre>// Static factory method - the method group can be passed in directly as a function reference<br>var bars = myFoo<br>    .Select(bar.FromFoo)<br><br>// Constructors - you have to pass in a lambda that constructs the instance via new.<br>var bars = myFoo<br>    .Select(f =&gt; new Bar(f));</pre><p>There’s no functional difference in this code — it’s only a matter of taste in code style, so it probably shouldn’t weight <em>too</em> heavily into the decision.</p><h4>You can name ‘em</h4><p>For some objects, particularly objects that can be constructed in multiple similar ways — being able to put a name on the way you construct your objects can be a huge benefit. Let’s take an example of a Color class than can be constructed both via CMYK and RGB parameters.</p><pre>// With constructors<br>var color = new Color(25, 25, 5, 80);<br>var color = new Color(100, 150, 50);<br><br>// With static factory methods<br>var color = Color.FromCMYK(25, 25, 5, 80);<br>var color = Color.FromRGB(100, 150, 50);</pre><p>Unless you <em>know</em> that the four value constructor of Color is CMYK and the three value constructor is RGB, it’s impossible to tell by reading the code. Contrast that with the static factory methods which are much more descriptive.</p><p>I think if you have different ways to construct an object, particularly ones where the parameters resemble each other, there’s a strong case for using the static factory methods.</p><h4>Factory Methods can return a different class</h4><p>While New Foo() always has to return a new instance of the Foo class, Foo.FromBar can easily return an IFoo interface, or a subclass of Foo. A real-world example where this could be relevant:</p><pre>// This could create an IpV4IpAddress that implements IIpAddress <br>IIpAddress ipv4Address = IpAddress.FromString(&quot;127.0.0.1&quot;);<br><br>// This could create an IpV6IpAddress that implements IIpAddress <br>IIpAddress ipv6Address = IpAddress.FromString(&quot;2001:0db8:0a0b:12f0:0000:0000:0000:0001&quot;)</pre><p>Being able to return a different actual type depending on the input is probably pretty valuable when providing public APIs, such as in library contexts. Particularly because it means you can hide some implementation details behind an interface or a base class.</p><p>I’m not sure the value is as great in application code, where you control the whole codebase and can make large-scale refactorings much easier.</p><h4>There Are Things You Shouldn’t Do In Constructors</h4><p>Generally people don’t expect constructors to do much of anything but construct an object. While you can do I/O, database access etc in constructors, most people don’t expect it. Convention-wise you’re free to do more work in a static factory method without anyone raising any eyebrows.</p><p>Some people also don’t think you should throw exceptions in constructors. Perhaps it depends on the language, but in C# <a href="https://docs.microsoft.com/en-us/cpp/mfc/exceptions-exceptions-in-constructors?view=vs-2019">it’s totally fine</a>, with some caveats if you’re <a href="https://stackoverflow.com/questions/926362/throwing-exceptions-from-a-constructor-in-net">creating umanaged resources in your constructor</a>.</p><h3>Cons of Static Factory Methods</h3><p>Let’s look at the flip side of the coin</p><h4>There Are Things You Shouldn’t Do In Constructors</h4><p>Constructors are usually simpler by convention. When I call a constructor, I generally don’t expect it to do I/O or anything fancier than return a plain vanilla object with the properties I gave it. This makes constructors much less flexible as a construct, which can be both a blessing and a curse.</p><h4>There’s more code</h4><p>No matter what, you’re still going to need a constructor to actually construct the objects. The static factory method is more code, and <a href="https://chrismdp.com/2012/09/code-is-a-liability/">code is a liabillity.</a> It’s usually not very complex code, and usually the static factory methods aren’t particularly long either — so this is probably not a huge con.</p><h4>They’re harder to find</h4><p>Usually when I try to construct a new object, I look for the constructor first. It’s a little harder to find a static method via autocomplete — as they’re usually not distinguishable from other static methods.</p><p>I think my biggest issue I have with the static factory methods is the discoverability you lose.</p><p>After doing the research and thinking about it, I think my opinion is this currently:</p><ul><li>You should always create one constructor that maps 1:1 to the fields internally in the class.</li><li>If you need to do anything fancy to create the object, such as IO, or you’re interested in caching objects and reusing them, use a static factory method.</li><li>If you need API stability, such as for library development, hide that constructor and use a static factory method because of the implementation flexibility it gives you.</li><li>If you have multiple different ways to create your class, create static factory methods and use those, because of the descriptiveness they give you.</li></ul><p><em>Did you enjoy this post? Please share it!</em></p><p><em>Originally published at </em><a href="https://www.gustavwengel.dk/csharp-static-factory-vs-constructor"><em>https://www.gustavwengel.dk</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b20d15b9da89" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>