<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andreas Jakof</title>
    <description>The latest articles on DEV Community by Andreas Jakof (@andreasjakof).</description>
    <link>https://dev.to/andreasjakof</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F129943%2F61163383-7bf3-47dc-912f-bf4c9d7f9897.jpg</url>
      <title>DEV Community: Andreas Jakof</title>
      <link>https://dev.to/andreasjakof</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andreasjakof"/>
    <language>en</language>
    <item>
      <title>Fun with Units of Measure</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Fri, 29 Jan 2021 14:44:02 +0000</pubDate>
      <link>https://dev.to/andreasjakof/fun-with-units-of-measure-5347</link>
      <guid>https://dev.to/andreasjakof/fun-with-units-of-measure-5347</guid>
      <description>&lt;p&gt;A while ago I read about F#'s Units Of Measure Support. Inspired by this, I just wanted to have some fun and do something like that in C#. The result has come to a point, where I am willing to let it loose to the world.&lt;/p&gt;

&lt;p&gt;This is open source. So if someone would like to add something, feel free to make a pull request.&lt;/p&gt;

&lt;h1&gt;
  
  
  What I have so far
&lt;/h1&gt;

&lt;p&gt;I already implemented metric, imperial and usually some astronomic and/or fun equivalent units of&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Distance &lt;/li&gt;
&lt;li&gt;Area &lt;/li&gt;
&lt;li&gt;Volume &lt;/li&gt;
&lt;li&gt;Mass&lt;/li&gt;
&lt;li&gt;Velocity&lt;/li&gt;
&lt;li&gt;Frequency&lt;/li&gt;
&lt;li&gt;Time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;BigDoubles, which are necessary, when converting f.e. between the mass of our sun and gram, are taken from &lt;a href="https://github.com/Razenpok/BreakInfinity.cs"&gt;Razenpok - Break Infinity&lt;/a&gt; and modified slightly.&lt;/p&gt;

&lt;p&gt;The interesting part was, to allow for automatic conversion between units of the same "area", but only those - and to enforce those restrictons already at compile time. I wanted the compiler to tell you, that you can not convert 10 cm to seconds instead of a runtime exception.&lt;/p&gt;

&lt;p&gt;Have fun with it and maybe contribute your own favorite fun equivalent: &lt;a href="https://github.com/DerGuru/UnitsOfMeasure"&gt;Units Of Measure&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>unitsofmeasure</category>
      <category>opensource</category>
    </item>
    <item>
      <title>IoC-Container with Mocks for Unit Testing</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Mon, 28 Sep 2020 16:34:00 +0000</pubDate>
      <link>https://dev.to/andreasjakof/ioc-container-with-mocks-for-unit-testing-449g</link>
      <guid>https://dev.to/andreasjakof/ioc-container-with-mocks-for-unit-testing-449g</guid>
      <description>&lt;p&gt;I was looking for an &lt;code&gt;IServiceCollection/IServiceProvider&lt;/code&gt; using Mocks instead of the real thing, in one class (or two dependend classes), to test my StartUp-Code for multiple WebSites/WebServices. I recently converted them to IoC, which gave me some headaches at first, because I forgot to register some of the later needed types to the IoC-Container. &lt;br&gt;
And since I did not find any, I decided to build one of my own. &lt;br&gt;
I call it &lt;a href="https://github.com/DerGuru/MockProvider"&gt;MockProvider&lt;/a&gt; and you can use it via &lt;a href="https://www.nuget.org/api/v2/package/MockProvider/"&gt;NuGet&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;You can use DI in ASP.NET CORE in multiple ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Constructor Injection into classes, that are created by the Framework. In my case the controllers.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;MyController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt; &lt;span class="n"&gt;myFoo&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Method Injection, into methods that are called from ASP.NET CORE. Like Controller Methods using &lt;code&gt;[FromServices]&lt;/code&gt; Attribute.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyController&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Controller&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;FromServices&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt; &lt;span class="n"&gt;myFoo&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;You could always use it "manually" providing an instance of your &lt;code&gt;IServiceProvider&lt;/code&gt; to many constructors and heve the Dependency resolved in the constructor, the method where it is needed. I don't say you should, but you could.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, I was interested in the first two, so I created a small &lt;a href="https://github.com/DerGuru/MockProvider"&gt;Startup Tester&lt;/a&gt; as well, to keep my boiler plate code to a minimum ... and because I like a challenge.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is this about?
&lt;/h2&gt;

&lt;p&gt;This little helper provides you with an implementation for &lt;code&gt;IServiceProvider&lt;/code&gt; and &lt;code&gt;IServiceCollection&lt;/code&gt; to be used as a replacement for the default ASP.NET CORE types during unit tests and uses Mocks from &lt;a href="https://github.com/moq/"&gt;Moq&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I personally use it to test, whether the startup type registrations to the IoC-Container are complete.&lt;/p&gt;
&lt;h2&gt;
  
  
  What can I do with it?
&lt;/h2&gt;

&lt;p&gt;You can use it as &lt;code&gt;IServiceCollection&lt;/code&gt; and &lt;code&gt;IServiceProvider&lt;/code&gt; within StartUp and later for e.g. Controllers/Methods, that make use of .NET CORE's Depedency Injection.&lt;/p&gt;

&lt;p&gt;If you don't want to run through the complete setup every time, you may also add Mocks of your own.&lt;/p&gt;
&lt;h3&gt;
  
  
  Use it as &lt;code&gt;IServiceCollection&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Create an empty MockProvider and use it as your &lt;code&gt;IServiceCollection&lt;/code&gt; in any default &lt;code&gt;StartUp.ConfigureServices&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Use it as &lt;code&gt;IServiceProvider&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Create a filled MockProvider and use it as your &lt;code&gt;IServiceProvider&lt;/code&gt; in any method, that wants one.&lt;/p&gt;
&lt;h3&gt;
  
  
  Add you own Mocks
&lt;/h3&gt;

&lt;p&gt;The easiest way to add specific mocks to it, is to use the &lt;code&gt;CreateMock&amp;lt;T&amp;gt;&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;MockProvider&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreateMock&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IsNotNull&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetService&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are some overloads:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;public Mock&amp;lt;U&amp;gt; CreateMock&amp;lt;U&amp;gt;()&lt;/code&gt;&lt;br&gt;
This is the most basic version. It finds constructor parameters and creates mocks for them as well. When done, it returns your created mock.&lt;br&gt;
Since this will use previously registered types for constructor parameter matching and directly creates the mock, should only be used after putting the parameter types in the container or for constructor parameterless types.  &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;public Mock&amp;lt;U&amp;gt; CreateMock&amp;lt;U&amp;gt;(params object[] o)&lt;/code&gt;&lt;br&gt;
This lets you specify the constructor parameters and returns your created mock.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;public MockDescriptor CreateMock(Type serviceType)&lt;/code&gt;&lt;br&gt;
Like the first one, this will do everything by itself, but handing back an internal representation of the IoC-Registration. The Mock is created lazily on first use. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;public MockDescriptor CreateMock(Type serviceType, params object[] o)&lt;/code&gt;&lt;br&gt;
Like the second one, this lets you specify the constructor parameters, but handing back an internal representation of the IoC-Registration. The Mock is created lazily on first use. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;public MockDescriptor CreateMock(Type serviceType, IEnumerable&amp;lt;object&amp;gt; o)&lt;/code&gt;&lt;br&gt;
Like the second one, this lets you specify the constructor parameters, but handing back an internal representation of the IoC-Registration. The Mock is created lazily on first use. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then there is: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;public void Add(ServiceDescriptor item)&lt;/code&gt;
Using the &lt;code&gt;IServiceCollection&lt;/code&gt;s internal type, there are three ways to go:

