<?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: Edward Chen</title>
    <description>The latest articles on DEV Community by Edward Chen (@echen805).</description>
    <link>https://dev.to/echen805</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%2F233001%2F2338263f-fc8a-4c5f-baec-efb8a9364d61.png</url>
      <title>DEV Community: Edward Chen</title>
      <link>https://dev.to/echen805</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/echen805"/>
    <language>en</language>
    <item>
      <title>Weekly Quick Tips: AWS Lambda Deployments</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Tue, 31 Jan 2023 18:28:31 +0000</pubDate>
      <link>https://dev.to/echen805/weekly-quick-tips-aws-lambda-deployments-1gpj</link>
      <guid>https://dev.to/echen805/weekly-quick-tips-aws-lambda-deployments-1gpj</guid>
      <description>&lt;p&gt;Hello folks! Been real deep in AWS as I learn more about the services and today's tip comes straight from the AWS team that I have been working with! If you don't want to read the rest, here's the quick TL;DR:&lt;/p&gt;

&lt;p&gt;There's a known issue (as of 01/01/2023 is when we started dealing with it) with AWS Lambdas where &lt;strong&gt;even if the size is over the limit, &lt;em&gt;sometimes&lt;/em&gt;&lt;/strong&gt; it can still be deployed to your environments. The best way to ensure you never experience any issues is to be sure that you are under the size limit:&lt;/p&gt;

&lt;p&gt;250 MB for uncompressed data (including layers)&lt;sup&gt;1&lt;/sup&gt;&lt;br&gt;
50 MB for compressed data (including layers)&lt;/p&gt;




&lt;p&gt;Now here's an overview of some notes and tips that I learned from my investigation! First off, it doesn't matter if this is done via CloudFormation, CodePipeline or any of their services, it all eventually has to go through Lambdas and that is when you will hit your size issue. The error message will appear as something like so:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code uncompressed size is greater than max allowed size of 272629760. (Service: Lambda, Status Code: 400, Request ID: 99a3c30a-b444-4558-ba5f-13ce38922f5b)" (RequestToken: dc727a33-6f29-e240-1452-97c228fe2ad0, HandlerErrorCode: InvalidRequest)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The error message is pretty solid in that it immediately tells you that your code is larger than what they allow. However, welcome to the first obstacle that I encountered - depending on the OS and even how you unzip (GUI vs terminal), there's a slight size difference. Going with the terminal will show you the smallest size (command for that is &lt;code&gt;du -h&lt;/code&gt; which stands for disk usage) while the GUI can be larger. The difference is negligible but something to note if you are wondering why there is a size difference.&lt;/p&gt;

&lt;p&gt;Now comes to the biggest revelation (besides the known issue) that helped me solve my issue: AWS Lambda runtime environments have their own &lt;code&gt;aws-sdk&lt;/code&gt; so you do not need to include that in your packages. Let me repeat that: &lt;strong&gt;You do not need to include &lt;code&gt;aws-sdk&lt;/code&gt; in your packages.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For us, that immediately removed 80 MB and helped us well be under the limit. And then it took another couple weeks continuously talking to AWS support to determine that it is a known issue why even though we were over the size limit, we were still able to deploy sometimes. &lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;Sources:&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html"&gt;https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Just a friendly reminder: Don't stress about the layoffs!</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Thu, 19 Jan 2023 16:59:29 +0000</pubDate>
      <link>https://dev.to/echen805/just-a-friendly-reminder-dont-stress-about-the-layoffs-261l</link>
      <guid>https://dev.to/echen805/just-a-friendly-reminder-dont-stress-about-the-layoffs-261l</guid>
      <description>&lt;p&gt;Here's another Weekly Tip! Today's topic is going to be a quick one and relevant to our careers but not really technical. &lt;strong&gt;DON'T STRESS ABOUT THE LAYOFFS!&lt;/strong&gt;&lt;sup&gt;*&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8etyvowrbkokyb173h5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8etyvowrbkokyb173h5.png" alt="Image description" width="193" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is more geared towards those earlier in your careers as I have found that generally the Senior+ Engineers are still in high demand. For those of you that are starting your careers as a Software Engineer or have been in the industry for 1-3 years now, I'm sure you are concerned and have been following the news on the &lt;a href="https://www.cnbc.com/2023/01/18/tech-layoffs-microsoft-amazon-meta-others-have-cut-more-than-60000.html" rel="noopener noreferrer"&gt;layoffs&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;But this is just a friendly reminder to not stress about your outlook! Keep learning, stay curious and do not take any rejections personally. Instead of applying to a FAANG (or MAANGA if we want to keep it more topical), you can get your foot in the door by applying to smaller companies or even a consultant agency (be wary of these though. Do not accept if they ask you to pay for training) as that will expose you to different tech stacks and experiences! &lt;/p&gt;

