﻿{"id":54,"date":"2022-11-29T11:50:00","date_gmt":"2022-11-29T11:50:00","guid":{"rendered":"https:\/\/demo.rivaxstudio.com\/roxeen\/creative\/?p=54"},"modified":"2026-03-18T12:34:38","modified_gmt":"2026-03-18T17:34:38","slug":"the-basics-of-coding","status":"publish","type":"post","link":"https:\/\/www.paulhreid.com\/the-basics-of-coding\/","title":{"rendered":"The Basics of Coding"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We are in an era where any person can think they can code, even if the code was copied from StackOverflow or Github. The fundamentals are being by-passed for quick and pretty outputs at the expense of security and efficiency. Real coders understand the fundamentals.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Even in the era of &#8220;vibe coding&#8221; and AI agents, these fundamentals are the &#8220;physics&#8221; of software. If you don&#8217;t understand them, you won&#8217;t know how to fix the AI when it inevitably drifts off course.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of these as the universal building blocks that apply whether you are writing Python, JavaScript, C# or C++.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Logic and Control Flow<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is the &#8220;brain&#8221; of your code. It determines the path the program takes based on specific conditions.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Boolean Logic: Understanding TRUE, FALSE, and operators like AND (&amp;&amp;), OR (||), and NOT (!).<\/li>\n\n\n\n<li>Conditionals (if\/else, switch): Directing the program to do X if a condition is met, or Y if it isn&#8217;t.<\/li>\n\n\n\n<li>Loops (for, while): Running the same block of code multiple times.\n<ul class=\"wp-block-list\">\n<li>Peer Tip: Be careful with &#8220;infinite loops&#8221; where the exit condition is never met\u2014this is a classic way to crash your browser or server!<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Variables and Data Types<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Variables are containers for storing information. You must know what kind of data you are moving around.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Primitives: * String: Text (e.g., &#8220;Hello World&#8221;).<\/li>\n\n\n\n<li>Integer\/Float: Numbers (e.g., 42 or 3.14).<\/li>\n\n\n\n<li>Boolean: True\/False.<\/li>\n\n\n\n<li>Collections: * Arrays\/Lists: Ordered groups of items (e.g., [Apple, Banana, Cherry]).<\/li>\n\n\n\n<li>Objects\/Dictionaries: Key-value pairs (e.g., { name: &#8220;Paul&#8221;, role: &#8220;Project Manager&#8221; }).<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Data Structures<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This is how you organize data for efficiency. Choosing the wrong structure can make a program painfully slow.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stacks and Queues: Last-In-First-Out (LIFO) vs. First-In-First-Out (FIFO).<\/li>\n\n\n\n<li>Trees and Graphs: Used for hierarchical data (like a folder system) or networked data (like social media connections).<\/li>\n\n\n\n<li>Hash Maps: Essential for lightning-fast data retrieval.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Functions and Scope<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Functions allow you to wrap a piece of logic into a reusable &#8220;package.&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input\/Output: Passing &#8220;arguments&#8221; into a function and getting a &#8220;return&#8221; value back.<\/li>\n\n\n\n<li>Scope: Understanding that a variable created inside a function usually can&#8217;t be seen outside of it. This prevents &#8220;variable collisions&#8221; where different parts of your code accidentally overwrite each other.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">The &#8220;Big Three&#8221; Patterns<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">As you move beyond the basics, you&#8217;ll encounter these architectural styles:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Procedural: Code runs line-by-line in a sequence.<\/li>\n\n\n\n<li>Object-Oriented (OOP): Organizing code into &#8220;Objects&#8221; (e.g., a User object has a name, email, and a login() function).<\/li>\n\n\n\n<li>Functional: Treating code like mathematical formulas to avoid changing the &#8220;state&#8221; of the program unexpectedly.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Version Control (Git)<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">In modern, Git is non-negotiable. It is your &#8220;Undo&#8221; button and your collaboration tool. You should know:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Commit: Saving a snapshot of your work.<\/li>\n\n\n\n<li>Push\/Pull: Moving code to and from a server (like GitHub).<\/li>\n\n\n\n<li>Branching: Creating a &#8220;parallel universe&#8221; to test a new feature without breaking the main app.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Error Handling &amp; Debugging<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The best coders aren&#8217;t the ones who never make mistakes; they are the ones who find them the fastest.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Try\/Catch blocks: Telling the code what to do if it hits an error so the whole app doesn&#8217;t crash.<\/li>\n\n\n\n<li>Debugging: Using &#8220;Print statements&#8221; or &#8220;Breakpoints&#8221; to pause the code and see exactly what the variables look like at that moment.\n<ul class=\"wp-block-list\">\n<li>Peer Note: If you are &#8220;vibe coding,&#8221; focus heavily on Data Structures and Git. The AI is great at syntax (the &#8220;grammar&#8221;), but it often struggles with the high-level organization of data and versioning.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-cyan-bluish-gray-color has-alpha-channel-opacity has-cyan-bluish-gray-background-color has-background is-style-wide\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">Applying what we just learnt (using C#)<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">C# is the backbone of enterprise software, game development (Unity), and robust web APIs. It is a statically typed language, meaning it\u2019s stricter than Python or JavaScript, which actually makes it better for learning the &#8220;basics&#8221; because it forces you to be explicit.<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>using System;\nusing System.Collections.Generic;\n\nnamespace CodingBasics\n{\n    \/\/ 5. OOP: This 'class' is a blueprint for a Weather Report object\n    public class WeatherReport\n    {\n        public string City { get; set; }\n        public double Temperature { get; set; } \/\/ 2. Data Type: Double (for decimals)\n    }\n\n    class Program\n    {\n        static void Main(string&#91;] args)\n        {\n            \/\/ 2. Variables &amp; Collections\n            string appName = \"VibeCheck Weather\"; \n            List&lt;WeatherReport&gt; reports = new List&lt;WeatherReport&gt;();\n\n            \/\/ 1. Control Flow: A simple loop to \"collect\" data\n            for (int i = 0; i &lt; 2; i++)\n            {\n                Console.WriteLine($\"Enter City {i + 1}:\");\n                string inputCity = Console.ReadLine();\n\n                \/\/ 7. Error Handling: Try\/Catch for bad numeric input\n                try \n                {\n                    Console.WriteLine($\"Enter Temp for {inputCity}:\");\n                    double inputTemp = Convert.ToDouble(Console.ReadLine());\n\n                    \/\/ Adding an object to our list (Data Structure)\n                    reports.Add(new WeatherReport { City = inputCity, Temperature = inputTemp });\n                }\n                catch (FormatException)\n                {\n                    Console.WriteLine(\"Invalid temperature! Skipping this entry.\");\n                }\n            }\n\n            \/\/ 4. Function Call: Processing the data\n            DisplayAnalysis(reports);\n        }\n\n        \/\/ 4. Function Definition: Logic wrapped in a reusable block\n        static void DisplayAnalysis(List&lt;WeatherReport&gt; data)\n        {\n            Console.WriteLine(\"\\n--- Analysis ---\");\n            foreach (var report in data)\n            {\n                \/\/ 1. Boolean Logic &amp; Conditionals\n                string feel = (report.Temperature &gt; 25) ? \"Hot\" : \"Cold\"; \n                \n                if (report.Temperature &gt; 30 &amp;&amp; report.City == \"Kingston\") \n                {\n                    Console.WriteLine($\"{report.City} is sweltering at {report.Temperature}\u00b0C!\");\n                }\n                else \n                {\n                    Console.WriteLine($\"{report.City}: {report.Temperature}\u00b0C ({feel})\");\n                }\n            }\n        }\n    }\n}\n\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Breaking Down the C# Specifics<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Static Typing (The &#8220;Safety Net&#8221;)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">In C#, you can&#8217;t just say x = 5. You usually say int x = 5;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why it matters: This prevents the AI (or you) from accidentally trying to &#8220;multiply a word by a number,&#8221; which is a common cause of crashes in more flexible languages.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Classes and Namespaces<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">C# organizes everything into Classes (blueprints) and Namespaces (drawers to keep those blueprints organized).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The &#8220;Vibe&#8221; Tip: When using AI to generate C#, always check the using statements at the top. If the AI suggests a library you don&#8217;t have installed, the code won&#8217;t even compile.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Memory Management (The Stack vs. Heap)<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">C# uses a Garbage Collector.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Concept: You don&#8217;t have to manually delete data when you&#8217;re done with it (unlike in C++). The language &#8220;cleans up&#8221; after itself. However, knowing the difference between a Value Type (stored on the Stack, fast\/temporary) and a Reference Type (stored on the Heap, flexible\/long-lived) is a key &#8220;Senior&#8221; skill.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udcc8 Your Learning Roadmap for C#<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Level 1: Master the Console (Input\/Output).<br><br>Level 2: Learn LINQ (Language Integrated Query). This is a C# &#8220;superpower&#8221; that lets you filter and sort data lists with very little code.<br><br>Level 3: Explore Asynchronous Programming (async\/await). Essential for modern apps so the UI doesn&#8217;t &#8220;freeze&#8221; while the app fetches data.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-cyan-bluish-gray-color has-alpha-channel-opacity has-cyan-bluish-gray-background-color has-background is-style-wide\"\/>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are in an era where any person can think they can code, even if the code was copied from StackOverflow or Github. The fundamentals are being by-passed for quick and pretty outputs at the expense of security and efficiency. Real coders understand the fundamentals.<\/p>\n","protected":false},"author":1,"featured_media":930,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[84,95,81,97],"class_list":["post-54","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-coding","tag-programming","tag-technology","tag-thought-provoking"],"_links":{"self":[{"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":0,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/posts\/54\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paulhreid.com\/api-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}