&lt;ol&gt;
&lt;li&gt;The default &lt;code&gt;ServiceDescriptor&lt;/code&gt; from .NET Core's IoC Container.
This will use the ServiceType and register a Mock for it. The Mock is created lazily on first use. &lt;/li&gt;
&lt;li&gt; There is a &lt;code&gt;MockDescriptor&lt;/code&gt; derived from &lt;code&gt;ServiceDescriptor&lt;/code&gt;, which allows you to first create your Mock and then add it to the IoC-Container. The &lt;code&gt;MockDescriptor&lt;/code&gt;-Instance is added to the Container, as it is. &lt;/li&gt;
&lt;li&gt; There is also a &lt;code&gt;InstanceDescriptor&lt;/code&gt;, which will add a real object to the Container, allowing you to implement your own stub and use it in the IoC-Container. The &lt;code&gt;InstanceDescriptor&lt;/code&gt;-Instance is added to the Container, as it is, since it derives from MockDescriptor.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  When registering the same service type multiple time, which one will be returned on &lt;code&gt;GetService&amp;lt;T&amp;gt;()&lt;/code&gt;?
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fooMock1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fooMock2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;Mock&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;MockProvider&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;fooMock1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IFoo&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;fooMock2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first entry wins. So the above will add only &lt;code&gt;fooMock1&lt;/code&gt; to the container.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>netcore</category>
      <category>ioc</category>
      <category>unittests</category>
    </item>
    <item>
      <title>Persisting and Multi-Reader IAsync Enumerable</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Mon, 18 May 2020 15:47:34 +0000</pubDate>
      <link>https://dev.to/andreasjakof/persisting-and-multi-reader-iasync-enumerable-38fm</link>
      <guid>https://dev.to/andreasjakof/persisting-and-multi-reader-iasync-enumerable-38fm</guid>
      <description>&lt;p&gt;It has been a while, but I have been busy.&lt;/p&gt;

&lt;p&gt;Well not with my home page, which was there and then no longer is...&lt;br&gt;
But I come, bearing gifts.&lt;/p&gt;

&lt;p&gt;I am currently working with quite big lists, I download from Azure via it's Graph API. Until recently I used the usual suspects to store the downloaded data ... well ... mostly a List.&lt;/p&gt;

&lt;p&gt;And then I stumbled over &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;, which allows for using the data already, while it is only partially downloaded (yet).&lt;br&gt;
The drawback: You will have to download it every time you access it.&lt;/p&gt;

&lt;p&gt;Well in my case, I was going through the downloaded data multiple times and I thought I encapsulate it, to persists the downloaded data while downloading. So the second time I access it, it is already there.&lt;/p&gt;

&lt;p&gt;It will depend on you use case, but I need one consistent set of multiple chunks/lists. So I either download everything once or do everything on the fly.&lt;br&gt;
"Once" was my preference and I decided to create something that can support this use case.&lt;/p&gt;

&lt;p&gt;Said and done. It took some time to make it thread safe. And since this introduces some runtime overhead, which is not always needed/wanted, I also decided to have two variants of it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Single Threaded Access - which gives you an Exception, when trying to create another Enumerator, while the "old" one is stil in use (or at least not yet disposed).&lt;/li&gt;
&lt;li&gt;The multi threaded one, which allows for multiple readers on the same underlying IAsyncEnumerable, persisting it's data along the way.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where can I get it?
&lt;/h2&gt;

&lt;p&gt;You can look into the sources here: &lt;a href="https://github.com/DerGuru/PersistingAsyncEnumerable"&gt;GitHub - PersistingAsyncEnumerable&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or get the NuGet Package here: &lt;a href="https://www.nuget.org/packages/PersistingAsyncEnumerable/1.0.0"&gt;NuGet - PersistingAsyncEnumerable&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What kind of licence is it?
&lt;/h2&gt;

&lt;p&gt;MIT. I just thought, It might help some one and it was fun for me to create it.&lt;/p&gt;

&lt;p&gt;Have fun with it and I would love some feedback.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>netcore</category>
    </item>
    <item>
      <title>Help: I am looking for some online tool for retrospectives </title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Fri, 15 May 2020 00:56:48 +0000</pubDate>
      <link>https://dev.to/andreasjakof/help-i-am-looking-for-some-online-tool-for-retrospectives-48o5</link>
      <guid>https://dev.to/andreasjakof/help-i-am-looking-for-some-online-tool-for-retrospectives-48o5</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;I am the Agility Master for our Kanban Team and in our Retrospectives, we would like to follow some basic approach, where we collect, group and vote on topics to the classic „What went well“, etc.&lt;/p&gt;

&lt;p&gt;Now the first part is easy. There are tons  of tools, that help you here. &lt;/p&gt;

&lt;p&gt;Coming to the hard part: We also would like to do root cause analysis for two to three voted groups and I am unable to find any tool, which has it all.&lt;/p&gt;

&lt;p&gt;We are helping ourselves currently with MS Whiteboard, which works for us, but it could be better.&lt;/p&gt;

&lt;p&gt;Any suggestions?&lt;/p&gt;

</description>
      <category>question</category>
      <category>help</category>
    </item>
    <item>
      <title>Merry Christmas and a Happy New Year</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Thu, 26 Dec 2019 13:56:01 +0000</pubDate>
      <link>https://dev.to/andreasjakof/merry-christmas-and-a-happy-new-year-3643</link>
      <guid>https://dev.to/andreasjakof/merry-christmas-and-a-happy-new-year-3643</guid>
      <description>&lt;p&gt;I hope you are all doing well!&lt;/p&gt;

&lt;p&gt;To all christians (and those following the tradition) a „merry Christmas“!&lt;/p&gt;

&lt;p&gt;And to all of you, following the Georgian calendar, a „happy new year!“&lt;/p&gt;

&lt;p&gt;🎆&lt;/p&gt;