&lt;p&gt;Also keep in mind that this could be a chance to reflect on yourself. Is this something that you want to do as a career or is it something that you enjoy more as a hobby? Would it be feasible to work as a Data Engineer even if you enjoy doing Front End work? You can spend some time to work on personal projects, figure out what you enjoy. Everyone has experienced (or are still experiencing) all the traumas from getting out of a global pandemic so give yourself a break. You earned it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fradtzsalzo92griiq7wm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fradtzsalzo92griiq7wm.png" alt="Image description" width="301" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;*&lt;/sup&gt; Of course take all of this with a grain of salt because I am a stranger on the internet and I do not know your situation. &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
      <category>css</category>
      <category>career</category>
    </item>
    <item>
      <title>Weekly Quick Tips: Pub/Sub vs Observer Pattern?</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Sat, 07 Jan 2023 18:48:05 +0000</pubDate>
      <link>https://dev.to/echen805/weekly-quick-tips-pubsub-vs-observer-pattern-2ele</link>
      <guid>https://dev.to/echen805/weekly-quick-tips-pubsub-vs-observer-pattern-2ele</guid>
      <description>&lt;p&gt;In my attempts to blog more, I am going to do weekly tips on stuff that I think would be helpful or interesting to know for beginners. I will probably link to other articles but the intention of Weekly Quick Tips is for something someone can read in &amp;lt;5 min and walk away with a general sense of "wow that was interesting" or "&lt;em&gt;nod&lt;/em&gt; good to know".&lt;/p&gt;

&lt;p&gt;So to start it off, let's talk about Pub/Sub vs Observer Pattern. They're similar but just slightly different!&lt;/p&gt;

&lt;p&gt;Starting off with the easier one, Observer Pattern. It's simple, there is a Subject that is being watched by many Observers. The Observers are subscribed to a Subject and eagerly wait for new information. There is a direct relationship between the Subject &amp;lt;-&amp;gt; Observer.&lt;/p&gt;

&lt;p&gt;Pub/Sub has a middle layer called message broker/event bus that allows for decoupling between the Publisher and Subscriber. So both the Publisher and Subscriber only talk to the message broker and the two are completely oblivious to each other's existence. &lt;/p&gt;

&lt;p&gt;You may ask, well what the heck - why would I want that? First off, the decoupling lets you minimize the risk of merge conflicts as people can work separately and since the two are independent of each other, if one happens to go down or encounters an issue it will not cause the other to immediately fail. Scaling can be easily done as well.&lt;/p&gt;

&lt;p&gt;Disadvantages? Well that independence is a double edged sword my friend. It also is harder to track logging when something goes wrong and you have to be very sure that the Publisher is sending the message, a way for the subscriber to notify the broker that it received the message and handling the communication between the two. With a traditional client &amp;lt;-&amp;gt; server like in an Observer pattern, an error can just bubble up directly and it is easier to follow. &lt;/p&gt;

&lt;p&gt;Thanks for tuning in, please feel free to comment if you have thoughts. At the end of the day, this is about learning so let's work together to help each other learn :D &lt;/p&gt;

&lt;p&gt;Sources: &lt;br&gt;
-&lt;a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern"&gt;https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern&lt;/a&gt;&lt;br&gt;
-&lt;a href="https://hackernoon.com/observer-vs-pub-sub-pattern-50d3b27f838c"&gt;https://hackernoon.com/observer-vs-pub-sub-pattern-50d3b27f838c&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>architecture</category>
    </item>
    <item>
      <title>What is OAuth 2.0?</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Wed, 05 Feb 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/echen805/what-is-oauth2-1c2m</link>
      <guid>https://dev.to/echen805/what-is-oauth2-1c2m</guid>
      <description>&lt;p&gt;First off, there's a lot of resources out there on what is the OAuth2 protocol and how it came to be. What I'm going to try to do is collect it all in this post including where it originated from and what's the future of it. Please feel free to comment if something is incorrect. After all, the best way to learn is to teach right?  &lt;/p&gt;

