<?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>Forem: Ellie</title>
    <description>The latest articles on Forem by Ellie (@elliezub).</description>
    <link>https://forem.com/elliezub</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%2F1166509%2Fb70a92db-74b8-4d4a-bc1f-2a1e190d11c5.png</url>
      <title>Forem: Ellie</title>
      <link>https://forem.com/elliezub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/elliezub"/>
    <language>en</language>
    <item>
      <title>Using the Pieces SDK Copilot Wrapper in JavaScript</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Wed, 14 Aug 2024 19:02:51 +0000</pubDate>
      <link>https://forem.com/elliezub/using-the-pieces-sdk-copilot-wrapper-in-javascript-3am8</link>
      <guid>https://forem.com/elliezub/using-the-pieces-sdk-copilot-wrapper-in-javascript-3am8</guid>
      <description>&lt;p&gt;While participating in Global Hack Week, I noticed one of the &lt;a href="https://ghw.mlh.io/challenges" rel="noopener noreferrer"&gt;challenges&lt;/a&gt; (the Hello World using Pieces challenge) didn't have a walkthrough. So I decided to make a simple "how-to" for this challenge.&lt;/p&gt;

&lt;p&gt;In this article, we will be using the &lt;a href="https://docs.pieces.app/build/reference/typescript/" rel="noopener noreferrer"&gt;TypeScript SDK&lt;/a&gt; to ask Pieces this question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is the most common first project for software devs? (hint it starts with hello and ends with world)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then we will log Pieces' response to the console. Also, even though we are using the TypeScript SDK, this challenge will be completed using JavaScript. So even if you don't know TypeScript you can try to make some simple projects using the Pieces SDK😄 &lt;/p&gt;

&lt;p&gt;There are also Python, Dart, and Kotlin SDKs, which can be implemented similarly. If you find anything confusing, you can always check the &lt;a href="https://docs.pieces.app/build/" rel="noopener noreferrer"&gt;Pieces build docs&lt;/a&gt;, &lt;a href="https://github.com/mason-at-pieces" rel="noopener noreferrer"&gt;Mason's SDK repos&lt;/a&gt;, or ask for help in the &lt;a href="https://discord.com/invite/getpieces" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the Pieces SDK with a Copilot Wrapper
&lt;/h2&gt;

&lt;p&gt;Here, we will use a Copilot wrapper (which simplifies the interaction with the Pieces SDK) to ask a simple question and log the response to the console. The only prerequisite is that you have &lt;a href="https://pieces.app/?utm_source=learnpiecessdk&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=ellie-partner" rel="noopener noreferrer"&gt;Pieces&lt;/a&gt; installed on your device. &lt;/p&gt;

&lt;p&gt;Start by installing Pieces SDK:&lt;br&gt;
&lt;code&gt;npm install pieces-copilot-sdk&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then we need to require the Pieces SDK:&lt;br&gt;
&lt;code&gt;const { PiecesClient } = require('pieces-copilot-sdk');&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, create an instance of PiecesClient:&lt;br&gt;
&lt;code&gt;const piecesClient = new PiecesClient({ baseUrl: 'http://localhost:1000' });&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The baseURL will be localhost:1000 for mac/windows but for Linux users it is localhost:5323 (so just make sure you have the right one!)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With the client set up, we can now write a function to ask Pieces a question using the &lt;code&gt;askQuestion()&lt;/code&gt; method provided by the Pieces SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;askPieces&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;piecesClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;askQuestion&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;What is the most common first project for software devs? 
(hint it starts with hello and ends with world)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&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;askPieces&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this function, the &lt;code&gt;askQuestion()&lt;/code&gt; method takes a single parameter, the question you want to ask. The response is logged to the console, and any errors are caught and printed.&lt;/p&gt;

&lt;p&gt;This method provides a straightforward way to interact with the Pieces API using a wrapper. Also, if you are just trying to complete the challenge for Hack Week, this would be totally acceptable!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are interested in learning about the underlying implementation for the &lt;code&gt;askQuestion&lt;/code&gt; endpoint check out the &lt;a href="https://github.com/mason-at-pieces/pieces-copilot-typescript-sdk/blob/main/index.ts" rel="noopener noreferrer"&gt;index.ts file&lt;/a&gt; from the wrapper SDK code&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, if you would like to try and use the Pieces SDK without the wrapper, check out the next article in this &lt;strong&gt;Learn Pieces SDK with me&lt;/strong&gt; series👀&lt;/p&gt;

&lt;h2&gt;
  
  
  Console Output
&lt;/h2&gt;

&lt;p&gt;In the console you should see a response similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The most common first project for software developers is the "Hello, World!" program. 
It is a simple program that outputs or displays the text "Hello, World!" to the user. 
This project is often used as a beginner's introduction to programming languages and serves as a way to verify that the development environment is set up correctly.
Here is an example of a "Hello, World!" program in Python:

print("Hello, World!")

This project is a great starting point for beginners to get familiar with the syntax and structure of a programming language.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Well, that's it for this article. I would love to start building some cool projects with the Pieces SDK, do you have any suggestions? &lt;/p&gt;

&lt;p&gt;Whatever I build will be turned into a tutorial and added to this article series, so we can all learn together😄&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ai</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>20 Coffee Chats in 2 Weeks: Here's What Happened</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Fri, 09 Aug 2024 20:07:05 +0000</pubDate>
      <link>https://forem.com/elliezub/20-coffee-chats-in-2-weeks-heres-what-happened-11em</link>
      <guid>https://forem.com/elliezub/20-coffee-chats-in-2-weeks-heres-what-happened-11em</guid>
      <description>&lt;p&gt;A while back I made a post on X that would end up changing my life! (I know so dramatic, but seriously tho) &lt;/p&gt;

&lt;p&gt;Let’s go back in time:&lt;br&gt;
&lt;iframe class="tweet-embed" id="tweet-1786758429018587344-836" src="https://platform.twitter.com/embed/Tweet.html?id=1786758429018587344"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1786758429018587344-836');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1786758429018587344&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;I asked if anyone was interested in having a coffee chat, and I didn’t know that after posting this I would end up scheduling about 25 coffee chats within the following 2-3 weeks. I knew it would be a bit overwhelming, but at the time I was feeling pretty motivated so decided to just go for it.&lt;/p&gt;

&lt;p&gt;Before we get into what happened, I should probably tell you what a coffee chat is, right? &lt;/p&gt;

&lt;h2&gt;
  
  
  First, What is a Coffee Chat?
&lt;/h2&gt;

&lt;p&gt;A coffee chat is (usually) a 30-minute video chat with another developer (or person in tech). You could be both junior devs trying to break into tech, or you could be on totally opposite ends of the spectrum. &lt;/p&gt;

&lt;p&gt;Then, you can chat about tech, life, what you're building, really anything! And the purpose is to make new friends, connect with people you've talked to online but never face to face &amp;amp; network (although, I don't really like the word network anymore).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Going into the coffee chat with the intention of &lt;strong&gt;making a new friend&lt;/strong&gt; is really the key point here, please don't go into these expecting the person to give you a job, rather, think "how can I help this person?" &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(and no &lt;strong&gt;you don't really need to drink coffee&lt;/strong&gt;, but if you do this many chats in a short time period you may want to consider it😅)&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of doing Coffee Chats
&lt;/h2&gt;

&lt;p&gt;Now that we know what a coffee chat is, let's get into what happened during these 2~ weeks and the awesome benefits! &lt;/p&gt;

&lt;h3&gt;
  
  
  Communication Skills
&lt;/h3&gt;

&lt;p&gt;I remember when I first started using X (at the time it was called Twitter😭), &lt;strong&gt;I was too scared to even speak in a space&lt;/strong&gt; (shoutout to &lt;a href="https://x.com/ShawnBasquiat" rel="noopener noreferrer"&gt;Shawn Charles&lt;/a&gt; for telling me to grab the mic and get over that fear!). Back then, I definitely would have been scared of doing a coffee chat.&lt;/p&gt;

&lt;p&gt;After a while, I started doing a few coffee chats (maybe 1 or 2 a month?). Soon after, I realized that I wasn't even getting nervous before the coffee chats (or even live streams).&lt;/p&gt;

&lt;p&gt;If you're someone who's anxious or shy, &lt;strong&gt;this is a great way to practice communicating with other people&lt;/strong&gt; and reducing anxiety around that. Then later on when you go into interviews or have to give presentations at work, it will be SO much easier.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect with the Community
&lt;/h3&gt;

&lt;p&gt;One of the coolest parts about coffee chats is the fact that you get to &lt;strong&gt;connect with new people in the tech community&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;When I was doing all those coffee chats, I had the pleasure of meeting &lt;a href="https://x.com/sophiairoegbu_" rel="noopener noreferrer"&gt;Sophia Iroegbu&lt;/a&gt; during a coffee chat (one of the coolest people on X btw!). We got to talk about ALL kinds of things, but mainly we realized that we both started out in tech as technical writers. &lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrscaf703rbfal04illk.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrscaf703rbfal04illk.jpg" alt="Picture of me and Sophia"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During our chat she told me that she had written some articles for a company called &lt;a href="https://pieces.app/?utm_source=coffeechatarticle&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=ellie-partner" rel="noopener noreferrer"&gt;Pieces&lt;/a&gt;. (At that time I didn't know much about Pieces). She also told me about how her technical writing ended up turning into a devrel internship at Pieces. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Now, Sophia is doing an internship at &lt;a href="https://www.leaddevrel.com/" rel="noopener noreferrer"&gt;Lead DevRel&lt;/a&gt; as a Developer Advocate. She is mainly focused on community building and creating unique developer experiences through &lt;a href="https://www.youtube.com/@sophyiairoegbu" rel="noopener noreferrer"&gt;videos&lt;/a&gt; and &lt;a href="https://sophyia.me/" rel="noopener noreferrer"&gt;articles&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I mentioned to her that Pieces had actually reached out to me about a social partner program, and she really recommended that I do it, and if possible I should write some articles for them.&lt;/p&gt;

&lt;p&gt;After this conversation, I was definitely inspired (btw getting inspired is probably one of the biggest benefits of doing coffee chats). &lt;/p&gt;

&lt;h3&gt;
  
  
  Career Benefits
&lt;/h3&gt;

&lt;p&gt;After my coffee chat with Sophia, I reached back out to Pieces about the social partner program they had DM’d me about on X, and ended up getting on a call with &lt;a href="https://x.com/Rosie_at_Pieces" rel="noopener noreferrer"&gt;Rosie&lt;/a&gt; (Pieces' Chief Customer Officer)&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqagdd6mr31l10qz8gyt.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqqagdd6mr31l10qz8gyt.png" alt="Picture of me and Rosie, CCO at Pieces"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Talking to Rosie was so much fun that it made me want to learn more about Pieces &amp;amp; hopefully work with them in some capacity.&lt;/p&gt;

&lt;p&gt;After this, I ended up becoming a social partner and I got to have a chat with the CEO of Pieces, &lt;a href="https://x.com/KnottTsavo" rel="noopener noreferrer"&gt;Tsavo&lt;/a&gt;! Pretty cool right? &lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fec5twknclrhb998475ne.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fec5twknclrhb998475ne.png" alt="Picture of me and Tsavo, CEO at Pieces"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During this chat we talked about Pieces and I also shared some of my first impressions when using the product. It was awesome to see how passionate and open to feedback he was! &lt;/p&gt;

&lt;p&gt;A few weeks after this chat, &lt;strong&gt;Rosie contacted me and asked if I was interested in joining the team as a Developer Advocate&lt;/strong&gt;. Of course, I was elated and said yes!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExMXd4YzY2b3phZ24wZnUwdWp1M3d3aHJoMW00MWNsaGtmdmQycnU3NiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/4SvfE8adjXNsIlJP61/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExMXd4YzY2b3phZ24wZnUwdWp1M3d3aHJoMW00MWNsaGtmdmQycnU3NiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/4SvfE8adjXNsIlJP61/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Literally my reaction after she asked me☝️&lt;/p&gt;

&lt;h3&gt;
  
  
  Moral of the Story
&lt;/h3&gt;

&lt;p&gt;If you haven't figured it out already.. What's really cool about this story is that one random coffee chat with Sophia eventually led to landing an offer as a developer advocate at Pieces. And it pretty much all stemmed from that one tweet (kinda crazy right?).&lt;/p&gt;

&lt;p&gt;So, hopefully I've convinced you that doing coffee chats is worth it and can lead to friendships and unexpected opportunities. Now, let's look into how to do a coffee chat.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to do a coffee chat
&lt;/h2&gt;

&lt;p&gt;1) &lt;strong&gt;Get on X or LinkedIn&lt;/strong&gt;: Hopefully you are already on X (if not, LinkedIn is ok too).&lt;/p&gt;

&lt;p&gt;2) &lt;strong&gt;Set up a &lt;a href="https://cal.com/" rel="noopener noreferrer"&gt;Cal&lt;/a&gt; or &lt;a href="https://calendly.com/" rel="noopener noreferrer"&gt;Calendly&lt;/a&gt;&lt;/strong&gt;: I prefer Cal personally (since you can have more than one active event type for free), setting this up will help you manage your chat schedule.&lt;/p&gt;

&lt;p&gt;3) &lt;strong&gt;Create a new event&lt;/strong&gt;:&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4txaoagsp5s6vzyhmmv.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4txaoagsp5s6vzyhmmv.png" alt="New calendly event"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4) &lt;strong&gt;Reach out&lt;/strong&gt;: If you have some friends on X, LinkedIn, or Discord communities, reach out to them directly. The method I used was just posting a &lt;a href="https://x.com/elliezub/status/1786758429018587344" rel="noopener noreferrer"&gt;tweet&lt;/a&gt; and then reaching out to those who left comments. &lt;/p&gt;