&lt;p&gt;I know there are other religions and calendars, but those are the ones I was socialized with.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My way to and in tech as a Developer</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Thu, 31 Oct 2019 15:09:38 +0000</pubDate>
      <link>https://dev.to/andreasjakof/my-way-to-and-in-tech-as-a-developer-45gi</link>
      <guid>https://dev.to/andreasjakof/my-way-to-and-in-tech-as-a-developer-45gi</guid>
      <description>&lt;p&gt;This post is a &lt;del&gt;bit&lt;/del&gt; far more personal, than my others and I was thinking quite a lot about, whether to write it at all, because I am usually more of an introvert and don't share so much personal stuff, especially on the internet. But I think, this might give some motivation or support to others in a similar position, as I was in 2010. So I decided to go through with it.&lt;/p&gt;

&lt;h1&gt;
  
  
  tl;dr;
&lt;/h1&gt;

&lt;p&gt;As the song goes: You can do it, if you really want it... &lt;br&gt;
but you must try, try and try...&lt;br&gt;
Just be consistent and follow your desire. And sometimes life will surprise you! A little bit of luck can't hurt either.&lt;/p&gt;



&lt;h1&gt;
  
  
  The early years
&lt;/h1&gt;

&lt;p&gt;I fell into the pot when I was seven years old. My father bought an &lt;a href="https://en.wikipedia.org/wiki/Atari_8-bit_family#Newer_XL_machines"&gt;Atari 800XL&lt;/a&gt;. We sat together long hours and copied a computer program in &lt;a href="https://en.wikipedia.org/wiki/BASIC"&gt;BASIC&lt;/a&gt; from a magazine to the computer. Yes, that was a thing in 1985.&lt;br&gt;
After some time, we wrote a simple math learning programm together, that gave simple mathematical tasks to solve and fired thunder and lightning, when solved correctly.&lt;/p&gt;

&lt;h1&gt;
  
  
  As a teenager
&lt;/h1&gt;