&lt;p&gt;If you want a TL;DR, as always scroll to the bottom.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what is the OAuth2 protocol?
&lt;/h3&gt;

&lt;p&gt;By definition, OAuth is a protocol that allows a resource owner to authorize clients to access a website or non-website server. This is important because it allows the resource owner to determine what areas the client can see which is convenient if you have proprietary or confidential IP. Typically, the authorization is granted via Access Tokens, an encrypted string that represents the granted permissions (or scopes). The API will then determine what scopes the client is authorized for and return back the data. For example, a Menu app would accept differing levels of authorization: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creating item (scope &lt;code&gt;read: item&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;deleting item (scope &lt;code&gt;delete: item&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;updating item (scope &lt;code&gt;update: item&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Within the OAuth 2.0 flow, there are the following roles that come into play. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Client&lt;/strong&gt;: The application that is requesting access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Owner/Server&lt;/strong&gt;: The entity that can grant access and the server that contains the protected resources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Authorization Server&lt;/strong&gt;: The server that authenticates whether or not the authorization grant is valid. If valid, an Access Token is granted.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GTykLpfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn2.auth0.com/docs/media/articles/protocols/oauth2-generic-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GTykLpfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn2.auth0.com/docs/media/articles/protocols/oauth2-generic-flow.png" alt="OAuth 2.0 diagram from Auth0" width="880" height="465"&gt;&lt;/a&gt;&lt;br&gt;
 This is taken from &lt;a href="https://auth0.com/docs/protocols/oauth2"&gt;Auth0's page on OAuth 2.0&lt;/a&gt; which I would highly recommend for further learning.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The Application (Client) asks for authorization from the Resource Owner in order to access the resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provided that the Resource Owner authorizes this access, the Application receives an Authorization Grant. This is a credential representing the Resource Owner's authorization.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Application requests an Access Token by authenticating with the Authorization Server and giving the Authorization Grant.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provided that the Application is successfully authenticated and the Authorization Grant is valid, the Authorization Server issues an Access Token and sends it to the Application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Application requests access to the protected resource by the Resource Server, and authenticates by presenting the Access Token.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provided that the Access Token is valid, the Resource Server serves the Application's request.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is a high level overview of the flow and each step can be explained in further detail, enough to constitute it's own page so I will remain general and elaborate into further detail in another page. However, an important aspect of OAuth 2.0 is to know how the authentication works. &lt;/p&gt;

&lt;p&gt;So first off, there is a difference between authentication and authorization. Authentication means that the entity has been validated to be who it claims to be. Authorization on the other hand refers to rules that determine who is allowed to do what. A good example of this is if you think of an application as a house. Authentication would be the owner of the house allowing Bob to enter the house. Once you have proven that you are Bob, you will be allowed to enter. Authorization in this case would be the owner telling Bob that he may enter the kitchen but not the master bedroom. &lt;/p&gt;

&lt;p&gt;Now that we have defined the two, it will make more sense that OAuth 2.0 is an &lt;em&gt;authentication&lt;/em&gt; protocol although due to scopes, it has some pseudo authorization aspects too. How the authentication works is that the protocol has two endpoints: Authorization and Token. What happens is that once a client has requested access to the resource server, the server will redirect the client to a consent screen where credentials can be entered. Assuming the credentials are valid, the client is given a response token and redirected back to the original page. I am sure you are familiar with this, this can be seen in many login screens where you can "Login via Facebook" or "Login via Github". Both of those options redirect you to the prospective login pages where you authorize the client's permission to access and then you are redirected back to the client. &lt;/p&gt;

&lt;p&gt;Depending on the Authorization flow, the response token can return back a Refresh Token as well. This is generally used by web applications that are server side so the source code is not exposed to the public. Since the code is not exposed to the public, in this flow the response token will contain &lt;code&gt;client_secret&lt;/code&gt;, &lt;code&gt;client_id&lt;/code&gt;, &lt;code&gt;scope&lt;/code&gt;, &lt;code&gt;state&lt;/code&gt;, &lt;code&gt;redirect_uri&lt;/code&gt;, &lt;code&gt;access_token&lt;/code&gt; and &lt;code&gt;refresh_token&lt;/code&gt;. So much information is exposed in this flow to allow a client and the resource server to interact with less, if any, user interaction. Given that information, the client can call the Authorization endpoint and use the &lt;code&gt;refresh_token&lt;/code&gt; to renew the &lt;code&gt;access_token&lt;/code&gt; since typically the &lt;code&gt;access_token&lt;/code&gt; has a shorter duration. For example, the access token can expire every 24 hours whereas the refresh token can expire every 100 days. &lt;/p&gt;

&lt;h3&gt;
  
  
  TL;DR &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Honestly, there is a lot of complexities and intricacies of OAuth 2.0. But Auth0 did an incredibly good job of simplifying a generic flow so I will just post their diagram here. They explain a lot of concepts easily and I did my best to summarize the information in a single page here for ease of use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GTykLpfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn2.auth0.com/docs/media/articles/protocols/oauth2-generic-flow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GTykLpfq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn2.auth0.com/docs/media/articles/protocols/oauth2-generic-flow.png" alt="OAuth 2.0 diagram from Auth0" width="880" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Sources:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://auth0.com/docs/protocols/oauth2"&gt;OAuth 2.0 Authorization Framework&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://oauth.net/about/introduction/"&gt;What is OAuth?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://auth0.com/docs/api-auth/which-oauth-flow-to-use"&gt;Which OAuth flow to use?&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>security</category>
      <category>beginners</category>
    </item>
    <item>
      <title>C# Dictionary: Add or [key]=value?</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Fri, 22 Nov 2019 07:33:06 +0000</pubDate>
      <link>https://dev.to/echen805/c-dictionary-add-or-key-value-2c17</link>
      <guid>https://dev.to/echen805/c-dictionary-add-or-key-value-2c17</guid>
      <description>&lt;p&gt;Recently I came across an interesting problem that threw me off initially. Now let me preface this with the fact that I have been using C# daily for almost three years now so I am by no means an expert like Jon Skeet but I am no beginner. If you want a TL;DR, as always scroll to the bottom.&lt;/p&gt;

&lt;p&gt;So the problem was pretty simple, print out a list of the number of occurrences in an array. &lt;/p&gt;

&lt;div class="highlight js-code-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;dict&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;Dictionary&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&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;nums&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;foreach&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;num&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&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;dict&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;TryGetValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="k"&gt;out&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)){&lt;/span&gt;
        &lt;span class="n"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;1&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;foreach&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;num&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Key: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Occurence: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num&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="s"&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;p&gt;This prints out what you would expect:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi2qw2jok898o94wtikh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fi2qw2jok898o94wtikh5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However when I tried to use the &lt;code&gt;[key]=value&lt;/code&gt; way, I got an error, the ever so common &lt;code&gt;KeyNotFoundException&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-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;dict&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;Dictionary&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&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;nums&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;foreach&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;num&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;foreach&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;num&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Key: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Occurence: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;num&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="s"&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;p&gt;That was odd to me because I had always thought that was equivalent to Add &lt;em&gt;or&lt;/em&gt; update. Of course I could have gone my merry way and taken a mental note to always use the Add method in combination with TryGetValue which would have caught the exception but by golly, I had to know I was not going insane here with such a simple task like adding a value to a dictionary. &lt;/p&gt;

&lt;p&gt;After digging into the reference source, the two look pretty identical.&lt;/p&gt;

&lt;div class="highlight js-code-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;void&lt;/span&gt; &lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TKey&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TValue&lt;/span&gt; &lt;span class="k"&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;true&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="n"&gt;TValue&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TKey&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&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="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FindEntry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&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;index&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;0&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;ThrowHelper&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ThrowKeyNotFoundException&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;set&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;false&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;p&gt;The only difference was the third argument but after taking a look at Insert, that is really only used to throw an exception if there is a duplicate Key. &lt;/p&gt;

&lt;p&gt;But then it dawned on me that I am &lt;a href="https://www.hanselman.com/blog/YakShavingDefinedIllGetThatDoneAsSoonAsIShaveThisYak.aspx" rel="noopener noreferrer"&gt;shaving the yak&lt;/a&gt; and I needed to take a step. Lo and behold, with that step back I realized that it was the operator precedence. The issue wasn't with the dictionary, it was with the &lt;code&gt;+=&lt;/code&gt; that I was doing. Because of that, the code was doing a get and then setting the value to an increment of plus one. However, the value doesn't exist which is where the KeyNotFound exception was thrown.&lt;/p&gt;

&lt;p&gt;Finally, I can push off the imposter syndrome for a little while longer. Thank you for reading and I hope everyone has fun programming!&lt;/p&gt;

&lt;h3&gt;
  
  
  TL;DR &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;First off, if I had checked StackOverflow first, I would have realized many people have thought of this and there's an excellent answer to this &lt;a href="https://stackoverflow.com/a/1841639" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;But to summarize, [key]=value is not really Add or Update in my case because of the order of precedence with operators. Due to &lt;code&gt;dict[num] += 1&lt;/code&gt;, the code is doing a &lt;code&gt;get&lt;/code&gt; on the &lt;code&gt;num&lt;/code&gt; value in the dictionary and throws an exception because the value does not exist. &lt;/p&gt;

</description>
      <category>csharp</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Akka.NET Bootcamp Notes: Unit 1.2 - Defining and Handling Messages</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Wed, 16 Oct 2019 01:27:01 +0000</pubDate>
      <link>https://dev.to/echen805/akka-net-bootcamp-notes-unit-1-2-defining-and-handling-messages-2f3a</link>
      <guid>https://dev.to/echen805/akka-net-bootcamp-notes-unit-1-2-defining-and-handling-messages-2f3a</guid>
      <description>&lt;p&gt;In an effort to reinforce my personal learning and summarize the wonderful Akka.NET bootcamp that is provided by Petabridge, I am going to cover each unit in a series as I go through it. I will continue to edit the page if the information is incorrect or not available. Since the topics can be complex, I will provide a &lt;strong&gt;TL;DR at the bottom&lt;/strong&gt; and sources for people who are interested in learning more. So let's get right into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a message
&lt;/h2&gt;

&lt;p&gt;I think Petabridge did a wonderful job of explaining a message so I am just going to put what they wrote below:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Any POCO can be a message. A message can be a string, a value like int, a type, an object that implements an interface... whatever you want.&lt;br&gt;
That being said, the recommended approach is to make your own custom messages into semantically named classes, and to encapsulate any state you want inside those classes"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In terms of sending and handling messages, you use the &lt;code&gt;Tell()&lt;/code&gt; method to send a message and how an actor handles the message is up to the developer. One thing to note is that if an actor receives a message that it cannot handle, the actor will choose to ignore it. Whether or not the ignored message is logged is dependent on the actor type (for example, an UntypedActor would not handle it unless defined but a ReceiveActor will automatically send it to Unhandled). When handling messages, the value of the sender is always in the receiving actor's &lt;code&gt;Sender&lt;/code&gt; property.  &lt;/p&gt;

&lt;p&gt;To organize the definitions of messages, it is recommended to put it in another file and reference the messages. A good example of the layout for Messages.cs would be something like this. This is taken from &lt;a href="https://github.com/petabridge/akka-bootcamp/blob/master/src/Unit-1/lesson2/Completed/Messages.cs"&gt;Akka.Net's Message.cs&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="cp"&gt;#region Neutral/system messages
&lt;/span&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Marker class to continue processing.&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;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;ContinueProcessing&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="cp"&gt;#endregion
&lt;/span&gt;
&lt;span class="cp"&gt;#region Success messages
&lt;/span&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Base class for signaling that user input was valid.&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;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;InputSuccess&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;InputSuccess&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;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Reason&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reason&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="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Reason&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="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;set&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="cp"&gt;#endregion
&lt;/span&gt;
&lt;span class="cp"&gt;#region Error messages
&lt;/span&gt;&lt;span class="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// Base class for signalling that user input was invalid.&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;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;InputError&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;InputError&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;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Reason&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reason&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="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Reason&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="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;set&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="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// User provided blank input.&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;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;NullInputError&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;InputError&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;NullInputError&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;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reason&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="c1"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;/// User provided invalid input (currently, input w/ odd # chars)&lt;/span&gt;
&lt;span class="c1"&gt;/// &amp;lt;/summary&amp;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;ValidationError&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;InputError&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;ValidationError&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;reason&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reason&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="cp"&gt;#endregion
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;TL;DR
&lt;/h2&gt;

&lt;p&gt;Messages and their types&lt;/p&gt;

&lt;p&gt;A message is the simplest object an actor can pass to encapsulate any state. Actors use messages to communicate between each other and how the actor handles the message is dependent on the actor (either ReceiveActor or UntypedActor). Messages should be separated into specific categorical classes.&lt;/p&gt;




&lt;h4&gt;
  
  
  Sources:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://getakka.net/articles/actors/receive-actor-api.html"&gt;Petabridge: ReceiveActor&lt;/a&gt;&lt;br&gt;
&lt;a href="https://getakka.net/articles/actors/untyped-actor-api.html"&gt;Petabridge: UntypedActor&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/petabridge/akka-bootcamp"&gt;Petabridge Akka.NET Bootcamp&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Akka.NET Bootcamp Notes: Unit 1 - Fundamentals of the Actor Model</title>
      <dc:creator>Edward Chen</dc:creator>
      <pubDate>Sun, 29 Sep 2019 16:47:56 +0000</pubDate>
      <link>https://dev.to/echen805/akka-net-bootcamp-notes-unit-1-fundamentals-of-the-actor-model-1km3</link>
      <guid>https://dev.to/echen805/akka-net-bootcamp-notes-unit-1-fundamentals-of-the-actor-model-1km3</guid>
      <description>&lt;p&gt;In an effort to reinforce my personal learning and summarize the wonderful Akka.NET bootcamp that is provided by Petabridge, I am going to cover each unit in the series as I go through it. I will continue to edit the page if the information is incorrect or not available. Since the topics can be complex, I will provide a &lt;strong&gt;TL;DR at the bottom&lt;/strong&gt; and sources for people who are interested in learning more. So let's get right into it!&lt;br&gt;
 &lt;/p&gt;

&lt;h1&gt;
  
  
  Unit 1.1 - How to create your own ActorSystem and actors
&lt;/h1&gt;

&lt;p&gt;What is the Actor model?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In an actor model, everything is an actor (similar to OOP) and each actor does one task&lt;/li&gt;
&lt;li&gt;Actors communicate via messages and message passing is asynchronous and immutable&lt;/li&gt;
&lt;li&gt;Actors pass the message to ActorReferences, not directly to actors. The ActorReferences take the messages and place them in a mailbox (Queue data structure meaning FIFO) and pushes the messages to OnReceive() when the actor is ready to process them. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foet5jhvqkw1wd287hf98.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foet5jhvqkw1wd287hf98.png" alt="Taken from Petabridge - What is an Actor article"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the guarantees of actors in Akka.NET is that an actor's context and internal state are always thread-safe when processing messages. This is because the messages are immutable and processed serially. &lt;br&gt;
Actors can have an internal state which means when an actor is destroyed or restarted, the actor instance is lost and a new instance is created via Props. This is important to know because an Actor's Life Cycle &lt;strong&gt;can&lt;/strong&gt; be rebooted whenever a problem is encountered:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb5n7220fuff88z7f07hp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fb5n7220fuff88z7f07hp.png" alt="Petabridge Actor Life Cycle"&gt;&lt;/a&gt;&lt;br&gt;
In the event an Exception is thrown, the actor's mailbox is retained and processed with the new actor instance.&lt;br&gt;
Every Actor has a Parent and Children&lt;br&gt;
An actor has to be created by another actor. This is important because an actor is restarted by it's parent (the terminology is Supervisor). Every parent comes with a default SuperviserStrategy object (but a user can define it's own strategy) that decides to either restart, stop or escalate to the grandparent actor. With a restart, all the children of the parent will be restarted as well. &lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a&gt;&lt;/a&gt;TL;DR
&lt;/h2&gt;

&lt;p&gt;Concurrency and Location Transparency.&lt;/p&gt;

&lt;p&gt;Since actors are lazy, cheap and single tasked, they can easily be scaled so even though you have one message per actor, you can have 10,000 actors -&amp;gt; 10,000 messages occurring at once. Due to messages being immutable and running asynchronously, this is really powerful. &lt;/p&gt;




&lt;h4&gt;
  
  
  Sources:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://petabridge.com/blog/akkadotnet-what-is-an-actor/" rel="noopener noreferrer"&gt;Petabridge: What is an Actor&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/petabridge/akka-bootcamp" rel="noopener noreferrer"&gt;Petabridge Akka.NET Bootcamp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>csharp</category>
      <category>softwareengineering</category>
      <category>actors</category>
    </item>
  </channel>
</rss>