&lt;p&gt;5) &lt;strong&gt;Be careful with your link&lt;/strong&gt;: Sharing your booking link publicly can lead to an overwhelming schedule and no-shows. Choosing who you want to chat with and DMing people directly is probably a better idea.&lt;/p&gt;

&lt;p&gt;After you get a few coffee chats booked, then you need to actually have a coffee chat. That might be a little scary, right? &lt;/p&gt;

&lt;p&gt;It might be a bit nerve-wracking, but conversations usually flow naturally (we're all in tech after all). However, if you want to be extra prepared, write down some questions or topics based on their profile. For example, if you see that someone is part of &lt;a href="https://leonnoel.com/100devs/" rel="noopener noreferrer"&gt;100Devs&lt;/a&gt;, that would be a great thing to ask them about. &lt;/p&gt;




&lt;p&gt;Well, that's all the advice I have. Go forth and have your own coffee chats! And if you're nervous, you can always reach out to me on &lt;a href="https://x.com/elliezub" rel="noopener noreferrer"&gt;X&lt;/a&gt; and we can have one first (I promise it's not that scary).&lt;/p&gt;

&lt;p&gt;See ya! &lt;/p&gt;

&lt;p&gt;Ellie&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>career</category>
      <category>community</category>
      <category>devrel</category>
    </item>
    <item>
      <title>Successfully Launch on Product Hunt🚀</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Tue, 09 Jul 2024 16:53:42 +0000</pubDate>
      <link>https://forem.com/elliezub/successfully-launch-on-product-hunt-1k49</link>
      <guid>https://forem.com/elliezub/successfully-launch-on-product-hunt-1k49</guid>
      <description>&lt;p&gt;Today, I want to share some quotes &amp;amp; advice from a recent X/Twitter space I hosted with &lt;a href="https://x.com/Astrodevil_" rel="noopener noreferrer"&gt;Ånand&lt;/a&gt; and &lt;a href="https://x.com/Arindam_1729" rel="noopener noreferrer"&gt;Arindam&lt;/a&gt;. The title was "&lt;strong&gt;How to Successfully Launch on Product Hunt 🚀&lt;/strong&gt;". &lt;/p&gt;

&lt;p&gt;If you're interested in listening to the space while you read this post, you can check it out &lt;a href="https://x.com/i/spaces/1mrxmyBeDvDxy" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf3mg3bpn1422ipdnyn2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf3mg3bpn1422ipdnyn2.png" alt="Screenshot of the twitter space" width="800" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This topic is really relevant to us since we're actually getting ready for the &lt;a href="https://www.producthunt.com/products/pieces-for-developers" rel="noopener noreferrer"&gt;Pieces' launch&lt;/a&gt; on Wednesday!&lt;/p&gt;

&lt;p&gt;That said, let's see what we learned during this space.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Product Hunt?
&lt;/h2&gt;

&lt;p&gt;What exactly is &lt;a href="https://www.producthunt.com/" rel="noopener noreferrer"&gt;Product Hunt&lt;/a&gt;? Here's the gist, according to Graham:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"It's a place to discover new tech. That's basically it. It's a place where people can hunt for and show you things that they discovered and think are cool. Then people can vote on things that they like, leave comments, etc. It's a discovery tool above all else" - &lt;a href="https://x.com/GrahamTheDev" rel="noopener noreferrer"&gt;Graham&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In essence, it's a discovery tool where the community votes on and comments on tech products they find interesting.&lt;/p&gt;

&lt;p&gt;Now that we know what Product Hunt is, let's get to the actual advice shared. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Importance of Strategy
&lt;/h2&gt;

&lt;p&gt;One of the main themes during this space was &lt;strong&gt;Strategy and Preparation&lt;/strong&gt;, whether it was preparing weeks before your launch, or even the day of, it seems like it's really important to have a plan. &lt;/p&gt;

&lt;p&gt;One thing that really resonated with me is what &lt;a href="https://x.com/0xT33m0" rel="noopener noreferrer"&gt;Dan&lt;/a&gt; said about preparation (paraphrased):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you're planning to use Product Hunt for your launch, you need a solid marketing strategy, a launch plan, a pre-launch, and a consistent strategy throughout the launch.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So we need to prepare, but how?&lt;/p&gt;

&lt;h3&gt;
  
  
  First Steps
&lt;/h3&gt;

&lt;p&gt;First things first, you need to set up a Product Hunt page. This step is pretty self-explanatory, but good graphics and descriptions can really make or break whether the product is successful. During this space we talked about having a concise intro that lets people know what the product is and what it can do. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To learn more about setting up your page, check out Product Hunt's &lt;a href="https://www.producthunt.com/launch/preparing-for-launch" rel="noopener noreferrer"&gt;official guide&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Specifically, &lt;a href="https://x.com/HowDevelop" rel="noopener noreferrer"&gt;Shivay&lt;/a&gt; mentioned having a high-quality demo, graphics, and description on the PH page. To learn how this might look, it's a good idea to check out some successful PH pages for inspiration.&lt;/p&gt;

&lt;p&gt;After talking about setting up PH pages, we talked about making lists/plans. It's probably a good idea to list out your goals, and the areas that need to be focused on during the pre-launch and launch. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Launch
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Community Focus
&lt;/h3&gt;

&lt;p&gt;A recurring theme among our speakers was the importance of community. Build for the community, ask for feedback, and engage with others. Here's a paraphrase from Shivay:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Build for the community. Ask for feedback in developer &amp;amp; Product Hunt communities.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, Shivay did mention that you need to be careful. If you're too aggressive in promoting your launch (or even asking for feedback too frequently), sometimes it can be flagged as spam or even be seen as asking for upvotes directly (that is &lt;a href="https://www.producthunt.com/questions/how-do-i-promote-my-launch" rel="noopener noreferrer"&gt;&lt;strong&gt;not&lt;/strong&gt; allowed&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rule of thumb:&lt;/strong&gt; Generally it seems safe to &lt;strong&gt;genuinely&lt;/strong&gt; ask for feedback and like &lt;a href="https://dev.to/francescoxx"&gt;Francesco&lt;/a&gt; said, post things like "go and check it out and give us some love".&lt;/p&gt;

&lt;p&gt;To reiterate:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Don't ask for upvotes. You will be banned." - Graham&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;On the other hand, one thing you &lt;strong&gt;can&lt;/strong&gt; do is: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You can add influencers as makers or hunters for your Product Hunt launch if they have used or contributed to your product. This can significantly boost engagement on social media." - Ånand&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By collaborating with "influencers" active in relevant communities who already use your product, you can connect with new audiences and integrate them into your existing community.&lt;/p&gt;

&lt;h3&gt;
  
  
  Making Connections
&lt;/h3&gt;

&lt;p&gt;Arindam asked an important question about the role of connections in a successful launch. &lt;/p&gt;

&lt;p&gt;Shivay responded, mentioning the tightly-knit nature of Product Hunt communities:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You help others and they also tend to reciprocate, so later on they may help you. For example, if you give feedback on someone else's product, they may do the same for you when you need feedback down the road. (paraphrased)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;However, make sure to keep this in mind when trying to make new connections:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Don't start spamming people in their DMs if you don't know them (about your product hunt launch)” - &lt;a href="https://x.com/FrancescoCiull4" rel="noopener noreferrer"&gt;Francesco&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It would be better to build a community first, as Alohe mentions:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Building an audience first, before launching is the main thing for me." - &lt;a href="https://x.com/alemalohe" rel="noopener noreferrer"&gt;Alohe&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And speaking of audience, one thing that &lt;a href="https://x.com/HairunHuang" rel="noopener noreferrer"&gt;Hairun&lt;/a&gt; shared that he regrets, is not utilizing the audience he gained from product hunt, and directing them to his Twitter profile. &lt;/p&gt;

&lt;h3&gt;
  
  
  Genuine Engagement
&lt;/h3&gt;

&lt;p&gt;Shivay also advised against blind upvoting. Only genuinely upvote products you believe in. It's about authenticity. (Also, pretty sure if you upvote a BUNCH of launches it might be flagged as spam)&lt;/p&gt;

&lt;h2&gt;
  
  
  Launch Day
&lt;/h2&gt;

&lt;h3&gt;
  
  
  When to Launch
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://x.com/CodingWithDrewK" rel="noopener noreferrer"&gt;Mr. Drew&lt;/a&gt;'s question about the timing of a launch led to Shivay's advice (paraphrased):&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If your app is stable enough, launching early, even in beta stages, can work in your favor. Pieces, for instance, had a successful beta launch.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The One-Day Party
&lt;/h3&gt;

&lt;p&gt;Francesco summed up the Product Hunt experience with a memorable quote:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Product Hunt is like a one-day party." - Francesco&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExNzBtczUxaDk3dmVkMjQ4MWoza3F0ZzZjYzh4eHVzc2xuMWFwOWpydSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/U4DswrBiaz0p67ZweH/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExNzBtczUxaDk3dmVkMjQ4MWoza3F0ZzZjYzh4eHVzc2xuMWFwOWpydSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/U4DswrBiaz0p67ZweH/giphy.gif" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Launch day is really exciting, but if you're the host of this "party" it can be really stressful if you don't do the prep work. Graham, summed it up pretty well when he said this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"On the day is horrendous. Even with an amazing team behind you, it's a lot of work. But before the (launch) day is even more important." - Graham&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Preparation, he says, is 80% of the battle, especially for smaller companies.&lt;/p&gt;

&lt;h3&gt;
  
  
  Launch Day Schedule
&lt;/h3&gt;

&lt;p&gt;Francesco emphasized the need for a launch day schedule:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Create a list schedule for the day of the launch. Plan every detail, from influencer posts to Twitter spaces and newsletters. (paraphrased)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He also mentioned that it's a good idea to host a Twitter space on launch day. It can be a pretty casual space, but having the link to the launch in the jumbotron can really help.&lt;/p&gt;

&lt;p&gt;And when creating this schedule, keep what &lt;a href="https://x.com/zeng_wt" rel="noopener noreferrer"&gt;Zeng&lt;/a&gt; said in mind:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;first 4 hours&lt;/strong&gt; after launching are critical for gaining momentum and getting a boost from the algorithm. (paraphrased)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Post-Launch
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Launching Multiple Times
&lt;/h3&gt;

&lt;p&gt;Here's a paraphrase from Francesco that's worth noting:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can launch on Product Hunt more than once, provided you've made substantial changes to your product. It's about bringing something new to the table each time.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Power of a Great Product
&lt;/h2&gt;

&lt;p&gt;Now that we've covered strategy, pre-launch, and launch day, there is still one &lt;strong&gt;VERY&lt;/strong&gt; important factor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Is your product awesome??&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Zeng, having launched multiple times on Product Hunt, reminded us that a &lt;strong&gt;great product&lt;/strong&gt; can be successful on Product Hunt, regardless of the size of your account (or the size of other socials). &lt;/p&gt;

&lt;p&gt;Speaking of awesome products... 👀&lt;/p&gt;

&lt;h2&gt;
  
  
  Pieces Launch
&lt;/h2&gt;

&lt;p&gt;As we wrapped up the space, Shivay gave us a sneak peek at what we're launching at Pieces:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"What is being launched is Pieces Copilot+ powered by &lt;a href="https://docs.pieces.app/product-highlights-and-benefits/live-context" rel="noopener noreferrer"&gt;Live-Context&lt;/a&gt; feature."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal is to aid in &lt;strong&gt;context switching&lt;/strong&gt;, providing awareness across your browser and IDE. For example, during the space I mentioned how Live Context could be useful when learning React:&lt;/p&gt;

&lt;p&gt;Imagine you're a &lt;a href="https://v2.scrimba.com/home" rel="noopener noreferrer"&gt;Scrimba&lt;/a&gt; student learning React and you just learned about &lt;code&gt;useState&lt;/code&gt;. You open VSCode to apply this knowledge. You could ask Pieces Copilot+:&lt;/p&gt;

&lt;p&gt;"What was I learning about in my React course, and how can I apply it to my project?"&lt;/p&gt;

&lt;p&gt;Pieces would then suggest how to implement &lt;code&gt;useState&lt;/code&gt; in your project, leveraging &lt;strong&gt;Live Context&lt;/strong&gt; to know what you were learning in the browser.&lt;/p&gt;

&lt;p&gt;This is just one example of how you could use it to help learn new things.&lt;/p&gt;




&lt;p&gt;If that sounds interesting to you, definitely check out &lt;a href="https://www.producthunt.com/products/pieces-for-developers" rel="noopener noreferrer"&gt;Pieces on Product Hunt&lt;/a&gt; this Wednesday. Your support and feedback mean the world to us.&lt;/p&gt;

&lt;p&gt;If you're curious about &lt;a href="https://pieces.app/?utm_source=producthuntarticle&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=ellie-partner" rel="noopener noreferrer"&gt;Pieces&lt;/a&gt; or want to connect, feel free to reach out on Twitter &lt;a href="https://x.com/getpieces" rel="noopener noreferrer"&gt;@getpieces&lt;/a&gt; or you can connect with me personally &lt;a href="https://x.com/elliezub" rel="noopener noreferrer"&gt;@elliezub&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;I really hope you enjoyed this summary of the space. If you listened to the space &amp;amp; have any favorite quotes, feel free to share them in the comments below! (and if I misquoted anyone, feel free to let me know!)&lt;/p&gt;

&lt;p&gt;See you next time,&lt;/p&gt;

&lt;p&gt;Ellie&lt;/p&gt;

</description>
      <category>startup</category>
      <category>ai</category>
      <category>beginners</category>
      <category>community</category>
    </item>
    <item>
      <title>Using Pieces: A Technical Writer's Perspective</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Tue, 04 Jun 2024 18:56:23 +0000</pubDate>
      <link>https://forem.com/elliezub/using-pieces-a-technical-writers-perspective-39ip</link>
      <guid>https://forem.com/elliezub/using-pieces-a-technical-writers-perspective-39ip</guid>
      <description>&lt;p&gt;Hello! I’m super excited to share a new tool I've been using recently that has significantly boosted my productivity and made my writing process a lot smoother.&lt;/p&gt;

&lt;p&gt;As you might have guessed from the title, I’ll be talking about &lt;a href="https://pieces.app/?utm_source=youtube&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=ellie-partner-twitter" rel="noopener noreferrer"&gt;Pieces&lt;/a&gt; (and I'm not talking about puzzle pieces).&lt;/p&gt;

&lt;p&gt;To give you a bit of background on why I'm writing this article, I'll tell you how I found out about Pieces. The first time I came across Pieces was a few weeks ago in one of their Twitter spaces. During the space, I got the impression that the team working on Pieces is &lt;strong&gt;really passionate&lt;/strong&gt; about what they are doing, and that stuck in my mind. &lt;/p&gt;

&lt;p&gt;Later on, I got even more interested after a coffee chat with the amazing &lt;a href="https://x.com/sophiairoegbu_" rel="noopener noreferrer"&gt;Sophia Iroegbu&lt;/a&gt;. She talked about her time &lt;strong&gt;writing articles for Pieces&lt;/strong&gt; and also her experience &lt;strong&gt;working as a DevRel intern&lt;/strong&gt;. After hearing about her positive experiences, I got really curious, so I decided to download Pieces and try it out for myself.&lt;/p&gt;

&lt;p&gt;That said, let's first learn a little bit about Pieces.&lt;/p&gt;

&lt;h2&gt;
  
  
  What even is Pieces?
&lt;/h2&gt;

&lt;p&gt;Well, basically, &lt;strong&gt;Pieces is an AI workflow companion&lt;/strong&gt; (think an early version of Jarvis from Iron Man).&lt;/p&gt;

&lt;p&gt;To give you a better idea of what Pieces can do, check out this 1-minute intro video:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aP8u95RTCGE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Now that you understand a bit about Pieces, I'll give you a rundown of how I normally use it.😄 &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExZG54ZDQ0N3pveWt5NjhhOHczZmkyYnU5YW1icm1raGx5cjNjbDhtayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/EjZCMlsD3TtSOrST2X/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExZG54ZDQ0N3pveWt5NjhhOHczZmkyYnU5YW1icm1raGx5cjNjbDhtayZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/EjZCMlsD3TtSOrST2X/giphy.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I use Pieces
&lt;/h2&gt;

&lt;p&gt;Over the past few weeks, I've had the chance to test out Pieces quite a bit. Mainly, I use it while writing articles and working on projects.&lt;/p&gt;

&lt;p&gt;What’s great is how well it integrates into my workflow, making me more productive and helping me stay on task. There are several ways to use Pieces, but in this article, I'll focus on my experience with the &lt;strong&gt;Pieces Copilot&lt;/strong&gt; (in VS Code), the &lt;strong&gt;Obsidian Extension&lt;/strong&gt;, and the &lt;strong&gt;Desktop App&lt;/strong&gt;. I'll walk you through how I use it, what I like about it, and what I wish it could do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pieces Obsidian Extension
&lt;/h3&gt;

&lt;p&gt;Recently, I've been working on an article about &lt;strong&gt;the benefits of coffee chats for developers&lt;/strong&gt;. The &lt;a href="https://docs.pieces.app/extensions-plugins/obsidian" rel="noopener noreferrer"&gt;Pieces Obsidian Extension&lt;/a&gt; has been super useful during the writing process. &lt;/p&gt;

&lt;p&gt;To put things in perspective, my initial outlines for articles usually look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Explain Coffee Chats
Benefits of Coffee Chats for devs
- Communication
- Community
- Career 

Conclusion/Tips
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pretty brief right? Ultimately, I need a much more thorough outline including headings and subheadings. So, to expand on what I have and brainstorm new ideas, I ask Pieces:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Give me a better outline, and create some title ideas for the blog&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here, you can see the beginning of Pieces' response:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihtzkfca8ndhykrostmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihtzkfca8ndhykrostmc.png" alt="Screenshot of the new outline Pieces generated" width="800" height="636"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the screenshot, Pieces responds with a WAY better outline &amp;amp; even adds some suggestions for subtopics.&lt;/p&gt;

&lt;p&gt;One interesting topic that it suggested including in the article was the "origin of coffee chats". I hadn't thought about mentioning that. Other than that, Pieces suggested some really good tips when doing coffee chats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prepare questions&lt;/li&gt;
&lt;li&gt;Be respectful of time&lt;/li&gt;
&lt;li&gt;Follow up with a thank-you note&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without getting too off-topic, I really liked the new version of my outline and the fact that I didn't even need to leave the Obsidian app to create it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pieces Copilot
&lt;/h3&gt;

&lt;p&gt;Another thing that I've been working on lately is my new portfolio site. It's been really interesting to go through my code and ask &lt;a href="https://docs.pieces.app/extensions-plugins/vscode" rel="noopener noreferrer"&gt;Pieces Copilot&lt;/a&gt; how to make it more accessible:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hzwkxp4h93f13cpfzr1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hzwkxp4h93f13cpfzr1.png" alt="Screenshot using the Pieces Copilot, asking how to make the code more accessible" width="800" height="621"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, Pieces gives me a list of about 10 tips, such as adding alt text, using semantic HTML, and ensuring good color contrast (for context, my entire website is purple).&lt;/p&gt;

&lt;p&gt;Then, it provides specific code snippets and suggested improvements.&lt;/p&gt;

&lt;p&gt;Honestly, I sometimes overlook making things accessible from the start and end up addressing it as one of my final tasks (I know, I'm terrible). So, for me, using Pieces in this way is extremely helpful.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Desktop App
&lt;/h3&gt;

&lt;p&gt;Last but not least, let's talk about the &lt;a href="https://docs.pieces.app/installation-getting-started/what-am-i-installing" rel="noopener noreferrer"&gt;Pieces Desktop App&lt;/a&gt;. The really cool thing about the desktop app is the &lt;strong&gt;Live Context&lt;/strong&gt; feature. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.pieces.app/product-highlights-and-benefits/live-context" rel="noopener noreferrer"&gt;Live Context&lt;/a&gt; essentially gives Pieces the ability to look at the other things that you are working on. This comes in handy when you are working on a larger project with a bunch of files. Instead of repeatedly copying &amp;amp; pasting code, you could just ask Pieces directly about whatever repo or file you need help with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExeTV1bGlhNmxrMjV2ZWg3eTA2d3JsOGRlb3YwZTFxeDFpbjQzbnBvcyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3oEjHYibHwRL7mrNyo/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExeTV1bGlhNmxrMjV2ZWg3eTA2d3JsOGRlb3YwZTFxeDFpbjQzbnBvcyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3oEjHYibHwRL7mrNyo/giphy.gif" width="475" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That said, let's see how &lt;strong&gt;Live Context&lt;/strong&gt; works:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmzzok4rjx9a33mvaxxn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmzzok4rjx9a33mvaxxn.png" alt="Screenshot of turning the live context on" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, we need to turn on Live Context.&lt;/p&gt;

&lt;p&gt;Then, to give you an idea of what it can access, I ask it where I left off with my work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy2wibe5e3jh4r4m5dz8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy2wibe5e3jh4r4m5dz8.png" alt="Screenshot of a message asking Pieces where I left off with my work" width="800" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, recently I've been working on my new portfolio site, which I haphazardly named Ellies-blog-links. Normally I wouldn't ask Pieces about where I left off, but I think this is a good way to demonstrate that Pieces is actually keeping tabs on what I do in VSCode.&lt;/p&gt;

&lt;p&gt;Now that I know that Pieces is aware of what I'm working on, I ask it to review my entire repo and check for accessibility issues:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcs301b12hbsa8mdsm2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcs301b12hbsa8mdsm2e.png" alt="Screenshot of accessibility recommendations from Pieces desktop app" width="800" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, Pieces responds with some accessibility tips, links to helpful resources, &amp;amp; specific instances where I could improve my code. This is similar to the previous example using the Copilot, but this time Pieces considers the accessibility of my &lt;em&gt;entire&lt;/em&gt; repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Overall, Pieces has been a great addition to my workflow. I've also had a lot of fun learning about its capabilities and interacting with the Pieces community.&lt;/p&gt;

&lt;p&gt;Now, I'd like to share a bit about the things I like &amp;amp; the things that could use some improvement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ways to Improve
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;I really wish the Live Context feature existed within the Obsidian extension &amp;amp; VSCode (although I heard they are working on getting this integrated🤞).&lt;/li&gt;
&lt;li&gt;Occasionally the responses have some formatting issues, like too much space between bullet points, or going suddenly from markdown to regular text.&lt;/li&gt;
&lt;li&gt;Sometimes Pieces (Copilot &amp;amp; Desktop App) changes my code a bit &lt;em&gt;too&lt;/em&gt; much (for ex: it might make quite a few changes outside of my original request, like variable name changes etc.) and sometimes it doesn't make enough changes. But to be fair, ChatGPT has the same issue. I assume that once Pieces has more time to learn about me and how I work, it will get more intuitive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Things I Love
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Love the fact I don't need to exit whatever app I'm using to ask it questions (Obsidian, VSCode).&lt;/li&gt;
&lt;li&gt;It really picks up on your personal writing style due to the Live Context, so I would say it's much better with editing than using ChatGPT directly.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Live Context&lt;/strong&gt; feature is very useful, I love how Pieces can look at ALL the files in my repo at once.&lt;/li&gt;
&lt;li&gt;The Pieces Team is SUPER responsive to feedback of any kind. They respond really quickly if a user is facing any kind of issue &amp;amp; then they try their best to fix it.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Well, that's all for this post. If you would like to try Pieces for yourself, you can download it for free &lt;a href="https://pieces.app/?utm_source=youtube&amp;amp;utm_medium=cpc&amp;amp;utm_campaign=ellie-partner-twitter" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I would love to know what you think!&lt;/p&gt;

&lt;p&gt;If you have any questions about Pieces or want to connect with me, the best place to reach me is on &lt;a href="https://x.com/elliezub" rel="noopener noreferrer"&gt;Twitter/X.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>ai</category>
    </item>
    <item>
      <title>Unity Transform: Position</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Sun, 25 Feb 2024 00:53:05 +0000</pubDate>
      <link>https://forem.com/elliezub/unity-transform-position-1b7f</link>
      <guid>https://forem.com/elliezub/unity-transform-position-1b7f</guid>
      <description>&lt;p&gt;So I've been learning a lot of Unity lately, but want to really solidify what I've been learning. &lt;/p&gt;

&lt;p&gt;What better way to do that than writing a blog about it? &lt;/p&gt;

&lt;p&gt;In this series we are going to get into some basic, but SUPER important things when getting started with Unity game development.&lt;/p&gt;

&lt;p&gt;These things are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position&lt;/li&gt;
&lt;li&gt;Scale&lt;/li&gt;
&lt;li&gt;Rotation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's jump right into it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Position
&lt;/h2&gt;

&lt;p&gt;So, what you see in this image is the Unity editor, and there is just a white square plane in the middle of the scene.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yc3sq85c7idvge232fh.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6yc3sq85c7idvge232fh.png" alt="Screenshot of a Unity editor showing a white plane"&gt;&lt;/a&gt;&lt;br&gt;
If you take a close look in the inspector, you can see an area called &lt;strong&gt;transform&lt;/strong&gt;. Below that, you can see &lt;strong&gt;position&lt;/strong&gt;.&lt;br&gt;&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2jinyc9sa5k2lz0ycza.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2jinyc9sa5k2lz0ycza.png" alt="Screenshot of a Unity editor showing transform, position, and the scene gizmo"&gt;&lt;/a&gt;&lt;br&gt;
This refers to the position in the scene and is determined by x, y, and z coordinates. In this example, our plane is right in the middle of the scene at &lt;code&gt;Vector3(0, 0, 0)&lt;/code&gt;. If you get confused by which one is which (meaning the x, y, and z-axis) you can take a look at the thing circled in orange, which comes in handy when changing the position of objects.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By the way, what even is a &lt;code&gt;Vector3&lt;/code&gt;?? Well, &lt;code&gt;Vector3&lt;/code&gt; in Unity represents a 3D position or direction using x, y, and z coordinates. You can learn more about that &lt;a href="https://cgcookie.com/lessons/understanding-vector-3" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Here comes THE CUBE!
&lt;/h3&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo09niecf4zqwfwu35963.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo09niecf4zqwfwu35963.png" alt="Screenshot of a Unity scene, there is a purple cube in the center"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, as you can see we have added a cube on top of our plane. Why?&lt;/p&gt;

&lt;p&gt;Well, we are going to make the cube move, it should be able to move forward, backward, left, and right with the arrow keys, and even jump up with the spacebar. By doing this you should be able to have a solid understanding of positioning in Unity.&lt;/p&gt;

&lt;p&gt;Some things to be aware of in this post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Horizontal input&lt;/strong&gt; (left and right arrow keys) moves the cube left and right along the X-axis (the red one).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vertical input&lt;/strong&gt; (up and down arrow keys) moves the cube forward and backward along the Z-axis (the blue one).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Jumping&lt;/strong&gt; is controlled separately (with the space bar), and changes the cube's position on the Y-axis (the green one).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we've defined some important words that you'll see later on, let's get into the code!&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;class&lt;/span&gt; &lt;span class="nc"&gt;CubePosition&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MonoBehaviour&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;float&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10.0f&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;float&lt;/span&gt; &lt;span class="n"&gt;jumpForce&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10.0f&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;float&lt;/span&gt; &lt;span class="n"&gt;horizontalInput&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;float&lt;/span&gt; &lt;span class="n"&gt;verticalInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Rigidbody&lt;/span&gt; &lt;span class="n"&gt;rb&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;First, we are going to go ahead and define some of our public and private variables. We make some of the variables public so we can easily edit them later in the Unity editor.👇 &lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a7hqwqv9drq9yzyie28.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a7hqwqv9drq9yzyie28.png" alt="Screenshot of Cube Position script public variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can directly edit the Speed and Jump Force here, and Horizontal and Vertical Input will change automatically when we click the arrow keys (after we add that logic later).&lt;/p&gt;

&lt;p&gt;The private variable &lt;code&gt;rb&lt;/code&gt; is a reference to the Rigidbody component attached to the cube, which allows us to apply physics-based behaviors to it. Later, we'll use this to make the cube jump!&lt;/p&gt;

&lt;p&gt;Next, we have our &lt;code&gt;Start()&lt;/code&gt; and &lt;code&gt;Update()&lt;/code&gt; functions.&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;void&lt;/span&gt; &lt;span class="nf"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;rb&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GetComponent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Rigidbody&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Update is called once per frame&lt;/span&gt;
&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Move&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nf"&gt;Jump&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;Here we have two methods, &lt;code&gt;Start()&lt;/code&gt; runs once when the game starts, right before anything else happens and &lt;code&gt;Update()&lt;/code&gt; runs once per frame.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Start()&lt;/code&gt; assigns the cube's Rigidbody component to rb, allowing for physics-based movement.&lt;/p&gt;

&lt;p&gt;Then, within &lt;code&gt;Update()&lt;/code&gt;, we call 2 functions that we will now create!&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's Move!
&lt;/h2&gt;

&lt;p&gt;First, the &lt;code&gt;Move()&lt;/code&gt; method!&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;void&lt;/span&gt; &lt;span class="nf"&gt;Move&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;horizontalInput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAxis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Horizontal"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;verticalInput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAxis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Vertical"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// this moves the cube forward and backward&lt;/span&gt;
    &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forward&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;verticalInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// this moves the cube left and right &lt;/span&gt;
    &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;horizontalInput&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 &lt;code&gt;Move()&lt;/code&gt; method gets player input for movement, using &lt;code&gt;Input.GetAxis&lt;/code&gt; for both vertical (forward/backward) and horizontal (left/right) directions. Then, we assign these inputs to &lt;code&gt;horizontalInput&lt;/code&gt; and &lt;code&gt;verticalInput&lt;/code&gt; variables. &lt;/p&gt;

&lt;p&gt;After that, we use &lt;code&gt;transform.Translate&lt;/code&gt; to make the game object move.  &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

&lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forward&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;verticalInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here, we are controlling the &lt;strong&gt;forward and backward&lt;/strong&gt; movement of the object (on the Z-axis). &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Vector3.forward&lt;/code&gt; (which is the shorthand for &lt;code&gt;Vector3(0,0,1)&lt;/code&gt;) targets movement along the Z-axis and is multiplied by: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Time.deltaTime&lt;/code&gt; for consistent speed across frames&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;speed&lt;/code&gt; for movement speed&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;verticalInput&lt;/code&gt; for direction based on player input&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If you would like to learn more about Time.deltaTime, you could check out this &lt;a href="https://www.educative.io/answers/what-is-timedeltatime-in-unity" rel="noopener noreferrer"&gt;resource&lt;/a&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then we do something very similar to allow for &lt;strong&gt;left and right&lt;/strong&gt; movement. &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

&lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;horizontalInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Here, we use &lt;code&gt;Vector3.right&lt;/code&gt; (shorthand for &lt;code&gt;Vector3(1,0,0)&lt;/code&gt;) for movement along the X-axis and multiply it by &lt;code&gt;Time.deltaTime&lt;/code&gt;, &lt;code&gt;speed&lt;/code&gt;, and &lt;code&gt;horizontalInput&lt;/code&gt;. &lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4i7zrcc8b8g7qdad5irq.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4i7zrcc8b8g7qdad5irq.gif" alt="gif of moving cube"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yay! Now our cube can move forward, backward, left, and right!&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's Jump!
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: it's not generally a good idea to mix two different movement systems, but for the sake of simplicity I am leaving it like this for now😅&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now let's move on to our &lt;code&gt;Jump()&lt;/code&gt; method: &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;void&lt;/span&gt; &lt;span class="nf"&gt;Jump&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;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetKeyDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;KeyCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Space&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// this moves the cube up (jump)&lt;/span&gt;
        &lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddForce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;up&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;jumpForce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ForceMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Impulse&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 &lt;code&gt;Jump()&lt;/code&gt; method makes it possible for our cube to jump into the air. It checks if the player has pressed the space bar &lt;br&gt;
 with &lt;code&gt;(Input.GetKeyDown(KeyCode.Space))&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If the player has pressed the space bar, there is an upward force applied to the object. We calculate this force by multiplying &lt;code&gt;Vector3.up&lt;/code&gt; (along the Y-axis) by &lt;code&gt;jumpForce&lt;/code&gt; (the strength of the jump), and &lt;code&gt;ForceMode.Impulse&lt;/code&gt; to make sure the force is applied right away.&lt;/p&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzbvar2n45l6z7h75pc4.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzbvar2n45l6z7h75pc4.gif" alt="gif of cube jumping"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all we need to make the cube move with the arrow keys and space bar! Here's the entire script if you would like to try it yourself. But make sure to add a Rigidbody component to the cube so it uses gravity. &lt;/p&gt;
&lt;h3&gt;
  
  
  Complete Script
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;UnityEngine&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;CubePosition&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MonoBehaviour&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;float&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10.0f&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;float&lt;/span&gt; &lt;span class="n"&gt;jumpForce&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10.0f&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;float&lt;/span&gt; &lt;span class="n"&gt;horizontalInput&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;float&lt;/span&gt; &lt;span class="n"&gt;verticalInput&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Rigidbody&lt;/span&gt; &lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Start is called before the first frame update&lt;/span&gt;
    &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Start&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;rb&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GetComponent&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Rigidbody&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Update is called once per frame&lt;/span&gt;
    &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Update&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;Move&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="nf"&gt;Jump&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Move&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;horizontalInput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAxis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Horizontal"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;verticalInput&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetAxis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Vertical"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// this moves the cube forward and backward&lt;/span&gt;
        &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;forward&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;verticalInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// this moves the cube left and right &lt;/span&gt;
        &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Translate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;deltaTime&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;speed&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;horizontalInput&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Jump&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;Input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetKeyDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;KeyCode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Space&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// this moves the cube up (jump)&lt;/span&gt;
            &lt;span class="n"&gt;rb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddForce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Vector3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;up&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;jumpForce&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ForceMode&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Impulse&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;h3&gt;
  
  
  The Result
&lt;/h3&gt;

&lt;p&gt;You can test what we've created &lt;a href="https://play.unity.com/mg/other/webgl-builds-392859" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Last but not least, here's a video of our cube in action! In this video, you can see how the x, y, and z values change as I click the arrow keys and space bar. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/4kO3hX8ILt4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;p&gt;Well, that's all for this post. If you end up making your own cube and adding movement, feel free to share it in the comments! &lt;/p&gt;

&lt;p&gt;If you have any suggestions for how to improve this post or notice anything I have excluded please let me know 😄&lt;/p&gt;

&lt;p&gt;If you're looking for more resources to learn how to code check out my &lt;a href="https://elliezub.github.io/Free-Coding-Resources/" rel="noopener noreferrer"&gt;Free Coding Resources&lt;/a&gt; site, it has links to a bunch of my favorite courses/resources!&lt;/p&gt;

&lt;p&gt;And of course, be sure to check out &lt;a href="https://learn.unity.com/pathway/junior-programmer" rel="noopener noreferrer"&gt;Unity Learn&lt;/a&gt;, it's an amazing resource!&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;Twitter/X&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>unity3d</category>
      <category>gamedev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Should you do #100DaysOfCode?</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Thu, 11 Jan 2024 23:01:44 +0000</pubDate>
      <link>https://forem.com/elliezub/should-you-do-100daysofcode-3p0h</link>
      <guid>https://forem.com/elliezub/should-you-do-100daysofcode-3p0h</guid>
      <description>&lt;p&gt;Thinking about doing the &lt;a href="https://www.100daysofcode.com/" rel="noopener noreferrer"&gt;#100DaysOfCode&lt;/a&gt; Challenge on X/Twitter? Well, you've come to the right place!&lt;/p&gt;

&lt;p&gt;When I first discovered #100DaysOfCode, I was very curious about it since I love a good challenge. At that time I had already started learning HTML and CSS via freeCodeCamp's &lt;a href="https://www.freecodecamp.org/learn/2022/responsive-web-design/" rel="noopener noreferrer"&gt;Responsive Web Design Course&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Somehow I heard that there's a big tech community on Twitter, so I decided to check it out. That's when I kept seeing the #100DaysOfCode hashtag floating around everywhere.&lt;/p&gt;

&lt;p&gt;After looking into it, I thought, "Hey, this seems cool. I'm already studying (almost) every day, so why not do this?"&lt;/p&gt;

&lt;p&gt;I had no idea people would actually care about what I was up to; I just wanted to document my progress with the challenge.&lt;/p&gt;

&lt;p&gt;Now, I have completed the challenge twice, met some awesome people, and am currently on round 3! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttburwy4f39vboyvcrmx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fttburwy4f39vboyvcrmx.png" alt="ScreenShot of my X/Twitter Account" width="800" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are certainly pros and cons to doing the challenge. In this post, we'll walk through my experience with the challenge, and by the end, you'll hopefully be able to decide if it's right for you.&lt;/p&gt;




&lt;p&gt;Before getting into my experience with the challenge, consider these questions to help you decide if #100DaysOfCode is a good idea for you:&lt;/p&gt;

&lt;h3&gt;
  
  
  Do you want to do it?
&lt;/h3&gt;

&lt;p&gt;Do you actually have a desire to code every day for 100 days? &lt;/p&gt;

&lt;p&gt;If the answer is no, it will be pretty difficult to succeed at doing this challenge. &lt;/p&gt;

&lt;h3&gt;
  
  
  Are you new to coding?
&lt;/h3&gt;

&lt;p&gt;Then this challenge is perfect for you. Personally, I find it hard to get into a habit of doing something unless I get obsessed with it. &lt;/p&gt;

&lt;p&gt;Coding every day provides me with a sense of achievement, and documenting my progress makes me feel like I am getting closer and closer to my goals. &lt;/p&gt;

&lt;p&gt;Whether your goal is to land a job or learn a new language/framework, seeing your progress laid out in front of you can be extremely motivating.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do you need external accountability?
&lt;/h3&gt;

&lt;p&gt;Then this is perfect, especially if you make connections with other people doing the challenge. You can keep each other accountable. &lt;/p&gt;

&lt;p&gt;By posting your wins and your struggles, you will end up meeting so many kind people willing to congratulate, support, and also correct you when you're wrong about something.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Experience with #100DaysOfCode
&lt;/h2&gt;

&lt;p&gt;Let's take a look at each round and the pros and cons with each. &lt;/p&gt;

&lt;h3&gt;
  
  
  Round 1
&lt;/h3&gt;

&lt;p&gt;The first time I did #100DaysOfCode, I had just started learning to code about a month or two prior.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1649134392114044929-492" src="https://platform.twitter.com/embed/Tweet.html?id=1649134392114044929"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1649134392114044929-492');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1649134392114044929&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;After making this post, I coded for 100 days STRAIGHT. It was intense, but it helped me form the habit of coding. After about 30 days, it just became a part of my daily routine. &lt;/p&gt;

&lt;p&gt;Of course, it's hard to keep up when traveling or attending family events, but I made a promise to myself (and everyone on X 😆) that no matter what I would code every day.&lt;/p&gt;

&lt;p&gt;Even if that meant some days I needed to code on my phone! (Mimo was great for that)&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1682995750899445760-738" src="https://platform.twitter.com/embed/Tweet.html?id=1682995750899445760"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1682995750899445760-738');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1682995750899445760&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;If you are like me and need to do something every day to stay consistent, then I highly recommend pushing yourself to do this.&lt;/p&gt;

&lt;p&gt;During this time I definitely achieved a lot of cool things, and I'm still proud of myself for that!&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1685103031136739328-473" src="https://platform.twitter.com/embed/Tweet.html?id=1685103031136739328"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1685103031136739328-473');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1685103031136739328&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;However, if you have self-control and can stay consistent without coding literally every day, then you can try a different approach.&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 2
&lt;/h3&gt;

&lt;p&gt;This time, I let myself take breaks when needed (and considering the amount of life stuff that happened during this time, I really needed that.)&lt;/p&gt;

&lt;p&gt;So, if I needed to, I would sometimes take breaks for 1-3 days, then continue where I left off.&lt;/p&gt;

&lt;p&gt;Personally, I think that during the first round (pushing myself every day) I progressed more quickly. So if you feel that it's possible for you to do that without getting burnt out, then &lt;strong&gt;JUST DO IT&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here's my day 100 for round 2:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1732145898170335509-255" src="https://platform.twitter.com/embed/Tweet.html?id=1732145898170335509"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1732145898170335509-255');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1732145898170335509&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;FYI: During this round, I ended up switching my focus to learning about C#/.NET. This was for multiple reasons that I'll get into in my next blog post!&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 3 (Minus Weekends)
&lt;/h3&gt;

&lt;p&gt;Now, if you follow me on X, you should know that I am currently on round 3 of #100DaysOfCode. In the very beginning of this round I managed to finally achieve my goal of landing my first job in tech (yay!). &lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1744459461010296880-437" src="https://platform.twitter.com/embed/Tweet.html?id=1744459461010296880"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1744459461010296880-437');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1744459461010296880&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;So what method am I currently using? 100 days straight, or breaks whenever?&lt;/p&gt;

&lt;p&gt;Well, I realized a good compromise between the two is &lt;strong&gt;#100DaysOfCode minus weekends&lt;/strong&gt;. I started to treat it as a full-time job, but let myself have the weekends off so I don't continue to put stress on my personal/family life.&lt;/p&gt;

&lt;p&gt;Doing 100 days straight was amazing, but the main negative aspect for me was always worrying about coding when I got home from traveling or going out with my family/friends. I am not a morning person, so I would always end up studying late at night.&lt;/p&gt;

&lt;p&gt;With #100DaysOfCode minus weekends, I feel a sense of balance but also have structure. My approach is this: Mon-Fri I MUST code, study, read up, and apply for jobs (anything tech-related is fine with me as long as I get some coding in).&lt;/p&gt;

&lt;p&gt;Now that we've talked about the different ways you could do #100DaysOfCode, I'd like to share some tips that have had a significant impact on me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tips
&lt;/h3&gt;

&lt;p&gt;Along the way, I've pinpointed some things that have been game-changers for me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a "&lt;strong&gt;Why&lt;/strong&gt;". Why do you want to do this? What do you want to get out of it? (ex: Finish a project/course, learn a new language)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ALWAYS&lt;/strong&gt; code in the morning at the same time as you drink your coffee (somehow I combined my coffee-drinking habit with coding, and I think it really helped)&lt;/li&gt;
&lt;li&gt;Take &lt;strong&gt;breaks&lt;/strong&gt; when needed (the Pomodoro technique is great)&lt;/li&gt;
&lt;li&gt;Learn about &lt;strong&gt;habit formation&lt;/strong&gt; (read Atomic Habits)&lt;/li&gt;
&lt;li&gt;If you like music, create a playlist that you &lt;strong&gt;ONLY&lt;/strong&gt; listen to when studying. This conditions your mind to know that it's time to code!&lt;/li&gt;
&lt;li&gt;Social media (X/LinkedIn) is important for &lt;strong&gt;community building&lt;/strong&gt;/networking, but &lt;strong&gt;don't&lt;/strong&gt; use it during your study blocks (schedule when you can use social media or you'll end up wasting a lot of time scrolling)&lt;/li&gt;
&lt;li&gt;Go on &lt;strong&gt;X spaces&lt;/strong&gt; and meet people (great way to network)! Currently, a great space is called &lt;a href="https://twitter.com/TasonJorres" rel="noopener noreferrer"&gt;the tech commute&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Now it's up to you
&lt;/h2&gt;

&lt;p&gt;After reading this are you interested in starting the &lt;strong&gt;#100DaysOfCode&lt;/strong&gt; challenge on X?&lt;/p&gt;

&lt;p&gt;If you do, make sure to tag me so I can show some support!&lt;/p&gt;




&lt;p&gt;If you're looking for more resources to learn how to code check out my &lt;a href="https://elliezub.github.io/Free-Coding-Resources/" rel="noopener noreferrer"&gt;Free Coding Resources&lt;/a&gt; site, it has links to a bunch of my favorite courses/resources!&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;X/Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>learning</category>
      <category>100daysofcode</category>
    </item>
    <item>
      <title>Intro to Coding with Scratch</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Sun, 03 Dec 2023 21:06:41 +0000</pubDate>
      <link>https://forem.com/elliezub/intro-to-coding-with-scratch-2e86</link>
      <guid>https://forem.com/elliezub/intro-to-coding-with-scratch-2e86</guid>
      <description>&lt;p&gt;Most people I've talked to who start their coding journey learning HTML and CSS usually end up hitting a roadblock when they begin learning JavaScript. &lt;/p&gt;

&lt;p&gt;At least that was my experience.&lt;/p&gt;

&lt;p&gt;Learning HTML and CSS felt like a piece of cake, and suddenly I was faced with something completely alien.  &lt;/p&gt;

&lt;p&gt;I started my coding journey with &lt;a href="https://www.freecodecamp.org/learn" rel="noopener noreferrer"&gt;freeCodeCamp's&lt;/a&gt; &lt;a href="https://www.freecodecamp.org/learn/2022/responsive-web-design/" rel="noopener noreferrer"&gt;Responsive Web Design course&lt;/a&gt; and it was awesome! I was learning HTML and CSS; feeling very satisfied and happy. Until... I got to JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/xU1spRleFHmtjvskXw/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xU1spRleFHmtjvskXw/giphy.gif" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SO CONFUSING!&lt;/p&gt;

&lt;p&gt;It felt like all of the motivation I had was slowly leaking out of me. &lt;/p&gt;

&lt;p&gt;Eventually, I got the basics down and my motivation returned, but it certainly took a while. I specifically remember being very confused by the concept of loops. It took a while to figure out what was actually happening within a loop.&lt;/p&gt;

&lt;p&gt;If only I had known about &lt;a href="https://scratch.mit.edu/" rel="noopener noreferrer"&gt;Scratch&lt;/a&gt; earlier!&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sooo.. what's Scratch?
&lt;/h3&gt;

&lt;p&gt;It's a great platform for people (children and adults), with no programming experience to understand fundamental programming concepts. Instead of memorizing syntax and struggling to comprehend some basic coding logic, there's a more intuitive way to learn these things.&lt;/p&gt;

&lt;p&gt;And that way is Scratch!&lt;/p&gt;

&lt;p&gt;You can use Scratch to create animated movies, games, quizzes, pretty much anything you can think of you can create. To create a program you use drag-and-drop code blocks. &lt;/p&gt;

&lt;p&gt;Just to give you an idea of how that looks, here's an example of the "code" from a small story/game I made.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9up7qterhxog8zhby11a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9up7qterhxog8zhby11a.png" alt="Screenshot of the code editor on scratch for my game help the witch find her wand" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Overall it's an amazing platform. If you are learning HTML/CSS and haven't gotten to JavaScript or you're just starting to learn programming, definitely give Scratch a try.&lt;/p&gt;

&lt;p&gt;Even just writing a couple of programs on Scratch will make learning a real programming language so much easier.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Harvard's Scratch Course
&lt;/h3&gt;

&lt;p&gt;If you're feeling motivated to try Scratch, Harvard offers a free 3-week long course entirely devoted to Scratch, called &lt;a href="https://pll.harvard.edu/course/cs50s-introduction-programming-scratch" rel="noopener noreferrer"&gt;CS50's Introduction to Programming with Scratch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06j4qtjpharpb8pdtjap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06j4qtjpharpb8pdtjap.png" alt="Screenshot of Harvard's Scratch course" width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Well, that's it for this post! By the way, this post is not sponsored by Scratch - I just think the platform is super innovative. I only wish that my middle or high school had offered an Intro to Programming course using Scratch. Maybe then I would have realized my passion for coding much earlier. &lt;/p&gt;

&lt;p&gt;If you're looking for more resources to learn how to code check out my &lt;a href="https://elliezub.github.io/Free-Coding-Resources/" rel="noopener noreferrer"&gt;Free Coding Resources&lt;/a&gt; site, it has links to a bunch of my favorite courses/resources!&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;Twitter/X&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>learning</category>
      <category>coding</category>
      <category>programming</category>
    </item>
    <item>
      <title>Magical C# Constructors</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Mon, 06 Nov 2023 19:33:52 +0000</pubDate>
      <link>https://forem.com/elliezub/magical-c-constructors-i01</link>
      <guid>https://forem.com/elliezub/magical-c-constructors-i01</guid>
      <description>&lt;p&gt;Hello! Welcome back to another magical post about Object Oriented Programming with C#.&lt;/p&gt;

&lt;p&gt;This post will introduce the concept of &lt;strong&gt;constructors&lt;/strong&gt; and how they are helpful in creating &lt;strong&gt;objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The main topics discussed are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default values&lt;/li&gt;
&lt;li&gt;Default constructors&lt;/li&gt;
&lt;li&gt;Constructor overloading&lt;/li&gt;
&lt;li&gt;The 'this' keyword&lt;/li&gt;
&lt;li&gt;The 'base' keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Assuming you have already read my post about &lt;a href="https://dev.to/elliezub/magical-c-classes-3heg"&gt;C# classes and objects&lt;/a&gt;, let's move on to the wizard examples!🧙🏻‍♀️ &lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Constructors
&lt;/h3&gt;

&lt;p&gt;First, it's important to answer the question: &lt;em&gt;what is a constructor?&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A constructor is a special method in a class that sets up and initializes a new object, ensuring that all its properties are given the right starting values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want more info about constructors, it's beneficial to get a few different examples &amp;amp; points of view. Here are some good resources to learn more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.w3schools.com/cs/cs_constructors.php" rel="noopener noreferrer"&gt;W3Schools constructors - free course&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.csharptutorial.net/csharp-tutorial/csharp-constructors/" rel="noopener noreferrer"&gt;C# Constructors - article&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.codecademy.com/learn/learn-c-sharp-classes-objects-interfaces-and-inheritance" rel="noopener noreferrer"&gt;Codecademy's C# Classes &amp;amp; Objects - free course&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/constructors" rel="noopener noreferrer"&gt;Microsoft's C# Docs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  Wizard Class without a constructor
&lt;/h3&gt;

&lt;p&gt;Remember our "Wizard" class from the &lt;a href="https://dev.to/elliezub/magical-c-classes-3heg"&gt;last post&lt;/a&gt;? If not, that's ok, here it is:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Properties&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;Name&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;set&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;House&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;set&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;Pet&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;set&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;int&lt;/span&gt; &lt;span class="n"&gt;Age&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;return&lt;/span&gt; &lt;span class="n"&gt;age&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;if&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;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;age&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="k"&gt;else&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;"Invalid age for a wizard at Hogwarts."&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="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Methods&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CastSpell&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;spellName&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;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; casts &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;spellName&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, if we wanted to add a new "Wizard" we would create a new "draco" object like this:&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="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;draco&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;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Draco Malfoy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Slytherin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hawthorn with a unicorn hair core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Eagle Owl"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But there's an easier way! and that's why we use &lt;strong&gt;constructors&lt;/strong&gt;.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Wizard class with a constructor
&lt;/h3&gt;

&lt;p&gt;Here's how the Wizard class would look with a constructor:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&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;Name&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;set&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;House&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;set&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;Pet&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;set&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;int&lt;/span&gt; &lt;span class="n"&gt;Age&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;return&lt;/span&gt; &lt;span class="n"&gt;age&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;if&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;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;age&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="k"&gt;else&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;"Invalid age for a wizard at Hogwarts."&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="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// constructor &lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;age&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;wandType&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;pet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Method to represent casting a spell&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CastSpell&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;spellName&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;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; casts &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;spellName&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes it much easier to create a new "Wizard" aka a new object:&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="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;draco&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Draco Malfoy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Slytherin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hawthorn with a unicorn hair core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Eagle Owl"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://i.giphy.com/media/ygx8EYsdRkNpu/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/ygx8EYsdRkNpu/giphy.gif" width="245" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Default values
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;But what if we don't know everything about a new "Wizard" at Hogwarts?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Could we just, not enter that info?&lt;/p&gt;

&lt;p&gt;Well, if we did that, this is what would happen.&lt;/p&gt;

&lt;p&gt;First, we have our constructor:&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="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;age&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;wandType&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;pet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pet&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;Then we try to create a new Wizard:&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="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;neville&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Neville Longbottom"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Cherrywood with a unicorn hair core"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Missing the 'pet' parameter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;So.. what happens if we don't include Neville's pet toad?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We will see this error 😱&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error CS7036: There is no argument given that corresponds to the required formal parameter 'pet' of 'Wizard.Wizard(string, string, int, string, string)'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;So.. how can we avoid this?&lt;/em&gt; 🙄&lt;/p&gt;

&lt;p&gt;Well, that's what &lt;strong&gt;default values&lt;/strong&gt; are for!&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="c1"&gt;// look! some default values!&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unknown"&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;house&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unassigned"&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;age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;11&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;wandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Standard"&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;pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unknown"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pet&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 way, if we choose to omit, or forget to assign a value, the code will still run with the value being assigned to the default value. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/hqBsV4bE9LGz6/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/hqBsV4bE9LGz6/giphy.gif" width="245" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Default constructors
&lt;/h3&gt;

&lt;p&gt;Another important topic is &lt;strong&gt;default constructors&lt;/strong&gt; although they sound similar to default values, they serve a different purpose.&lt;/p&gt;

&lt;p&gt;They are the simplest form of constructors which don't take any arguments.&lt;/p&gt;

&lt;p&gt;In some cases, a default constructor might set properties to their default values, or it might leave them to be set later.&lt;/p&gt;

&lt;p&gt;For example, if you want to create a "Wizard" but you don't have all the necessary info, a default constructor allows you to instantiate the object and fill in the details later:&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="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initialize with default values&lt;/span&gt;
    &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unknown"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unassigned"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Default starting age for Hogwarts students&lt;/span&gt;
    &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Standard"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unknown"&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;Then you can create a new "Wizard" like this:&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="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;ginny&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since "ginny" is a new student, we still don't have all of her details. They must be assigned as they become known to the school.&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="c1"&gt;// When Ginny is enrolled, we know her full name&lt;/span&gt;
&lt;span class="n"&gt;ginny&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Ginny Weasley"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Then we assign the rest of the properties as we become aware of them&lt;/span&gt;

&lt;span class="c1"&gt;// After the sorting hat ceremony we find out she is sorted into Gryffindor!&lt;/span&gt;
&lt;span class="n"&gt;ginny&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Then she must register her wand&lt;/span&gt;
&lt;span class="n"&gt;ginny&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Yew with a phoenix feather core"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Later, when she gets a pet, we would update her pet info&lt;/span&gt;
&lt;span class="n"&gt;ginny&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Arnold the Pygmy Puff"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;But this seems a bit tedious, why would I ever use this method over the previously described methods?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well, a default constructor can be particularly useful when you need to create an object without immediately supplying detailed information, it provides the ability to set properties at a later time. &lt;/p&gt;

&lt;p&gt;This is exactly what we did with "ginny", we didn't have all of the information at first so we had to add the new information as we became aware of it.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Constructor overloading
&lt;/h3&gt;

&lt;p&gt;Similar to default values and default constructors, there is something called constructor overloading. We do this when we might not have all the details about a wizard, or maybe we have wizards with different sets of known attributes.&lt;/p&gt;

&lt;p&gt;So.. &lt;strong&gt;&lt;em&gt;what's the difference between all three?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Default values&lt;/strong&gt; and &lt;strong&gt;default constructors&lt;/strong&gt; are useful when you want to fill in missing information automatically. However, &lt;strong&gt;constructor overloading&lt;/strong&gt; makes it possible to create objects with varying sets of initial information from the very beginning.&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&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;Name&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;set&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;House&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;set&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;Pet&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;set&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;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// Intentionally excluding Age for readability&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor for a wizard without a pet&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;wandType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor for a wizard with a pet&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;wandType&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;pet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pet&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor for a foreign wizard where we only know the name and wand type&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;wandType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="c1"&gt;// House and pet might be unknown&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Wizard with a pet&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;hermione&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hermione Granger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Vine wood with a dragon heartstring core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Crookshanks"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Foreign wizard&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;viktor&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Viktor Krum"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Hornbeam"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Can you use default values, default constructors, and constructor overloading at the same time?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Yes! At the end of this post, there will be an example of an ultimate "Wizard" class using everything mentioned in this post. &lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  'this' keyword
&lt;/h3&gt;

&lt;p&gt;What's &lt;strong&gt;&lt;em&gt;this&lt;/em&gt;&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Well, the "this" keyword has two main usecases. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; To avoid confusion ( this.Name = name; )&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&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;Name&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor using the 'this' keyword to differentiate between&lt;/span&gt;
    &lt;span class="c1"&gt;// the parameter 'name' and the class property 'Name'&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 'this.Name' refers to the property 'Name' of the current instance&lt;/span&gt;
        &lt;span class="c1"&gt;// Name = name; can get confusing, so using this.Name can be a bit clearer sometimes&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;&lt;strong&gt;2.&lt;/strong&gt; Constructor chaining ( : this(name) )&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&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;Name&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;set&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;House&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;set&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;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor that takes only Name&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor that takes Name and House, reusing the first constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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="n"&gt;name&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="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor that takes Name, House, and WandType, reusing the second constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;wandType&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="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;house&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="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&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;&lt;em&gt;&lt;strong&gt;What's the point of constructor chaining?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Constructor chaining allows a constructor to call another constructor within the same class to set things up, which keeps the code simple and avoids repetition. Neat, right?&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  'base' keyword
&lt;/h3&gt;

&lt;p&gt;Another keyword?? 🤨&lt;/p&gt;

&lt;p&gt;Yes.. but this one is pretty easy!&lt;/p&gt;

&lt;p&gt;It's very similar to the "this" keyword, except it can help chain info from &lt;strong&gt;other&lt;/strong&gt; classes.&lt;/p&gt;

&lt;p&gt;According to our previous examples, the "Wizard" class represents all students or faculty members at Hogwarts. However, students may also participate in school sports, like Quidditch, which requires keeping track of additional details like the player's position. &lt;/p&gt;

&lt;p&gt;So we would also need to create a "QuidditchPlayer" class that extends the Wizard class because it needs to include all the standard wizard information, plus these extra sports-related attributes. &lt;/p&gt;

&lt;p&gt;This is how that would look:&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="c1"&gt;// Base class for any wizard at Hogwarts&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;Wizard&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;Name&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;set&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;House&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;set&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="nf"&gt;Wizard&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;name&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;house&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&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;// Derived class for a Quidditch player&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;QuidditchPlayer&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Wizard&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;Position&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor sets up a Quidditch player, using 'base' to include the basic wizard setup info&lt;/span&gt;
    &lt;span class="c1"&gt;// The 'base' keyword passes name and house to the Wizard constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;QuidditchPlayer&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;name&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;house&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;position&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;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Position&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;position&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="n"&gt;QuidditchPlayer&lt;/span&gt; &lt;span class="n"&gt;harry&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;QuidditchPlayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Harry Potter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Seeker"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://i.giphy.com/media/uma9yIh0ghkFa/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/uma9yIh0ghkFa/giphy.gif" width="500" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for basic constructors. Here are all of the things we learned together in an ultimate "Wizard" class!&lt;br&gt;
&lt;br&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  ULTIMATE WIZARD CLASS!
&lt;/h3&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;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&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;Name&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;set&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;House&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;set&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;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Default constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unknown"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Unassigned"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Standard"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// 1. Constructor that takes only Name but inherits the defaults from the default constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// 2. Constructor that takes Name and House, reusing constructor 1&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// 3. Constructor that takes Name, House, and WandType, reusing constructor 2&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Wizard&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;name&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;house&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;wandType&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="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;wandType&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;QuidditchPlayer&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Wizard&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;Position&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Default constructor for QuidditchPlayer&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;QuidditchPlayer&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="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Position&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Chaser"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Constructor chaining is used here as well, reusing Wizard's constructor&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;QuidditchPlayer&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;name&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;house&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;wandType&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;position&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;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;house&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wandType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Position&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;position&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;// A lesser-known wizard with minimal information&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;blaise&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Blaise Zabini"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// A member of the Order of the Phoenix with some details known&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;mundungus&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Mundungus Fletcher"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// A fully detailed wizard&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;hermione&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hermione Granger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Vine wood with a dragon heartstring core"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Quidditch player with all properties known&lt;/span&gt;
&lt;span class="n"&gt;QuidditchPlayer&lt;/span&gt; &lt;span class="n"&gt;harry&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;QuidditchPlayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Harry Potter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Holly wood with a phoenix feather core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Seeker"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Example output:&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;$"Wizard: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;blaise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, House: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;blaise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;House&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Wand: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;blaise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WandType&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="c1"&gt;// Output: Wizard: Blaise Zabini, House: Unassigned, Wand: Standard&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;$"Order Member: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mundungus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, House: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mundungus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;House&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Wand: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mundungus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WandType&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="c1"&gt;// Output: Order Member: Mundungus Fletcher, House: Gryffindor, Wand: Standard&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;$"Wizard: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, House: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;House&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Wand: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WandType&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="c1"&gt;// Output: Wizard: Hermione Granger, House: Gryffindor, Wand: Vine wood with a dragon heartstring core&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;$"Quidditch Player: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;harry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, House: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;harry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;House&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Wand: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;harry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WandType&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;, Position: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;harry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Position&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="c1"&gt;// Output: Quidditch Player: Harry Potter, House: Gryffindor, Wand: Holly wood with a phoenix feather core, Position: Seeker&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Challenge (optional)
&lt;/h3&gt;

&lt;p&gt;If you're up for it, I challenge you to make your own constructor that includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default values&lt;/li&gt;
&lt;li&gt;A default constructor&lt;/li&gt;
&lt;li&gt;Constructor overloading&lt;/li&gt;
&lt;li&gt;The 'this' keyword&lt;/li&gt;
&lt;li&gt;The 'base' keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Theme ideas: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Astronomy:&lt;/strong&gt; Classes for celestial objects like Star, Planet, and Asteroid. Properties could include mass, composition, and orbit details.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Magical Beasts:&lt;/strong&gt; A MagicalBeast base class with properties like rarity, danger level, and magical abilities. Subclasses could include Dragon, Phoenix, Basilisk, each with special traits or abilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't be afraid to ask your friendly neighborhood chatGPT for more ideas that align with your personal interests😄&lt;/p&gt;

&lt;p&gt;If you actually do the challenge, please send me the link to your code. I would love to see your solution!&lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/pgTUboKO6i08/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/pgTUboKO6i08/giphy.gif" width="500" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, that's it for this post! If you've made it this far, Hermione certainly would be proud of you. &lt;/p&gt;

&lt;p&gt;In the future, I will be making part 2 which will be about "static constructors", "copy constructors", and "destructors". (Thought it would be a bit overwhelming to add those here)&lt;/p&gt;

&lt;p&gt;If you're looking for more resources to learn how to code check out my &lt;a href="https://elliezub.github.io/Free-Coding-Resources/" rel="noopener noreferrer"&gt;Free Coding Resources&lt;/a&gt; site, it has links to a bunch of my favorite courses/resources!&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;Twitter/X&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>oop</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Magical C# Classes</title>
      <dc:creator>Ellie</dc:creator>
      <pubDate>Thu, 26 Oct 2023 19:02:43 +0000</pubDate>
      <link>https://forem.com/elliezub/magical-c-classes-3heg</link>
      <guid>https://forem.com/elliezub/magical-c-classes-3heg</guid>
      <description>&lt;p&gt;If you're like me and can't seem to wrap your head around "classes" then I hope these magical examples can serve as some kind of reference for the both of us!&lt;/p&gt;

&lt;p&gt;In this post, I'll be using some wizard-themed examples to try and make a reference for myself and others so we can finally "get" classes.&lt;/p&gt;

&lt;p&gt;This post will just cover the basics of classes and objects, there will be further posts explaining more advanced topics.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Classes and Objects
&lt;/h3&gt;

&lt;p&gt;First of all, why do we even need classes?&lt;/p&gt;

&lt;p&gt;To put it simply, they keep related bits of code and info together, so everything is neat and easy to find. Pretty convenient, right?&lt;/p&gt;

&lt;p&gt;Of course, there's a lot more to it than that, I suggest checking out some of these resources to learn more about classes and objects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.codecademy.com/learn/learn-c-sharp-classes-objects-interfaces-and-inheritance" rel="noopener noreferrer"&gt;Codecademy's C# Classes &amp;amp; Objects - free course&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=TzgxcAiHCWA&amp;amp;list=PLdo4fOcmZ0oVxKLQCHpiUWun7vlJJvUiN" rel="noopener noreferrer"&gt;Object Oriented Programming: Objects and Classes - video&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/cs/cs_classes.php" rel="noopener noreferrer"&gt;W3Schools C# Classes and Objects - free course&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After you have an idea about what classes and objects are, check out the "Wizard" class below👇&lt;/p&gt;


&lt;h3&gt;
  
  
  Wizard Class
&lt;/h3&gt;

&lt;p&gt;Imagine you wanted to represent every witch or wizard in the Harry Potter universe. You could create a &lt;strong&gt;class&lt;/strong&gt; to define their common characteristics.&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// This is a backing field for the Age property&lt;/span&gt;

    &lt;span class="c1"&gt;// what's a backing field??😅 see Example 1 below &lt;/span&gt;

    &lt;span class="c1"&gt;// Properties&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;Name&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;set&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;House&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;set&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;Pet&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

   &lt;span class="c1"&gt;// what the heck do get and set do?? see Example 2&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&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;return&lt;/span&gt; &lt;span class="n"&gt;age&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;if&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;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;age&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="k"&gt;else&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;"Invalid age for a wizard at Hogwarts."&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="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;WandType&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;set&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Methods&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;CastSpell&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;spellName&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;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; casts &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;spellName&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;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, "Wizard" is a class that has properties like "Name", "House", "Age", and "WandType". It also has the method "CastSpell" to represent the action of a witch or wizard casting a spell.&lt;/p&gt;

&lt;p&gt;The "age" field is private and is used to store the actual value of a wizard's age. When we want to set or get the age of a wizard, we use the public "Age" property.&lt;/p&gt;

&lt;p&gt;The set accessor in the "Age" property contains logic to validate the age. If someone tries to set an age value less than 11 or more than 150, the class will print an error message, and the age won't be changed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;But why should we have a private AND a public Age? Why do we even need a backing field?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Look at this part of the "Wizard" class again:&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="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Backing field&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&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;return&lt;/span&gt; &lt;span class="n"&gt;age&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;if&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;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;age&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="k"&gt;else&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;"Invalid age for a wizard at Hogwarts."&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;p&gt;We are using a backing field ("age"). The "age" variable is the backing field for the "Age" property. The backing field is necessary here to store the value of "Age" when it's set, and to return the value when it's accessed.&lt;/p&gt;

&lt;p&gt;The key point about using a backing field is that it allows you to have control over how the value is stored and accessed, enabling you to add additional logic (like validation) as needed.&lt;/p&gt;

&lt;p&gt;If you were to try and define the "Age" property without a backing field:&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="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Age&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;return&lt;/span&gt; &lt;span class="n"&gt;Age&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;if&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;&amp;gt;=&lt;/span&gt; &lt;span class="m"&gt;11&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;value&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;Age&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="k"&gt;else&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;"Invalid age for a wizard at Hogwarts."&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;p&gt;You would end up with a recursive call that would result in a StackOverflowException. This happens because when you try to get or set the age, it just ends up trying to get or set the age again, creating an infinite loop.&lt;/p&gt;

&lt;p&gt;Using a backing field avoids this issue, because in the get and set accessors, we have a separate variable (age), not the property itself.&lt;/p&gt;

&lt;p&gt;If this is still confusing, check out &lt;strong&gt;Example 1&lt;/strong&gt; below.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Wizard Objects
&lt;/h3&gt;

&lt;p&gt;Now, if we want to represent both Harry Potter and Hermione Granger in our program, we need to create two &lt;strong&gt;objects&lt;/strong&gt; (or instances) of the "Wizard" class:&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="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;harry&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;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Harry Potter"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Holly with a phoenix feather core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hedwig the owl"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;hermione&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;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Name&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hermione Granger"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;House&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Gryffindor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Age&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;WandType&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Vine wood with a dragon heartstring core"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Pet&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Crookshanks the cat"&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="n"&gt;harry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CastSpell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Expelliarmus"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Output: Harry Potter casts Expelliarmus!&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;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; has a pet named &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;hermione&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Pet&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="c1"&gt;// Output: Hermione Granger has a pet named Crookshanks the cat&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, "harry" and "hermione" are objects of the Wizard class. We set their properties individually, giving each wizard their own unique characteristics. After that, Harry casts a spell using the "CastSpell" method, and we also display the name of Hermione’s pet cat, Crookshanks, using the properties of the "hermione" object.&lt;/p&gt;




&lt;h3&gt;
  
  
  Examples:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Example 1: Backing field
&lt;/h4&gt;

&lt;p&gt;Imagine a backing field as Tom Riddle’s diary.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Diary (Backing Field): Just like how Tom Riddle put his thoughts and secrets into the diary, your private data is stored securely. It’s meant to be accessed and modified only within safe and controlled conditions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tom Riddle's manifestation (Property): If someone at Hogwarts, let's say Ginny, wants to delve into the diary’s mysteries, she wouldn’t directly read from its pages. Instead, she would interact with Tom Riddle’s manifestation, which represents the property in C#. Depending on the circumstances, Tom might alter the information, hold back details, or even choose to remain silent.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In coding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The diary is like the backing field. It holds the actual data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tom’s manifestation acts as the property, controlling access to the diary’s content. Other parts of the code (aka other characters in the story) must communicate with Tom to access or modify the diary's content. However, the ability to access or change the content is based on specific conditions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Example 2: Accessors (get and set)
&lt;/h4&gt;

&lt;p&gt;Think of the thermostat in your home:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;get: When you look at the thermostat, you can see the current room temperature. This is like the get accessor – it allows you to view the value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;set: If you want the room to be warmer or cooler, you adjust the thermostat to the desired temperature. However, there are limits on how high or low you can set the temperature. For example, it might only go as low as 50°F and as high as 90°F. If you try to set it outside these limits, it won't let you. That’s how the set accessor works, the information needs to be validated before it is actually set.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In our "Wizard" class, the "Age" property is similar. When we "get" the age, it's like checking the current temperature. But when we "set" the age, we ensure it's a valid age (between 11 and 150), just as the thermostat ensures the temperature is within its limits.&lt;/p&gt;

&lt;p&gt;Here's a simple wizard example about how get and set work:&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="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Wizard&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;favoriteSpell&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Backing field&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;FavoriteSpell&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;return&lt;/span&gt; &lt;span class="s"&gt;"The favorite spell is: "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;favoriteSpell&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IsNullOrEmpty&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;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;"A wizard must have a favorite spell!"&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;favoriteSpell&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="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;// Using the class&lt;/span&gt;
&lt;span class="n"&gt;Wizard&lt;/span&gt; &lt;span class="n"&gt;ron&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;Wizard&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;ron&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FavoriteSpell&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Wingardium Leviosa"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="c1"&gt;// Sets rons favorite spell&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="n"&gt;ron&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FavoriteSpell&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;      
&lt;span class="c1"&gt;// Gets rons favorite spell &lt;/span&gt;
&lt;span class="c1"&gt;// Output: The favorite spell is: Wingardium Leviosa&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The "FavoriteSpell" property uses get to retrieve and display the wizards favorite spell.&lt;/li&gt;
&lt;li&gt;The set accessor checks if the provided spell is null or empty. If it is, it gives a message that a wizard must have a favorite spell; otherwise, it sets the favorite spell.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, it’s important to note that C# has a shortcut for when you don’t need extra logic in your get or set. Instead of writing out the whole thing with a backing field and validation, you can do something like this:&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="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;Wand&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;set&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;Here, a hidden backing field is automatically created for the "Wand" property. This keeps code concise, but if you need to add validation or other logic, you would need to create a backing field and switch to the full property syntax.&lt;/p&gt;




&lt;p&gt;Well, thats all for this post. I recommend trying to make your own classes and objects. By doing this, you'll deepen your understanding and see how everything fits together. &lt;/p&gt;

&lt;p&gt;If you have any suggestions for how to improve this post or notice anything I have excluded that should be considered basic knowledge when it comes to classes and objects please let me know 😄&lt;/p&gt;

&lt;p&gt;If you're looking for more resources to learn how to code check out my &lt;a href="https://elliezub.github.io/Free-Coding-Resources/" rel="noopener noreferrer"&gt;Free Coding Resources&lt;/a&gt; site, it has links to a bunch of my favorite courses/resources!&lt;/p&gt;

&lt;p&gt;If you have any questions or want to connect, the best place to reach me is on &lt;a href="https://twitter.com/elliezub" rel="noopener noreferrer"&gt;Twitter/X&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>beginners</category>
      <category>learning</category>
      <category>oop</category>
    </item>
  </channel>
</rss>