&lt;p&gt;A few years later, I got my first own computer: a &lt;a href="https://en.wikipedia.org/wiki/Amiga_1200"&gt;Commodore Amiga 1200&lt;/a&gt;, which already had 14MHz and 2 MB of RAM (don't laugh, that was quite good at the time). I also bought an extension card with a 50 MHz FPU and additional 2 MB of RAM. Later came a harddrive with 30 MB.&lt;br&gt;
I mostly dabbled in creating system disks, optimizing the RAM usage and the space on the disk, to get the maximum of tools onto one disk. A little bit of shell scripting, but not much more, except playing games on it.&lt;/p&gt;

&lt;p&gt;And then there was a class in school called EDV (german: Elektronische Datenverarbeitung, translates roughly to electronic data processing), where I learned a little more BASIC and Turbo Pascal, which I fell in love with. I wanted to code, but I always had (and still have) the problem, that I lack the ideas. If I have an idea, I come up with solutions, but what kind of problem, do I want to solve?&lt;/p&gt;

&lt;p&gt;Later there was &lt;a href="https://en.wikipedia.org/wiki/Prolog"&gt;Prolog&lt;/a&gt;, which was a bit weird at the beginning. We never did much with it, but it showed us another paradigm: &lt;a href="https://en.wikipedia.org/wiki/Logic_programming"&gt;logic programming&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  As a student
&lt;/h1&gt;

&lt;p&gt;For me it was clear, that I wanted to study CS ... and so I did... start at least. &lt;br&gt;
I started CS at the University, but soon after (well, after five semesters) I realized, that it is not for me. It was not what I expected and not what I wanted. We learend about different pradigms, SQL and a little bit of network basics, but in those 2.5 years, we never opened an IDE or text editor, to write some code. All just theory: Complexity Theory, Graph Theory, Formal Languages, Automatas and on top of that some electrical engineering.&lt;/p&gt;

&lt;p&gt;So I decided to change my direction to a more practical one: Business Informatics. Less theory, more practice, but also a lot more business management.&lt;br&gt;
I was able get some credits for stuff I already completed in CS, but there was a lot of economics in there. And here comes another problem of mine personally ... I never had to learn in school. I heard it and since it was repeated so often in class, it just stuck. Reading again, what topics we covered was preparation enough for any tests in school to at least get a B. So the hardest task for me, was to learn, how to learn and that was a really hard task for me, since I am inherently lazy. I often joke about lazyness as a reason to get into programming in the first place. But the truth is: I'd rather sit there thinking and programming an automated task instead of doing it manually, even if it takes twice (or more) as long. But the second time, the automation is already there.&lt;/p&gt;

&lt;p&gt;I really would have liked, to complete Business Informatics, but there were some issues with the examination office, which led to me being exmatriculated. I don't blame them, because, if I would not have been so lazy, I never had come into the issue in the first place.&lt;/p&gt;

&lt;p&gt;This was also the time, I met my future wife, which finally put some ambition into me ... even if just to not fall from her grace. And since I already prepared for a big test about the content of 6 courses at once, I used my final chance and changed again: this time to Business Management.&lt;/p&gt;

&lt;p&gt;I passed the test with &lt;del&gt;flying&lt;/del&gt; colours, but it still took me another few years, to finish it all. This time, because I already started working. First at a distribution center of a grocery store chain and later at a small startup, mostly writing texts for manuals. &lt;/p&gt;

&lt;p&gt;Until one day, that changed everything.&lt;/p&gt;

&lt;h1&gt;
  
  
  Graduation time
&lt;/h1&gt;

&lt;p&gt;It was 2010 and I was already worried for a while about, what might happen after graduation. My resumee was far from perfect. I almost did not get a place for the practical semester, which was required for graduation. &lt;/p&gt;

&lt;p&gt;And so I sat there, writing and proof reading texts in a 500 MB Word document, that was saved on a network share, which led to 30 second breaks every time the auto save hit, which unfortunately seemed to be every time, I had formed a decision about, how to write that sentence.&lt;/p&gt;

&lt;p&gt;A guy, I never met before, came into the room and asked me to write a technical evaluation document for another project they were doing. He showed me some sketches with bullet point notes, answered some questions and left me with it.&lt;/p&gt;

&lt;p&gt;I wrote it and I was quite pleased with the result. It showed all the options, with their pro's and con's, giving enough information to make an informed decision without going to much into details.&lt;/p&gt;

&lt;p&gt;Two weeks later the same guy showed up again, telling me, that the customer was very impressed and blurted "Now, you only need to be able to code!" And I thought: This is my chance! &lt;br&gt;
So I took the leap and said: "Yes, I have a little experience in coding. Which language?"&lt;br&gt;
"We are using C++, with boost to make it platform agnostic and a self written framework of mine that takes care of interprocess and network communication." &lt;em&gt;&lt;a href="https://dev.to/andreasjakof/brilliant-but-also-horribly-wrong-50de"&gt;which I already wrote a piece about here&lt;/a&gt;&lt;/em&gt;. &lt;br&gt;
Most of the sentence was gibberish for me, but I still replied "I don't have experiences with C++, just Turbo Pascal and &lt;a href="https://en.wikipedia.org/wiki/Delphi_(software)"&gt;Delphi&lt;/a&gt;. But to me, programming is more the algorithmic thinking and problem solving, the rest is just syntax."&lt;/p&gt;

&lt;p&gt;To be honest, my biggest project up to then, were some school projects and a countdown timer, ticking down the seconds during semester breaks until I saw my future wife again. But I knew, that I liked programming and although there would have been a lot to learn, I hopefully would be able to do it.&lt;/p&gt;

&lt;p&gt;As a result of that conversation, he promised, to take me on board as a software developer right after graduation at least for this project.&lt;/p&gt;

&lt;h1&gt;
  
  
  After graduation
&lt;/h1&gt;

&lt;p&gt;And so - with some luck - I landed my first job as software developer right after my studies, which I am still thankful for. I never had imposter syndrome at the time. That came a bit later, when I finally realised, what I was getting into. &lt;/p&gt;

&lt;p&gt;The job was very close to hardware, but not in the sense of down to the metal, but interacting with reality. We built simulators for special training. The one I was hired to participate in, was for air traffic controller education. So we had two radar consoles and a tower replicated with all the knobs, lights and radio transmission. And I &lt;strong&gt;LEARNED&lt;/strong&gt;! I did my first polymorphy, I was working multithreaded, I built a factory, without knowing, that it was a factory ... the learning curve was very (&lt;strong&gt;VERY&lt;/strong&gt;) steep. And I loved every bit of it.&lt;/p&gt;

&lt;p&gt;Imagine five guys, sitting around a pc with an attached console, that has buttons on it. Pressing a button and a number appears on the screen, resulting in all of them shouting in joy and giving each other high fives!&lt;/p&gt;

&lt;p&gt;My still future wife and I finished at the same time. As a matter of fact, we wrote our thesis together. And it was time to apply for jobs. I already had one, so I told her to take, whatever she wants and I would follow. Easier said than done.&lt;/p&gt;

&lt;p&gt;I played with open cards. I would be there until the end of the project and afterwards, if they still want me, until I have another job in the same city as my girlfriend.&lt;/p&gt;

&lt;p&gt;I was there about a year and traveled about 1100 km (~680mi) each week, to visit my future wife. I knew, that this was the hardest time for most relationships ... trying to make it work, while finding a new routine for one self. &lt;/p&gt;

&lt;p&gt;I applied for jobs in the area of her living at least twice a week for about six months, at the beginning mostly in Marketing (my major) and later mostly as a developer. I was getting rejections over and over ... often even no answer at all. Until one day, when I suddenly had two offers on the table and I was the one who could decide. It was much later, that I had hoped for - I already was no longer working as a full time employee but as a contractor for the same start up - but I could finally move on.&lt;/p&gt;

&lt;p&gt;Both offers were in IT consulting companies. One was really upfront about travelling, the other just "could not guarantee", that I would not need to travel. I felt more drawn to the first one and at least the travel costs were now no longer mine.&lt;/p&gt;

&lt;h1&gt;
  
  
  Consulting
&lt;/h1&gt;

&lt;p&gt;We had three weeks of training, learning C# and other MS Products. After that we were assigned to our service lines. I drew the short straw and was assigned to SharePoint.&lt;/p&gt;

&lt;p&gt;I did not have prior experiences with C#, but since there was about a month between training and the first project, I dove into it. I already knew, what I wanted: The beloved framework, I was working with at the start up, but I wanted it in C#. I knew how it worked, so I rebuilt it from scratch. I did some wrong design decisions and put them straight later on. I still have it and even used it for a project in production.&lt;/p&gt;

&lt;p&gt;My first project had SharePoint as focus, but right the second project was a developer assignment. My job (in a team) was it, to cut a big Visual Studio Solution of 212 projects into pieces, that could be maintained separately to reduce friction between the teams. There was everything in there: C, C++, C++/CLI and C#.&lt;/p&gt;

&lt;p&gt;I opend the solution and the first thing I did, was looking at a class dependecy diagram and I saw a blob. I always called it lovingly "the felt". There were so many classes (I looked it up later: ~6600), you could not make out anything. So I needed another abstraction level. &lt;br&gt;
Projects would be great, but there was no tool (to my knowledge) that could do it at the time. So I wrote a Solution and Project parser, that showed me the dependencies as a graph.&lt;br&gt;
Going around with that graph, talking to people, asking what everything is, marking the projects with colours and grouping them was the first step.&lt;br&gt;
The second was cutting it apart. I somehow took the lead (I had the plan) and we started moving files around, changing the code as little as possible and building some tooling around it, which worked a bit like NuGet today. We prepared everything as good as we could and then it was time to go into production. &lt;br&gt;
We had one week, doing it bit by bit and on a Sunday afternoon, we were done. Three consecutive tests on three different machines worked. There was champaign and a deep sleep afterwards.&lt;br&gt;
The next week my project lead asked me, why I was in the SharePoint service line, I would have been a much better developer. I wholeheartedly agreed and a few months later I was in the Service Line Application Development.&lt;/p&gt;

&lt;h1&gt;
  
  
  At last
&lt;/h1&gt;

&lt;p&gt;A mariage, a few projects and six years later, I was still in consulting. And for quite some time now, I wanted something more local. Yes, I was no longer paying to see my (now) wife, but I was apart very often. I had a good deal with the current customer, to travel only every other week, but still...&lt;/p&gt;

&lt;p&gt;I was already applying for jobs for four years now. Not really permanently, but at least once per quarter and later once a month. I also had some interviews, but nothing came around. The problem was, that in the area, where we lived at the time, the companies mostly used JAVA and I could not show any experience with it. So the possibilities were sparse. But never give up hope!&lt;/p&gt;

&lt;p&gt;I was working as consultant at a big chemical company in Germany for about 2.5 years now, when the leader of the team, I was working closely with, came by and asked, whether I could imagine working permanently for them.&lt;br&gt;
My wife and I had moved to Berlin in the meantime and they also have an office in Berlin. So I said yes. I did not bargain much about the salary. Not less than before was okay for me, my reasons to change were of a different nature.&lt;/p&gt;

&lt;h1&gt;
  
  
  Happily ever after
&lt;/h1&gt;

&lt;p&gt;And now (for the last two years) I have what I want. I can spend most evenings with my wife at home and I have a lot of independence at work, since my team leader usually lets us developers do, as we think is right. We are allowed and encouraged, to try new technologies. So I changed a large code base &lt;a href="https://dev.to/andreasjakof/migrating-net-framework-tp-net-core-b4p"&gt;from .NET Framework to .NET Core&lt;/a&gt; and we are currently moving everything to the cloud - in our case Azure, since we already use Intune and Office 365. &lt;br&gt;
If you look at other posts of me, you will find some of my experiences with that.&lt;/p&gt;

&lt;p&gt;I travel to the headquarter about once every six weeks to meet the rest of the team. Usually these weeks lead to lots of talking and no coding, but thats fine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I do what I love and what I wanted to do since childhood and I get paid for it!&lt;/strong&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  So why am I writing all this?
&lt;/h1&gt;

&lt;p&gt;Even if this reads different, I had setbacks and not just a few. I was rejected more often, than I took time to count. I had doubts about my future, not only work related but also personally: My wife and I almost did not marry.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you put yourself together and go forward. Not necessarily in a straight line, but in the rough direction.&lt;/li&gt;
&lt;li&gt;If you accept the fact, that this might not yet be the ideal solution, but at least it is better than before. &lt;/li&gt;
&lt;li&gt;If you accept setbacks but keep your vision, and &lt;/li&gt;
&lt;li&gt;if you are willing to work through it all, &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;life will eventually present you with a chance. And if that chance presents itself, take the leap and make a step. It might not look like much at the moment, but this is a marathon, not a sprint. &lt;/p&gt;

&lt;p&gt;Keep at it and you can make it happen!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>talesfromthepast</category>
    </item>
    <item>
      <title>Ask questions and tell us your passion </title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Fri, 25 Oct 2019 11:48:54 +0000</pubDate>
      <link>https://dev.to/andreasjakof/ask-questions-and-tell-us-your-passion-1jcm</link>
      <guid>https://dev.to/andreasjakof/ask-questions-and-tell-us-your-passion-1jcm</guid>
      <description>&lt;p&gt;This week, we have welcomed a new trainee in our team. He is still pretty green, but he had the right attitude to the job.&lt;/p&gt;

&lt;p&gt;He escaped from Syria in 2015, coming to Germany with nothing. He then spent multiple months in a camp and after that he first started his education. &lt;/p&gt;

&lt;p&gt;He is into coding for about 6 months now, starting with HTML and some very basic JS. For 2 months he started looking into C# (our „team“ language of choice).&lt;/p&gt;

&lt;p&gt;So we did except a little but not too much. And we were about right. What I did not expect, because of other experience, was his attitude towards coding. Usually trainees came to it, because „there is good money in it and they don’t get dirty“. But he just likes to code. &lt;/p&gt;

&lt;p&gt;I was talking to him and he was an artist in Syria and to him, coding is comparable to that. I am by far no artist, but I can relate to his argument. An argument I already read: It’s the process of creation.&lt;/p&gt;

&lt;p&gt;Another aspect of his attitude: He comes and asks questions. And not just how to solve this or that, but how this works and why this behaves like that.&lt;br&gt;
He is also proactive: He finished his job (a small API, to calculate Exchange Values between currencies) and right after it, he came to me and told me, that he would like to learn SQL. He saw, that we are using it quite a bit in our daily work and he wants to learn!&lt;/p&gt;

&lt;p&gt;I was very impressed and I wanted to share that with you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don’t be afraid to ask and if you want to learn something, tell your team or boss. If it has the least value, you will most likely get the chance!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I told him, to pick up a tutorial, gave him some links, where he could read more and we expanded his Currency Exchange API to a banking Platform (from the view of a Bank) so there will be accounts, account owners and transactions. No security, though, that would add too much complexity for now. &lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Managing Credentials</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Fri, 18 Oct 2019 15:34:09 +0000</pubDate>
      <link>https://dev.to/andreasjakof/managing-credentials-18d1</link>
      <guid>https://dev.to/andreasjakof/managing-credentials-18d1</guid>
      <description>&lt;p&gt;I guess we all can agree, that storing Credentials in Code is a really, really bad idea! Not only can you reverse engineer the assemblies, but with Azure DevOps (or GitHub, ...) you can read the credentials in the clear.&lt;br&gt;
Obfuscation does not help either, so if I ever see something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;_password&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;@"klksndfl"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I think I'll cry!&lt;/p&gt;

&lt;p&gt;But the question stands, how to access other systems with credentials, without having them in the code.&lt;/p&gt;

&lt;p&gt;Well you have a couple of options here:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Storing the credentials somewhere else
&lt;/h3&gt;

&lt;p&gt;This is the most obvious and easiest approach. Removing the credentials from code, but leaving them in the clear in another file, that is read during runtime and contains the credentials.&lt;br&gt;
The application runs in a user context, therefore the file must be readable by the user, the application is running as. Forbid everyone else and you already have a very basic security. At least more than in code. &lt;br&gt;
&lt;strong&gt;Make sure, to never check it in or you haven't won anything.&lt;/strong&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Encrypting it in the code
&lt;/h3&gt;

&lt;p&gt;With encryption you can choose between symetric and asymetric ... or (like in S/MIME) use a combination of both.&lt;br&gt;
No matter how you decide, there will be always the question, how to secure the parameters for encryption. If you save them in the code, you could have saved your credentials in the clear.&lt;/p&gt;

&lt;p&gt;Well, if you choose asymetric, there is a way by using &lt;code&gt;X509Certificate2&lt;/code&gt;.&lt;br&gt;
First of all, asymetric is not cheap, that's one of the reasons S/MIME uses a combination of both. But, since we have only very small amounts of data (credentials usually are much less that 1 kb), we still can use it.&lt;br&gt;
&lt;a href="https://github.com/DerGuru/CrytpJson/blob/master/CryptoJson/CryptoJson.cs"&gt;This little class of mine takes the properties from a directly derived class and stores them into an asymetrically encrypted base64-string or a BSON encoded asymetrically encrypted Stream.&lt;/a&gt;&lt;br&gt;
There is a readme, showing how to use it.&lt;/p&gt;

&lt;p&gt;It served me very well! Rest in peace little helper. ... but now we use another option:&lt;/p&gt;
&lt;h3&gt;
  
  
  3.&lt;a href="https://azure.microsoft.com/en-us/services/key-vault/"&gt;Azure Key Vault&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;When runnig in Azure loading from an Azure Key Vault is as easy as these few lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;LoadFromKeyVault&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="k"&gt;ref&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;credentialName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;new&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;creds&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;astp&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;AzureServiceTokenProvider&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;kvc&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;KeyVaultClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;KeyVaultClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AuthenticationCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="n"&gt;astp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;KeyVaultTokenCallback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;secret&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kvc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetSecretAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"https://&amp;lt;YourKeyVaultName&amp;gt;.vault.azure.net/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
          &lt;span class="n"&gt;credentialName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
          &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;creds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;JsonConvert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeserializeObject&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;creds&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You manage the access in the KeyVault itself with Managed Identites.&lt;br&gt;
So only allowed and managed Principals (Users/Apps) are able to get to your precious credentials while TLS secures the transport.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>devops</category>
      <category>csharp</category>
      <category>security</category>
    </item>
    <item>
      <title>Generic Singletons</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Mon, 07 Oct 2019 12:15:14 +0000</pubDate>
      <link>https://dev.to/andreasjakof/generic-singletons-1oca</link>
      <guid>https://dev.to/andreasjakof/generic-singletons-1oca</guid>
      <description>&lt;p&gt;When design patterns are concerned, the most commonly used might be the factory and the singleton.&lt;br&gt;
As a quick disclaimer: This works with C#, but I don't know, if there are other languages out there (not .NET), which might support this.&lt;br&gt;
I also try to make this as beginner friendly as I can, but even if generics are quite powerful, they can be unintuitive at some points. So if I missed something cruicial, don't hesitate to ask in the comments.&lt;/p&gt;
&lt;h3&gt;
  
  
  Whats a singleton?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one "single" instance. This is useful when exactly one object is needed to coordinate actions across the system. The term comes from the mathematical concept of a singleton. &lt;a href="https://en.wikipedia.org/wiki/Singleton_pattern"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Translated: &lt;br&gt;
You have a type and there should be one and only one instance of that type.&lt;/p&gt;

&lt;p&gt;Usually this is done, by making the constructor private and giving the class a static property... let's call it "Instance".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Singleton&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="c1"&gt;//make the constructor private&lt;/span&gt;
   &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;Singleton&lt;/span&gt; &lt;span class="n"&gt;Instance&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//access it like this&lt;/span&gt;
&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Singleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But what if you have multiple Singletons, that should behave the same? &lt;/p&gt;

&lt;p&gt;You could still create the (now abstract) Singleton-BaseClass but with a protected constructor, have an abstract "GetInstance()" Method and override it in the derived classes?&lt;br&gt;
Well there is one problem: Static Methods can be neither abstract nor virtual. So you need to create the boiler code over and over again.&lt;br&gt;
In my case this were 10 (and growing) AAD-Groups, that all have the ability to check, if a user is a member, add a user and remove a user.&lt;/p&gt;
&lt;h3&gt;
  
  
  Generics to the rescue
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Generic programming is a style of computer programming in which algorithms are written in terms of &lt;em&gt;types to-be-specified-later&lt;/em&gt; that are then instantiated when needed for specific types provided as parameters. This approach [...] permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplication ... &lt;a href="https://en.wikipedia.org/wiki/Generic_programming"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Translated: Generic programming allows you to write code, that can operate on specific types, which are not known yet, but will support this kind of code.&lt;/p&gt;

&lt;p&gt;Pretty abstract? Yes it is, but I bet, most of you already used it at some point. &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt; is one such generic type and it allows you to handle pretty much any type, make a list of it and use the "List-Methods" no matter, what type the list is made of. &lt;br&gt;
The benefit over an untyped ArrayList is, that you know, what type you are working with as soon, as you create the &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt; and only objects of that type T are allowed in the list. And even better, the compiler checks this for you. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember: The compiler is your friend, not your enemy. All it wants, is to protect you from doing mistakes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But lets show you, how I did multiple Singletons with the same "base class" using generics and then go over the details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;abstract&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;GenericSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;GenericSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nf"&gt;GenericSingleton&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;Instance&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="nf"&gt;Create&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Type&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Reflection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindingFlags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instance&lt;/span&gt; &lt;span class="p"&gt;|&lt;/span&gt;
                &lt;span class="n"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Reflection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BindingFlags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NonPublic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;constructor&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetConstructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EmptyTypes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Invoke&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FirstSingleton&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;GenericSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;FirstSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;FirstSingleton&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt; &lt;span class="c1"&gt;//make sure it cannot be instantiated by using new()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnotherSingleton&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;GenericSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;AnotherSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;AnotherSingleton&lt;/span&gt;&lt;span class="p"&gt;(){}&lt;/span&gt; &lt;span class="c1"&gt;//make sure it cannot be instantiated by using new()&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//access it like this&lt;/span&gt;
&lt;span class="n"&gt;FirstSingleton&lt;/span&gt; &lt;span class="n"&gt;firstSiglenton&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;FirstSingleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;AnotherSingleton&lt;/span&gt; &lt;span class="n"&gt;anotherSingleton&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;AnotherSingleton&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first thing to recognize are the pointy brackets. Already in the first line there is the &lt;code&gt;GenericSingleton&amp;lt;T&amp;gt;&lt;/code&gt; which means, that the class expects a generic type for instantiation much like the &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;br&gt;
Different from &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt;, which works with all types, is the &lt;code&gt;where T : GenericSingleton&amp;lt;T&amp;gt;&lt;/code&gt;. I put a type constraint to T, and therefore restrict the types, that can be used as T to &lt;code&gt;GenericSingleton&amp;lt;T&amp;gt;&lt;/code&gt;. This might look weird at the beginning, but it basically restricts the types for T to derived classes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And why the &lt;code&gt;&amp;lt;T&amp;gt;&lt;/code&gt; again?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Very good question! When creating a generic type, the type is not yet "complete". When you call &lt;code&gt;new List&amp;lt;int&amp;gt;()&lt;/code&gt; you create a new type on the fly. In the same matter &lt;code&gt;GenericSingleton&amp;lt;T&amp;gt;&lt;/code&gt; is not yet fully complete and &lt;code&gt;GenericSingleton&amp;lt;FirstSingleton&amp;gt;&lt;/code&gt; is a different type than &lt;code&gt;GenericSingleton&amp;lt;AnotherSingleton&amp;gt;&lt;/code&gt;. Even though they are written in one class, they are different types.&lt;/p&gt;

&lt;p&gt;This "on the fly type creation" is, what makes &lt;code&gt;public static T Instance { get; } = Create();&lt;/code&gt; possible in the first place.&lt;br&gt;
Static properties are the same over all instances of the class. Which makes sense, because they are not part of any object (instance of the class) but of the type itself.&lt;/p&gt;

&lt;p&gt;So, if the property would belong to &lt;code&gt;GenericSingleton&lt;/code&gt;, it would always have the same value. And if you created multiple singletons one after another, then (at the end) it would be an instance of the last type you created. &lt;strong&gt;BUT&lt;/strong&gt; since it belongs to &lt;code&gt;GenericSingleton&amp;lt;T&amp;gt;&lt;/code&gt; and you have a new base class for each derived class just by creating a new derived class, it is unique for each derived class.&lt;/p&gt;

&lt;p&gt;At last, there is the method &lt;code&gt;private static T Create()&lt;/code&gt;, which contains the "magic".... well it is not magic, but reflection. It circumvents the private constructors of the derived classes, which are there to make sure, the intended singletons cannot be instantiated with new().&lt;br&gt;
Line by line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;typeof(T)&lt;/code&gt; is our derived singleton's class, which is known, since the class takes it as generic argument.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;flags&lt;/code&gt; describe a non-public (method or property) which belongs to the instance and not the type. The constructor in question is &lt;code&gt;private&lt;/code&gt; and therefore non-public and it belongs to the instance. A static constructor or the static property &lt;code&gt;Instance&lt;/code&gt; would have belonged to the type, but lets not get distracted.&lt;/li&gt;
&lt;li&gt;We have the type of our class and the know the binding flags of the constructor we want to execute. So in the next line, we get the constructor from the type,&lt;/li&gt;
&lt;li&gt;which is invoked in the next line. But the Invoke(...) does return an object,
&lt;/li&gt;
&lt;li&gt;so in the last line, we cast the object to the type of our Derived Class and return it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am hoping, I was able to bring you generics a bit closer. This is a pretty special case of using them with singletons but it also shows some of the underlaying behavior of generics in .NET as well.&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is programming?</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Mon, 23 Sep 2019 22:14:52 +0000</pubDate>
      <link>https://dev.to/andreasjakof/what-is-programming-33oe</link>
      <guid>https://dev.to/andreasjakof/what-is-programming-33oe</guid>
      <description>&lt;h3&gt;
  
  
  What is programming?
&lt;/h3&gt;

&lt;p&gt;This is a question I am asking my self from time to time. Usually followed by...&lt;/p&gt;

&lt;h3&gt;
  
  
  What skills make a good programmer?
&lt;/h3&gt;

&lt;p&gt;I am doing this for a while now, and so far I came up with some answers for myself, which I would like to share and discuss with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Algorithmic thinking "...the rest is just syntax"
&lt;/h2&gt;

&lt;p&gt;Programming is not just &lt;em&gt;knowing a programming language&lt;/em&gt;. To me, a big part of it is algorithmic thinking. The rest is just syntax, which might differ from language to language, but has at least similar results in the end.&lt;/p&gt;

&lt;p&gt;I often use an analogy of talking to a person, that knows only it's own language and no other. A person, who will follow any and all of your instructions true to the word, but does neither deviate nor has any own initiative. Which means, that you have to be concise and complete.&lt;/p&gt;

&lt;p&gt;I mean: You have to solve every bit of the problem (at least in theory) and then tell the computer how you would do it in a way, that enables it to &lt;strong&gt;solve the problem using only your description&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Breaking big problems into smaller ones
&lt;/h2&gt;

&lt;p&gt;Algorithmic thinking is all good, but what if the problem too complex to be solved straight on? You have to be able, to break a big/complex problem into smaller pieces. &lt;/p&gt;

&lt;p&gt;Let's take a closer look at the often used example of spreading butter on a slice of bread. You could solve the problem as one... but that would limit re-useablity and you would be stuck with always the same ingredients: always toast, always butter. Also it is kind of a repetitive task, moving the knife back and forth. &lt;/p&gt;

&lt;p&gt;But what if, you could identify different sub-problems?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Preparing the bread&lt;/li&gt;
&lt;li&gt;Opening the butter cup&lt;/li&gt;
&lt;li&gt;Spreading "something spreadable" on "something" using a "spreader"

&lt;ul&gt;
&lt;li&gt;moving the spreader with slight pressure (from left to right)&lt;/li&gt;
&lt;li&gt;moving the spreader with slight pressure (from right to left)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The whole task now consists of three smaller tasks, which are also a bit more abstract, but can be used again, if something similar comes up.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Solving smaller problems, solves the big one
&lt;/h2&gt;

&lt;p&gt;If you have created manageable problems to solve, it time to do so. I think, the most important task here is to create the algorithm, that solves the problem at hand. And finding a balance between glueing it to that one case and having too much abstraction and complexity.&lt;/p&gt;

&lt;p&gt;I think, that as a rule of thumb: If you can think of another use case right off your head, there is a good chance you might use it in the future. If you have to think about it, just leave it be for the time or &lt;a href="https://martinfowler.com/bliki/Yagni.html"&gt;YAGNI&lt;/a&gt; will bite you. You can always come back later and make it more versatile, if you need it.&lt;/p&gt;

&lt;p&gt;In the butter spreading example this would be, to make the spreading independent of the flow direction, so one only has to write it once and then just call it with different directions: right-to-left and left-to-right. On thinking about it, there might be more parameters, like the pressure for different kinds of "spreadings": Peanut butter will take more pressure than jelly for example. &lt;br&gt;
But that could be added, when it is time.&lt;/p&gt;

&lt;p&gt;I guess the three traits above are the basis, for what is programming. Depending on the execution of these, you can determine the craftsman skills of a programmer. &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Art vs Craftsmanship
&lt;/h2&gt;

&lt;p&gt;But I think that programming is not only craftsmanship, where you use the tools you have but also art, where you create, think out of the box and come up with new and unique solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Experience and Curiosity
&lt;/h2&gt;

&lt;p&gt;With time, you get to know your tools better and better. &lt;br&gt;
You learn the shortcuts of your IDE, the functions a framework provides, but you also learn the limitations of the framework. So you are no longer trying to solve it in dead ends, but you chose another road from the start. You learn, how to combine different tools and/or frameworks. &lt;br&gt;
But experience also leads to the danger of only using the paved roads. Doing the safe thing. So even with experience, I think an open mind and curiosity are two main factors, that make a good programmer. &lt;/p&gt;

&lt;h2&gt;
  
  
  6. Willingness to learn and allowing for failure
&lt;/h2&gt;

&lt;p&gt;There are times, when you have to deliver. Times, when there is a deadline and every one is counting on you to be ready, when you have to. These are the times, when you choose the safe road. &lt;/p&gt;

&lt;p&gt;And then there are times, when you have time to play around with ideas, to invent and to learn. I think, it is an essential trait of a good programmer, to use those times and learn. But as with every unknown, this has the potential to failure, so a good programmer allows for failure and takes them into account. And a good programmer also learns from those failures, and if it is just, how not to approach a specific problem in the future...&lt;/p&gt;

&lt;p&gt;As a synopsis: I think programming is not the writing of code in a programming language, but the breaking down of complex problems into manageable portions, solving them and putting them together in away, to solve the bigger issue. &lt;br&gt;
Also I think a good programmer uses his/her experience and creativity to solve unique problems and is always trying to learn something new, allowing for failure but learning from it. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>CronJob-Expressions (Automate Tasks in Azure)</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Mon, 23 Sep 2019 09:28:03 +0000</pubDate>
      <link>https://dev.to/andreasjakof/cronjob-expressions-automate-tasks-in-azure-2j80</link>
      <guid>https://dev.to/andreasjakof/cronjob-expressions-automate-tasks-in-azure-2j80</guid>
      <description>&lt;p&gt;This post is mostly for me to remember and to look it up, when I need it again, but I hope, you might find it usefull as well.&lt;/p&gt;

&lt;p&gt;There are tasks, which are run repeatedly over and over again. One of the most common might be a cleanup job for a database. &lt;/p&gt;

&lt;p&gt;I personally prefer events, when something happens, but sometimes you do not have an event, and that is, when you need to run tasks on a schedule. &lt;/p&gt;

&lt;p&gt;In Azure you basically have two options, to execute those:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Azure WebJobs&lt;/li&gt;
&lt;li&gt;Azure Functions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The former runs as part of a WebApp for as long as it takes. The second runs "serverless" for a maximum of 10 minutes.&lt;/p&gt;

&lt;p&gt;Both, however, take a CronJob-Expression as their scheduling information. So here are some information about those.&lt;/p&gt;

&lt;p&gt;A CronJob-Expression is a string of mostly numbers and some literals describing the execution time/interval of a cron job in the following format:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;second&lt;/code&gt; &lt;code&gt;minute&lt;/code&gt; &lt;code&gt;hour&lt;/code&gt; &lt;code&gt;day&lt;/code&gt; &lt;code&gt;month&lt;/code&gt; &lt;code&gt;day of the week&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Each of those data entries will create a set of restrictions to the time of execution and the result will be the combination of all those sets. &lt;/p&gt;

&lt;p&gt;The rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There is no empty set. If you don't want it to run, just don't schedule it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;,&lt;/code&gt; is used to list single data entries e.g. 1,5,7,35&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-&lt;/code&gt; is used to list an inclusive range e.g. 1-5 = 1,2,3,4,5&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;*&lt;/code&gt; is used to set the value to "any". &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/&lt;/code&gt; sets an interval for the reoccurence. &lt;em&gt;No lists or ranges for reoccureances.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Literals &lt;code&gt;MON&lt;/code&gt;, &lt;code&gt;TUE&lt;/code&gt;, &lt;code&gt;WED&lt;/code&gt;, &lt;code&gt;THU&lt;/code&gt;, &lt;code&gt;FRI&lt;/code&gt;, &lt;code&gt;SAT&lt;/code&gt;, &lt;code&gt;SUN&lt;/code&gt; can be used for the day of the week. &lt;em&gt;No Range, when using literals. Use 0-6 instead, starting with SUN = 0.&lt;/em&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Lets have a look some examples:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Expression&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0 * * * * *&lt;/td&gt;
&lt;td&gt;Every minute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 1/2 * * * *&lt;/td&gt;
&lt;td&gt;Every other minute&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;*/1 * * * * *&lt;/td&gt;
&lt;td&gt;Every second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 * * * *&lt;/td&gt;
&lt;td&gt;Every hour&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 * * *&lt;/td&gt;
&lt;td&gt;Every day&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 30 11 * * *&lt;/td&gt;
&lt;td&gt;Every day at 11:30:00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 5-10 * * *&lt;/td&gt;
&lt;td&gt;Every hour between 5 to 10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 * * SAT&lt;/td&gt;
&lt;td&gt;Every saturday&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 * * 6&lt;/td&gt;
&lt;td&gt;Every saturday&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 * * 1-5&lt;/td&gt;
&lt;td&gt;Every workday (Monday to Friday)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 * * SAT,SUN&lt;/td&gt;
&lt;td&gt;Every saturday and sunday&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 1 1 *&lt;/td&gt;
&lt;td&gt;Every year 1st january&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0 0 0 1-7 * SAT&lt;/td&gt;
&lt;td&gt;Every first saturday of the month at 00:00:00&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Lets have a closer look at some of these:&lt;br&gt;
&lt;code&gt;0 1/2 * * * *&lt;/code&gt;:&lt;br&gt;
The seconds are &lt;code&gt;0&lt;/code&gt; -&amp;gt; only at full minutes.&lt;br&gt;
The first time to execute, the minute must be &lt;code&gt;1&lt;/code&gt; and after that every other minute &lt;code&gt;/2&lt;/code&gt;.&lt;br&gt;
All other entries can have any value -&amp;gt; every hour at every day.&lt;br&gt;
It runs every odd minute.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*/1 * * * * *&lt;/code&gt;:&lt;br&gt;
This could have been written also &lt;code&gt;* * * * * *&lt;/code&gt; and will be executed every second until it is stopped.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;0 0 0 1-7 * SAT&lt;/code&gt;:&lt;br&gt;
That one is bit more interesting.&lt;br&gt;
It exutes only at midnigth, since the parts that describe the time of the day are all set to zero. Execution is also restricted to the days within the range 1 through 7 (the first week) of the month and to Saturdays. To rephrase that a bit,  it will be executed at midnight of every Saturday within the first week of every month.&lt;/p&gt;

&lt;p&gt;When scheduling in Azure keep in mind, that times are given in UTC.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Reducing downtime using Azure Deployment-Slots</title>
      <dc:creator>Andreas Jakof</dc:creator>
      <pubDate>Fri, 20 Sep 2019 12:32:57 +0000</pubDate>
      <link>https://dev.to/andreasjakof/reducing-donwtime-using-azure-deployment-slots-2h12</link>
      <guid>https://dev.to/andreasjakof/reducing-donwtime-using-azure-deployment-slots-2h12</guid>
      <description>&lt;p&gt;Disclaimer:&lt;br&gt;
We have a (mostly) pure Microsoft environment. Having lots of virtual Windows Servers with IIS on them, serving our intranet pages. I don't know, if there is anything like WebDeploy with other Servers/IDEs.&lt;/p&gt;

&lt;p&gt;There are several ways to deploy to the IIS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebDeploy &lt;a href="https://blogs.msdn.microsoft.com/ericparvin/2018/05/31/install-and-configure-web-deploy-on-iis/"&gt;If you never used it, read this!&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;FTP&lt;/li&gt;
&lt;li&gt;Copy &amp;amp; Paste&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They all are pretty simple and they all have the same drawback.&lt;br&gt;
When you deploy, there is a downtime to your site. This might be okay, when deploying a WebSite, but when you have a heavily used API, you want to keep downtime to the absolut minimum. Preferably Zero, because you never know, when the next request will come. With bad timing it will be in the exact 500ms it took you to deploy the app.&lt;/p&gt;

&lt;p&gt;I dont know an easy way around it, besides having a load balancer (or something similar) in front and at least two IIS instances.&lt;br&gt;
But, with Azure, you have something called "Deployment Slots" and they come in handy.&lt;/p&gt;

&lt;p&gt;You deploy to a deployment slot and (if configured) an automatic swap takes place. Your app is spun up and if successful, all new requests to your site/API are redirected to your new copy. As soon, as all requests to the old app are fulfilled, it is taken down and your new app is there to answer requests alone.&lt;/p&gt;

&lt;p&gt;How can you use a Deployment Slot?&lt;br&gt;
&lt;a href="https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots"&gt;Configure a slot&lt;/a&gt;, to your site.&lt;br&gt;
&lt;a href="https://blog.elmah.io/continuous-deployment-to-azure-in-visual-studio-team-service/"&gt;Deploy to it from your CD-Pipeline&lt;/a&gt; or any other way.&lt;/p&gt;

&lt;p&gt;If you want, configure the Auto Swap as well... done.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
