<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lorraine Moyo</title>
    <description>The latest articles on DEV Community by Lorraine Moyo (@lorrainemoyo).</description>
    <link>https://dev.to/lorrainemoyo</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%2F742957%2Ff7d6a2d5-4322-45f7-b85a-c30b8ec33c58.png</url>
      <title>DEV Community: Lorraine Moyo</title>
      <link>https://dev.to/lorrainemoyo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lorrainemoyo"/>
    <language>en</language>
    <item>
      <title>Should I refractor?</title>
      <dc:creator>Lorraine Moyo</dc:creator>
      <pubDate>Mon, 19 Aug 2024 21:07:34 +0000</pubDate>
      <link>https://dev.to/lorrainemoyo/should-i-refractor-3bfg</link>
      <guid>https://dev.to/lorrainemoyo/should-i-refractor-3bfg</guid>
      <description>&lt;p&gt;When dealing with spaghetti code at work, you generally have two primary options: refactoring the code or trying to understand and maintain it as is. Here's a breakdown of the pros and cons of each approach:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1: Refactoring the Code&lt;br&gt;
Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Improved Code Quality&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easier to maintain in the future&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Increased stability&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Time-consuming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Risk of introducing new bugs**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Possible downtime&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires deep service knowledge&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Option 2: Understanding and Maintaining the Existing Code&lt;br&gt;
Pros:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Service continuity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Preservation of legacy logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Good for short term&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cons&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Maintaining the service is a headache&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Decreased developer morale&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Underlying issues increase&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What do you guys do when faced with a new service that will potentially be your baby to take care of?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Choosing a python framework</title>
      <dc:creator>Lorraine Moyo</dc:creator>
      <pubDate>Mon, 08 Jan 2024 15:20:34 +0000</pubDate>
      <link>https://dev.to/lorrainemoyo/choosing-a-python-framework-1966</link>
      <guid>https://dev.to/lorrainemoyo/choosing-a-python-framework-1966</guid>
      <description>&lt;p&gt;I've recently switched to a new role and moved away from the tedious CRUD operations and moved onto data transformations and more interesting things in the world of python and I think at some point I lost my passion bc it was all work and no play work. I had no motivation to actually create something - I still don't but I believe I will find it along this learning journey.&lt;/p&gt;

&lt;p&gt;You get people who know what they want from the word go and then you get us who figure it out along the way. We just ensure the car has enough fuel, enough money in the bank account to book accomodation in some little town we'll find along the journey and we just drive. Call it unprepped, call it winging it - call it whatever but lets start this journey&lt;/p&gt;

&lt;p&gt;So I don't know what kinda app I want to build. The only spec I know is that it's going to be data intensive. I already know about django and fastapi.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conditions to consider when choosing a framework
&lt;/h2&gt;

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

&lt;p&gt;For me as someone who is building a personal project in terms of learning and becoming a better dev - I'd say my most important conditions would be &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Performance&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will elaborate on the above points with the comparison between Django and Fast API&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting up one-to-many &amp; many-to-many relationships in Entity Framework Core</title>
      <dc:creator>Lorraine Moyo</dc:creator>
      <pubDate>Mon, 24 Oct 2022 12:54:29 +0000</pubDate>
      <link>https://dev.to/lorrainemoyo/setting-up-relational-databases-in-entity-framework-core-n6i</link>
      <guid>https://dev.to/lorrainemoyo/setting-up-relational-databases-in-entity-framework-core-n6i</guid>
      <description>&lt;p&gt;The Entity Framework is one of my favorite Object Relational Mapping Tools. It has extensive support for schema migrations, and change tracking and it also supports LINQ Queries.&lt;/p&gt;

&lt;p&gt;It also works with one of my favorite SQL databases; SQLite. &lt;br&gt;
What's there not to love about the Entity Framework Core? It is especially great when your want to focus on the application logic because EFC will automatically generate the SQL code for you.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04rda9j6ka2g000zd26h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04rda9j6ka2g000zd26h.png" alt="Love Entity Framework Core" width="269" height="303"&gt;&lt;/a&gt; What's there not to love about the Entity Framework Core? It is especially great when your want to focus on the application logic because EFC will automatically generate the SQL code for you.&lt;/p&gt;

&lt;p&gt;In order to ensure that the Entity Framework Core generates accurate SQL code, you must have well-written model classes that clearly state the relationships between the entities&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's get to the meat of this article
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Relational Databases&lt;/strong&gt; reduce duplication, let's say we have a Gym data records table that has athlete's, workouts, and personal trainers; &lt;br&gt;
if the data is recorded in a non-relational approach we would have a long list of different Athletes that do the same Workouts, with the same Personal Trainer. &lt;/p&gt;

