<?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 JJ on Medium]]></title>
        <description><![CDATA[Stories by JJ on Medium]]></description>
        <link>https://medium.com/@HKJ8?source=rss-db284623fff2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F3Zyv4_qkRfCUtVSYE7bHg.jpeg</url>
            <title>Stories by JJ on Medium</title>
            <link>https://medium.com/@HKJ8?source=rss-db284623fff2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:28:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HKJ8/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[Break It Down — Dealing with Complex Code]]></title>
            <link>https://medium.com/@HKJ8/break-it-down-dealing-with-complex-code-9313a246ea6b?source=rss-db284623fff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/9313a246ea6b</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-storage-blob]]></category>
            <dc:creator><![CDATA[JJ]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 14:56:54 GMT</pubDate>
            <atom:updated>2024-01-30T15:05:30.941Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Break It Down — Dealing with Complex Code</strong></h3><p>When I started as a developer, some tasks used to bamboozle me (some still do!). There was just so much to think about, I couldn’t get it all in my head at once.</p><p>Now I have the privilege of helping others who are early in their coding journey, I see the same thing happens. There’s only so much we can fit in our brains after all.</p><p>As with so many things in life, the key is to break things down.</p><p>I thought I’d demonstrate this by breaking down a moderately complex requirement where the answer isn’t a straight ‘copy and paste from the internet’.</p><p><strong>Requirement</strong></p><p>We have data in many Azure Blob Storage accounts. We need to find which storage account a blob is housed in, using just part of the key. The solution will rarely be used and if it starts being used more, we’ll think about it later.</p><p><strong>What to do?</strong></p><p>Of course, the first thing to do is to head to ChatGPT or StackOverflow. No point re-inventing the wheel.</p><p>ChatGPT (3.5) looks promising, but unfortunately it seems to be using an out of date version of the Azure.Storage.Blobs library. It understands what I’m asking, but even after a few regenerations, I can’t get a good response out of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TmeV82Ao315zUz4jYYQX1Q.png" /></figure><p>A further look around Google/ StackOverflow looks like we’ll have to ‘roll our own’.</p><p>So here are our requirements:</p><ul><li>We want to find a blob from a partial key</li><li>That blob could be in one of many accounts</li><li>We want the data as fast as possible, so it probably needs to be multi-threaded</li><li>We need to rattle this out quick!</li></ul><p>Hmm. This feels like a lot to take in.</p><p><strong>Break It Down</strong></p><p>Of course, there are many ways we can tackle this. We could start looking into Azure Functions, maybe a durable function, but this doesn’t require a lot of input, so lets just make a simple console.</p><p>How about we build it up in stages:</p><ul><li>Get a blob from a partial key on one storage account</li><li>Update that code to have a list of storage accounts and loop through</li><li>Parallelize the loop</li><li>Find a way to cancel all tasks once we have what we need</li></ul><p>NOTE: To get this to work, you will need to install the NuGet package <em>Azure.Storage.Blobs</em>. I’m going to assume you know how to get connection strings etc for Azure Blob Storage and call this class. We’re looking at more complex tasks. Although the code works, it’s really just to illustrate the process.</p><p><strong>Get a Blob From A Partial Key</strong></p><p>Very quickly, we can rob some code of the internet and get something up and running for this part.</p><pre>using Azure;<br>using Azure.Storage.Blobs;<br>using Azure.Storage.Blobs.Models;<br>using System.Collections.Concurrent;<br><br>namespace delme<br>{<br>    public class BlobFinder<br>    {<br>        public async Task&lt;string&gt; FindStorageAccountFromPartialKeyAsync(string blobConnectionString,<br>            string tableName,<br>            string partialKey)<br>        {<br>            string returnVal = &quot;&quot;;<br>            var partialKeyLower = partialKey.ToLower();<br><br>            BlobServiceClient blobServiceClient = new BlobServiceClient(blobConnectionString);<br><br>            var containerClient = blobServiceClient.GetBlobContainerClient(tableName);<br>            await containerClient.CreateIfNotExistsAsync();<br><br>            // Call the listing operation and return pages of the specified size.<br>            var resultSegment = containerClient.GetBlobsAsync()<br>                .AsPages(default, 1000);<br><br>            await foreach (Page&lt;BlobItem&gt; blobPage in resultSegment)<br>            {<br>                foreach (BlobItem blobItem in blobPage.Values)<br>                {<br>                    // TODO: Remove this!<br>                    Console.WriteLine(&quot;Blob name: {0}&quot;, blobItem.Name);<br><br>                    if (blobItem.Name.ToLower().Contains(partialKeyLower))<br>                    {<br>                        returnVal = $&quot;{containerClient.AccountName} / {blobItem.Name}&quot;;<br>                        break;<br>                    }<br>                }<br><br>                if (!String.IsNullOrEmpty(returnVal))<br>                {<br>                    break;<br>                }<br>            }<br><br>            return returnVal;<br>        }<br>    }<br>}</pre><p><strong>Pass In A List Of Storage Accounts And Loop Through</strong></p><p>Now to increase the complexity, all we need to do is pass in a list of connection strings instead of one and make a list of blob containers. Loop through and we are now looking at multiple storage accounts.</p><pre>public class BlobFinder<br>{<br> public async Task&lt;string&gt; FindStorageAccountFromPartialKeyAsync(string[] blobConnectionStrings, <br>  string tableName,<br>  string partialKey)<br> {<br>  string returnVal = &quot;&quot;;<br>  var partialKeyLower = partialKey.ToLower();<br><br>  List&lt;BlobContainerClient&gt; blobContainers = new List&lt;BlobContainerClient&gt;();<br><br>  foreach(var conn in blobConnectionStrings)<br>  {<br>   BlobServiceClient blobServiceClient = new BlobServiceClient(conn);<br>   var containerClient = blobServiceClient.GetBlobContainerClient(tableName);<br>   await containerClient.CreateIfNotExistsAsync();<br>   blobContainers.Add(containerClient);<br>  }<br><br>  <br>  foreach(var containerClient in blobContainers)<br>  {<br>   // Call the listing operation and return pages of the specified size.<br>   var resultSegment = containerClient.GetBlobsAsync()<br>    .AsPages(default, 1000);<br><br>   await foreach (Page&lt;BlobItem&gt; blobPage in resultSegment)<br>   {<br>    foreach (BlobItem blobItem in blobPage.Values)<br>    {<br>     // TODO: Remove this!<br>     Console.WriteLine(&quot;Blob name: {0}&quot;, blobItem.Name);<br><br>     if (blobItem.Name.ToLower().Contains(partialKeyLower))<br>     {<br>      returnVal = $&quot;{containerClient.AccountName} / {blobItem.Name}&quot;;<br>      break;<br>     }<br>    }<br><br>    if (!String.IsNullOrEmpty(returnVal))<br>    {<br>     break;<br>    }<br>   }<br><br>   if (!String.IsNullOrEmpty(returnVal))<br>   {<br>    break;<br>   }<br>  }<br><br>  return returnVal;<br> }<br>}</pre><p>It’s a step forward, but that could really chunk. We’re going to need to multi-thread it, or we could be waiting a long time for results.</p><p><strong>Parallelize The Loop</strong></p><p>Due to having awaits, we can’t use Parallel.ForEach, but we can use Parallel.ForEachAsync. We’re also going to need to change the return type to something we can guarantee being thread safe.</p><pre>public class BlobFinder<br>{<br> public async Task&lt;ConcurrentBag&lt;string&gt;&gt; FindStorageAccountFromPartialKeyAsync(<br>                string[] blobConnectionStrings, <br>  string tableName,<br>  string partialKey)<br> {<br>  ConcurrentBag&lt;string&gt; retVal = new ConcurrentBag&lt;string&gt;();<br>  var partialKeyLower = partialKey.ToLower();<br><br>  List&lt;BlobContainerClient&gt; blobContainers = new List&lt;BlobContainerClient&gt;();<br><br>  foreach(var conn in blobConnectionStrings)<br>  {<br>   BlobServiceClient blobServiceClient = new BlobServiceClient(conn);<br>   var containerClient = blobServiceClient.GetBlobContainerClient(tableName);<br>   await containerClient.CreateIfNotExistsAsync();<br>   blobContainers.Add(containerClient);<br>  }<br><br><br>  var options = new ParallelOptions()<br>  {<br>   MaxDegreeOfParallelism = 4<br>  };<br><br>  CancellationTokenSource source = new CancellationTokenSource();<br>  CancellationToken token = source.Token;<br><br><br>  await Parallel.ForEachAsync(blobContainers, options, async (containerClient, ct) =&gt;<br>   {<br>    // Call the listing operation and return pages of the specified size.<br><br>    var resultSegment = containerClient.GetBlobsAsync()<br>     .AsPages(default, 1000);<br><br>    await foreach (Page&lt;BlobItem&gt; blobPage in resultSegment)<br>    {<br>     foreach (BlobItem blobItem in blobPage.Values)<br>     {<br>      // TODO: Remove this!<br>      Console.WriteLine(&quot;Blob name: {0}&quot;, blobItem.Name);<br><br>      if (blobItem.Name.ToLower().Contains(partialKeyLower))<br>      {<br>       retVal.Add($&quot;{containerClient.AccountName} / {blobItem.Name}&quot;);<br>       break;<br>      }<br>     }<br><br>     if (retVal.Any())<br>     {<br>      break;<br>     }<br>    }<br>   });<br><br>  return retVal;<br> }<br>}</pre><p>This is great, but even when we find something, we’re going to keep searching the other accounts. We’ll need to put a stop to that.</p><p><strong>Cancel All Tasks Once We have What We Need</strong></p><p>This <a href="https://stackoverflow.com/a/70827899/852806">good post on StackOverflow</a> details about Task Cancelling ForEachAsync loops. It’ll work perfectly.</p><p>Now we just need to update our method to set a cancel in motion once we have what we need and ensure all the other loops finish at the first possible opportunity.</p><pre>public class BlobFinder<br>{<br> public async Task&lt;ConcurrentBag&lt;string&gt;&gt; FindStorageAccountFromPartialKeyAsync(string[] blobConnectionStrings, <br>  string tableName,<br>  string partialKey)<br> {<br>  ConcurrentBag&lt;string&gt; retVal = new ConcurrentBag&lt;string&gt;();<br>  var partialKeyLower = partialKey.ToLower();<br><br>  List&lt;BlobContainerClient&gt; blobContainers = new List&lt;BlobContainerClient&gt;();<br><br>  foreach(var conn in blobConnectionStrings)<br>  {<br>   BlobServiceClient blobServiceClient = new BlobServiceClient(conn);<br>   var containerClient = blobServiceClient.GetBlobContainerClient(tableName);<br>   await containerClient.CreateIfNotExistsAsync();<br>   blobContainers.Add(containerClient);<br>  }<br><br><br>  var options = new ParallelOptions()<br>  {<br>   MaxDegreeOfParallelism = 4<br>  };<br><br>  CancellationTokenSource source = new CancellationTokenSource();<br>  CancellationToken token = source.Token;<br><br>  try<br>  {<br>   await Parallel.ForEachAsync(blobContainers, options, async (containerClient, ct) =&gt;<br>   {<br>    ct = token;<br><br>    ct.ThrowIfCancellationRequested();<br><br>    // Call the listing operation and return pages of the specified size.<br>    var resultSegment = containerClient.GetBlobsAsync()<br>     .AsPages(default, 1000);<br><br>    await foreach (Page&lt;BlobItem&gt; blobPage in resultSegment)<br>    {<br>     ct.ThrowIfCancellationRequested();<br><br>     foreach (BlobItem blobItem in blobPage.Values)<br>     {<br>      await Task.Delay(300);<br><br>      ct.ThrowIfCancellationRequested();<br><br>      // TODO: Remove this!<br>      Console.WriteLine(&quot;Blob name: {0}&quot;, blobItem.Name);<br><br>      if (blobItem.Name.ToLower().Contains(partialKeyLower))<br>      {<br>       retVal.Add($&quot;{containerClient.AccountName} / {blobItem.Name}&quot;);<br>       source.Cancel();<br>      }<br>     }<br>    }<br>   });<br>  }<br>  catch (OperationCanceledException)<br>  {<br>   // ... (the cts was canceled) - do nothing<br>  }<br>  catch (Exception)<br>  {<br><br>   throw;<br>  }<br><br>  return retVal;<br> }<br>}</pre><p><strong>Conclusion</strong></p><p>So there we have it, breaking down a complex task into small chunks. You can follow this style of process with just about anything. It’s much easier on the brain than going straight to solution.</p><p>Hopefully, seeing it in action helps you with something you work on in the future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9313a246ea6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How hard is it to pass the 70–483 C# Exam?]]></title>
            <link>https://medium.com/@HKJ8/how-hard-is-it-to-pass-the-70-483-c-exam-63df183e8338?source=rss-db284623fff2------2</link>
            <guid isPermaLink="false">https://medium.com/p/63df183e8338</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[JJ]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 16:29:48 GMT</pubDate>
            <atom:updated>2019-06-27T07:56:50.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*57j81M60MP_GDtVeWrmPpQ.png" /></figure><p>I have spent years debating whether to bother with the <a href="https://www.microsoft.com/en-us/learning/exam-70-483.aspx">70–483</a> C# Exam.</p><p>Back in the old days, the test was very crude. People could get cheat sheets, so just had to remember A,B,A,D,A,A,C etc. As a result, it’s reputation was a little tarnished. The exam is now more intelligent and the questions vary from person to person, so there’s little chance of knowing what you’re going to be asked before you start (as far as I know anyway!).</p><p>In addition you used to have to retake the exam every 3 years! I <em>really </em>cant be faffed re-doing stuff I’ve already done (imagine having to redo your GCSE’s/A-Levels/Degree!), so I gave it a miss.</p><p>However, in 2016, Microsoft Announced that Certifications would <a href="https://blogs.technet.microsoft.com/uktechnet/2016/11/03/understand-the-big-changes-for-the-new-streamlined-microsoft-technical-certifications/">no longer expire</a> and I became interested.</p><p>This year, my new years resolution was to stop <em>always</em> chasing the <a href="https://www.youtube.com/watch?v=5m7recXsEKo">shiny-shiny</a> and do something I didn’t really care about to completion. Doing boring tasks isn’t a strong point for me, but I’m actively aiming to improve. This seemed like a positive thing to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*4ZRllu7Bbt670mEq8aFMAw.png" /></figure><p>After a while where I didn’t have the time, I finally got the chance to gear up and do the exam — and passed first time (woo hoo!). Here’s what I did and what I would recommend. NONE of the links are affliate links. They are here only to help.</p><p><strong>Note: I really didn’t want to fail, so you will probably be able to get away with less than this.</strong></p><h4>MeasureUp Practice Tests</h4><p>Whatever you do; Get the practice exam from <a href="https://www.measureup.com/catalogsearch/result/?cat=&amp;q=+70-483">MeasureUp</a> .</p><p>I would argue that no matter how good you are at C#, nothing can really prepare you for the nit-picky questions the exam asks like the practice exams.</p><p>In fact, to start with, I was downright angry at some of the questions. They just seemed to be frustratingly hard games of spot-the-difference. This was the worst in there (don’t let this put you off — I’ve picked it out the <em>absolute worst</em> on purpose — most are just fine).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*DdF5DPpiz0kvWms4rvpWqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*SwVdJoJp90zjQW6DSSGY1w.png" /></figure><p>However, in amongst the occasional bit of crap there’s actually some really good learning to be had. The answers provided by MeasureUp are clear and, most importantly, correct.</p><p>Just to prove I’m not a MeasureUp fanboi or in any way paid by them - their support is crap imo.</p><p>This was my main source of learning. I did all 180+ questions twice over. I set the questions to “show answers to incorrect results”, then read what was right, researched it if necessary, AND researched the <em>wrong</em> answers too. When I needed to expand on things I’d never needed (hello <a href="https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netframework-4.8">SemaphoreSlim</a>!), I Googled it and read the docs.</p><p>I also created a Console Application with lots of examples.</p><p>Couple of small points to mention - on the real exam, it’s more obvious which questions are multiple selection. Also, for multiple selection in the real exam, you get a point for each right selection, whereas MeasureUp is all or nothing. You need to watch out for multi selections — missing them is an easy way to lose points!</p><h4>Books</h4><p>I still like a book. The MeasureUp test references <a href="https://www.amazon.co.uk/C-7-0-Nutshell-Joseph-Albahari/dp/1491987650/ref=sr_1_1?keywords=C+sharp+in+a+nutshell&amp;qid=1561553170&amp;s=gateway&amp;sr=8-1">C# in a Nutshell</a> , though I plumped for <a href="https://www.amazon.co.uk/Exam-Ref-70-483-Programming-Miles/dp/1509306986/ref=sr_1_1?keywords=70-483&amp;qid=1561553262&amp;s=gateway&amp;sr=8-1">Exam Ref 70–483</a> (2nd Edition) which I leisurely read cover to cover over about 4 weeks.</p><p>The book starts with the Task Parallel Library - not exactly newbie friendly. So, if you are just starting with C#, I would recommend something like <a href="https://www.amazon.co.uk/Head-First-C-Jennifer-Greene/dp/1449343503/ref=sr_1_1?keywords=head+first+c%23&amp;qid=1561553405&amp;s=gateway&amp;sr=8-1">Head First C#</a> (4th edition comes out soon), or head over to (my beloved) <a href="https://www.pluralsight.com/">PluralSight</a> before you tackle this book. Either that, or start with one of the later sections of the book (about types, variables etc), then go back to the first.</p><p>The book is rightly critiqued on Amazon as having too many typo’s. For this reason, I would say you have to have a reasonable grounding before using it (especially in one part where “Asymmetric” is written in the place of “Symmetric” - Doh!). However, despite the typo’s it’s a <em>really good book</em>.</p><h4>What was the 70–483 C# exam like?</h4><p>When I booked the <a href="https://www.microsoft.com/en-us/learning/exam-70-483.aspx">exam</a>, I chose the “home online proctoring” option, so I could take it online from home rather than hike over to a test centre. This was a great thing to do, as I could do the test in complete comfort. There were lots of potential appointment times, day and night. I’d recommend it to anyone thinking about taking the exam.</p><p>Before you do the exam, they check your ID and your room (including ceiling!) via the webcam to make sure you haven’t sneaked any cheat sheets about. They even checked my glasses inside and out!</p><p>You get 120 minutes to answer 40 questions (+ 4 trial questions) which is more ample than you expect. I am not the quickest reader, so was concerned, but I was able to answer all the questions, then review all my answers within the time. I had made some mistakes, so <strong>reviewing your answers is well worth doing</strong>.</p><p>You can’t navigate back to previous questions for the 4 trial questions, but you can go back and forward on the real questions. This disparity was a little odd.</p><p>Some of the questions touch on things you will never ever ever ever EVERRR use as a developer, and this is still my slight grievance with the test… And seriously Microsoft — what is the obsession with crusty old ‘COM’ ffs? Still, a lot of the stuff is on topics you will use regularly (LINQ, Data Access, TPL, Inheritance, Encapsulation etc).</p><p>I’d like to pretend it was a breeze after all the effort I put in, but it was pretty tricky in parts. I don’t think it would have mattered how long I spent learning — it would have been tricky and probably would have depended a bit on the luck of the questions I got. It’s scored out of 1000 points, 700 being the pass and I got roughly 850. The test covered parts which neither the book nor the practice questions had touched on.</p><h4>So How Hard Is The C# Exam?</h4><p>Overall I would say it’s more tricky than hard, though you certainly need to keep in mind a lot of the .NET framework. Even after all my effort, I wouldn’t have been upset with myself had I failed. I would say it’s 75% knowledge, 20% knack, 5% luck that you get questions that suit you.</p><h4>How Long Does it take to pass the C# exam?</h4><p>For me:<br><strong>Procrastination:</strong> 7 years<br><strong>Time from deciding I would do it:</strong> 6 months 6 days<br><strong>Actual swatting time:</strong> <em>*2 months</em>* proper effort (outside of work + lunchtimes)<br><strong>Overall time: 7</strong> years 6 months?</p><p>As stated above, the exam is 120 minutes; 40 questions.</p><h4>Was it worth doing?</h4><p>In terms of Job eligability, I don’t know for sure. I can’t see how it could do any harm and hopefully it will do some good. As I’m self taught, it’s nice to have something to show I do actually have a bit of a clue what this coding stuff is about.</p><p>After my initial frustration at some of the questions, I planned to give it a good roasting in this post. However, even as a developer with 10+ years experience, <strong>I still learned enough good stuff to make it worth doing</strong>.</p><p>With a bit of luck, I’ll spend less time looking something up on StackOverflow only to find I’ve previousy upvoted the correct answer :).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*r_wT7zKVw_hcvNfR7v9Jkw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63df183e8338" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>