&lt;p&gt;This means that if 50 Athletes attended a workout called Cardio, held by one personal trainer, we would have to record the workout classes and the personal trainer's name 50 times, God Forbid the Personal Trainer's name changes and now we must update the 50 duplicate occurrences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Relational Databases have entities&lt;/strong&gt; such as Athlete, Workout Plan, and Personal Trainer that relate to one another by Foreign Keys, and together they make managing data easier and less prone to errors&lt;/p&gt;
&lt;h2&gt;
  
  
  One-to-Many Relationships
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;One-to-many relationships&lt;/strong&gt; look at two unique entities/tables for example a Personal-Trainer and a Workout Class&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lsfux61mhjccg88djo3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8lsfux61mhjccg88djo3.png" alt="One-to-Many Relationship tables" width="800" height="456"&gt;&lt;/a&gt;&lt;br&gt;
A single Personal Trainer can conduct multiple workout classes and that forms our one-to-many relationship.&lt;br&gt;
To show this one-to-many relationship for the Entity Framework to generate our SQL code our Model classes should look like this:&lt;/p&gt;

&lt;p&gt;The Personal Trainer Model creates a &lt;strong&gt;collection of Workout&lt;/strong&gt; Model&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public class PersonalTrainer
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
        public ICollection&amp;lt;Workout&amp;gt; Workouts { get; set; }

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

&lt;/div&gt;



&lt;p&gt;The Workout Model class declares the &lt;strong&gt;Foreign Key and adds a navigation property of Workout.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Workout
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public int MetabollicEquivalent { get; set; }
        public int Duration { get; set; }
        public int PersonalTrainerId { get; set; }
        public PersonalTrainer PersonalTrainer { get; set; } 

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A cheat method that I like to use&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First I create an Entity Diagram showing the one-to-many relationship&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The entity that is "One" always has a Collection of the "Many" entity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The "Many" Entity will have a Foreign Key&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fysvxrm6ka3d7pcze82tw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fysvxrm6ka3d7pcze82tw.png" alt="ERD of one-to-many diagram" width="670" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Many-to-Many Relationships
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Many-to-Many relationships&lt;/strong&gt; are actually entities that have a one-to-many relationship between them both ways. For example a Workout can have multiple Athletes and Athletes can do multiple Workouts. This relationship is represented by creating a join table and then relating the entities to the join on a one-to-many relationship as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq49uys96l8z98849g425.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq49uys96l8z98849g425.png" alt="ERD for many-to-many diagrams" width="800" height="228"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Easy right!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now to configure a model for such a relationship is just as simple:&lt;br&gt;
The Athlete class will create a collection of the Join Table That We will create called AthleteWorkout&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Athlete
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Surname { get; set; }
        public decimal Weight { get; set; }
        public decimal Height { get; set; }
        public DateTime StartDate { get; set; }
        public ICollection&amp;lt;AthleteWorkout&amp;gt; AthleteWorkouts { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and Workout class will do the same&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public class Workout
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public int MetabollicEquivalent { get; set; }
        public int Duration { get; set; }
        public int PersonalTrainerId { get; set; }
        public PersonalTrainer PersonalTrainer { get; set; } 

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

&lt;/div&gt;



&lt;p&gt;Then the join table AthleteWorkout class will have the navigation properties of both Athlete and Workout and their Foreign Keys&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class AthleteWorkout
    {
        public int ID { get; set; }
        public int AthleteId { get; set; }
        public Athlete Athlete { get; set; }
        public int WorkoutId { get; set; }
        public Workout Workout { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Understanding how relationships work is fundamental when you have to create the joins and navigation properties of Models. &lt;/p&gt;

&lt;p&gt;In the next article, I will look at how we configure the models that we created for our ApplicationDbContext class.&lt;/p&gt;

</description>
      <category>database</category>
      <category>csharp</category>
      <category>aspnet</category>
      <category>entityframeworkcore</category>
    </item>
    <item>
      <title>Opensource Newbie</title>
      <dc:creator>Lorraine Moyo</dc:creator>
      <pubDate>Tue, 02 Nov 2021 08:23:21 +0000</pubDate>
      <link>https://dev.to/lorrainemoyo/opensource-newbie-16g2</link>
      <guid>https://dev.to/lorrainemoyo/opensource-newbie-16g2</guid>
      <description>&lt;p&gt;I often ask myself when will I ever stop referring to myself as a code newbie when I have been in the world of coding for the past 4 years. There are so many aspects to explore in this coding universe of ours that I find myself constantly being a newbie at something. I have decided to embark on a personal journey with open source and it feels completely new - I know nothing - Even after watching 10 tutorials. 4 months into my job as a low-code front end developer and I still feel like a newbie. &lt;/p&gt;

&lt;p&gt;As I embark on this open source journey I hope you will enjoy the ride with me, and hopefully by the end of this year I will be blogging about how I successfully contributed to open source and put my name out there.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
