<?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: VirginieLemaire</title>
    <description>The latest articles on DEV Community by VirginieLemaire (@virginiel).</description>
    <link>https://dev.to/virginiel</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%2F660024%2F7701ae24-0d47-4a2a-bf6b-3ec394792347.jpeg</url>
      <title>DEV Community: VirginieLemaire</title>
      <link>https://dev.to/virginiel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/virginiel"/>
    <language>en</language>
    <item>
      <title>Comprendre le concept des boucles (sans code)</title>
      <dc:creator>VirginieLemaire</dc:creator>
      <pubDate>Sun, 10 Mar 2024 10:26:43 +0000</pubDate>
      <link>https://dev.to/virginiel/comprendre-le-concept-des-boucles-sans-code-4c9o</link>
      <guid>https://dev.to/virginiel/comprendre-le-concept-des-boucles-sans-code-4c9o</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Quand on débute le dev, il peut parfois être compliqué de comprendre les boucles. On se concentre trop sur la syntaxe, sans comprendre l'intérêt même de la boucle. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Si je ne comprends pas à quoi va me servir une boucle, je vais avoir du mal à l'utiliser, encore plus à choisir laquelle utiliser.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Je propose de faire un petit tour sur l'avantage des boucles en prenant exemple dans la vie de tous les jours. Car , oui, dans la vie, on passe son temps à faire des boucles 😉&lt;/p&gt;

&lt;p&gt;On s'est tous retrouvés au moins une fois dans cette situation où on doit préparé les sandwichs, les saucisses pour le barbecue, les goûters... pour un groupe de personnes. Si ça ne t'es jamais arrivé, je pense que tu n'auras tout de même aucun mal à te représenter la situation !&lt;/p&gt;

&lt;p&gt;Exemple de la vie courante utilisé dans cet article : &lt;strong&gt;créer des sandwichs pour un groupe de personnes.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Convention
&lt;/h2&gt;

&lt;p&gt;Voici les  protagonistes de notre "histoire" :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;👤 : 1 personne.&lt;/li&gt;
&lt;li&gt;👤👤👤👤👤 : le groupe de personnes.&lt;/li&gt;
&lt;li&gt;🤔 : un bonhomme (qui réfléchi ou pense à une personne).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Le sandwich 🥪 sera composé de pain 🍞 , salade 🥗,  jambon 🥓, tomate 🍅 puis pain 🍞 à nouveau. &lt;/p&gt;

&lt;p&gt;J'utiliserai la flèche → pour représenter des étapes.&lt;/p&gt;

&lt;p&gt;On partira du principe que je dois expliquer à quelqu'un comment s'y prendre.&lt;/p&gt;

&lt;h2&gt;
  
  
  Préparer les sandwichs, sans les boucles
&lt;/h2&gt;

&lt;p&gt;Si c'est la tout première fois que mon bonhomme fait ça, je vais sûrement devoir lui expliquer en répétant chaque étape. Je lui dis donc que pour s'assurer qu'il prépare un sandwich par personne il va :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;penser à une personne (🤔 → 👤), &lt;/li&gt;
&lt;li&gt;lui préparer son sandwich (🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪) pour obtenir le résultat (🥪👤), &lt;/li&gt;
&lt;li&gt;puis il va penser à la personne suivante, &lt;/li&gt;
&lt;li&gt;lui préparer son sandwicc,&lt;/li&gt;
&lt;li&gt;etc. 
Il devra régulièrement regarder s'il reste des personnes sans sandwich pour savoir s'il faut continuer à préparer des sandwichs (🤔 →👤❌🥪 ?). &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour simplifier, je ne mettrai l'étape de vérification qu'à la fin.&lt;/p&gt;

&lt;p&gt;Voici la séquence pour un groupe de 5 personnes :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Pour la 1ère personne :&lt;br&gt;
🤔 → 👤 → 🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;br&gt;
Pour la 2ème personne :&lt;br&gt;
🤔 → 👤 → 🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;br&gt;
Pour la 3ème personne :&lt;br&gt;
🤔 → 👤 → 🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;br&gt;
Pour la 4ème personne :&lt;br&gt;
🤔 → 👤 → 🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;br&gt;
Pour la 5ème personne :&lt;br&gt;
🤔 → 👤 → 🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;br&gt;
Une petite vérification :&lt;br&gt;
🤔 →👤❌🥪 ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Rien qu'avec cette séquence, on peut voir que c'est fastidieux. Tu te dis même sûrement déjà que j'aurais pu faire plus simple. Tu aurais d'ailleurs fait autrement, sans même trop y réfléchir. Hé bien ! Sans le savoir tu aurais fait une boucle. Voyons-ça !&lt;/p&gt;

&lt;h2&gt;
  
  
  Préparer les sandwichs, avec des boucles
&lt;/h2&gt;

&lt;p&gt;On remarque assez facilement qu'il y a des choses qui se répètent dans la séquence ci-dessus. Pour éviter de redonner les instructions à chaque fois, on peut imaginer que je lui explique comme ceci : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;calcule le nombre de personnes, &lt;/li&gt;
&lt;li&gt;crée un sandwich pour chaque personne, &lt;/li&gt;
&lt;li&gt;répète le point 2 jusqu'à ce que le nombre de sandwichs corresponde au nombre de personnes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Voici la séquence :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Calcule le nombre de personnes : 🤔 → 👤 + 👤 + 👤 + 👤 + 👤 = 5&lt;/p&gt;

&lt;p&gt;Boucle jusqu'à arriver à 5 : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;/li&gt;
&lt;li&gt;compte 1 sandwich&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ca revient au même que compter avec des petits bâtons.&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%2Fwzt30vqxt19n6tzkjwl1.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%2Fwzt30vqxt19n6tzkjwl1.png" alt="Image description" width="138" height="139"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;C'est tout de même beaucoup plus simple ! Non ?&lt;/p&gt;

&lt;p&gt;On aurait aussi pu imaginer une autre explication :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;crée une liste à cocher des personnes qui ont besoin d'un sandwich&lt;/li&gt;
&lt;li&gt;prépare un sandwich&lt;/li&gt;
&lt;li&gt;coche la personne à qui va le sandwich
Recommence les étapes 2 et 3 tant qu'il reste des cases à cocher&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;Boucle 1 : pour chaque personne&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;☐ 👤 &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Boucle 2 :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍞 + 🥗 + 🥓 + 🍅 + 🍞 → 🥪👤&lt;/li&gt;
&lt;li&gt;✅👤&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ce qui revient à faire une liste des personnes et cocher au fur et à mesure&lt;/p&gt;

&lt;h2&gt;
  
  
  Des boucles imbriquées
&lt;/h2&gt;

&lt;p&gt;Pour m'assurer qu'il n'oublie aucun ingrédient, je pourrais lui proposer d'y aller par étapes : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;préparer autant de pain que de personnes, &lt;/li&gt;
&lt;li&gt;puis ajouter la salade sur chaque pain, &lt;/li&gt;
&lt;li&gt;puis le jambon etc.&lt;/li&gt;
&lt;li&gt;et enfin distribue les sandwichs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On aurait par exemple cette séquence :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Calcule le nombre de personnes : 🤔 → 👤 + 👤 + 👤 + 👤 + 👤 = 5&lt;/p&gt;

&lt;p&gt;Boucle 1 : Prépare le pain pour le nombre de personnes :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍞 + 🍞 + 🍞 + 🍞 + 🍞&lt;/li&gt;
&lt;li&gt;boucle 2 : Sur chaque pain :

&lt;ul&gt;
&lt;li&gt;+ 🥗&lt;/li&gt;
&lt;li&gt;+ 🥓&lt;/li&gt;
&lt;li&gt;+ 🍅 &lt;/li&gt;
&lt;li&gt;+ 🍞&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;🥪👤&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Cette méthode peut paraitre plus longue mais permet assez facilementde moduler les sandwichs selon les préférences et/ou intolérances de chacun par exemple 😉&lt;/p&gt;

&lt;p&gt;Tu peux retrouver des &lt;a href="https://www.instagram.com/p/C4VIi55oXpY/?utm_source=ig_web_copy_link&amp;amp;igsh=MzRlODBiNWFlZA=="&gt;slides reprenant ces exemples sur insta&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;J'espère que ces exemples de la vie courante t'auront permis de démystifier  les boucles. Je pourrai te proposer un article qui te donne la syntaxe javaScript pour chaque exemple. Ca te dit ?&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>development</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Understanding the Difference between Active Record and Data Mapper with a Cooking Analogy (and no coding)</title>
      <dc:creator>VirginieLemaire</dc:creator>
      <pubDate>Sun, 10 Dec 2023 22:46:20 +0000</pubDate>
      <link>https://dev.to/virginiel/understanding-the-difference-between-active-record-and-data-mapper-with-a-cooking-analogy-and-no-coding-1dln</link>
      <guid>https://dev.to/virginiel/understanding-the-difference-between-active-record-and-data-mapper-with-a-cooking-analogy-and-no-coding-1dln</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Understanding the differences between Active Record and Data Mapper patterns isn't easy. &lt;br&gt;
They're both design patterns commonly used in software development to interact with database. They both have pros and cons, making them suitable for different scenarios. And guess what? They're both cool!&lt;/p&gt;

&lt;p&gt;As a development student, later as a developer myself, and then as a Teacher Assistant, I struggled to grasp these differences clearly. Articles and developers often explained them using technical jargon, making it challenging for me to find the right analogy to explain them in a simply way to my development students.&lt;/p&gt;

&lt;p&gt;I think I found it, so I'd like to share it with you, as some 'non-tech' explanations, so that the light 💡 can come to you too. You'll tell me 😉&lt;/p&gt;

&lt;p&gt;I hope this will help 🤗&lt;/p&gt;

&lt;h2&gt;
  
  
  Advice
&lt;/h2&gt;

&lt;p&gt;To fully grasp and appreciate this cooking analogy, it's recommended that you have some prior knowledge or practical experience with both the Active Record and Data Mapper patterns. &lt;br&gt;
While I won't dive into code in this discussion, having a basic understanding of these patterns will enhance your ability to relate the culinary comparisons to their software development counterparts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;I won't explain what Active Record and Data Mapper are since my purpose is to help you visualize the difference between the two.&lt;br&gt;
To anchor our analogy in the world of code, let's consider the backdrop of a Model-View-Controller (MVC) architecture, a common structure used in software development. &lt;br&gt;
Every time my students doesn't wrap around a concept, I try to make a cooking analogy.&lt;br&gt;
So... let's go cooking !&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's cook with the two patterns!
&lt;/h2&gt;

&lt;p&gt;Active Record and Data Mapper can help cooking the same delicious meals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Active Record: the Cooking Robot
&lt;/h3&gt;

&lt;p&gt;Active Record is like a cooking robot where you put all the ingredients inside, select a program, and the robot takes care of the entire cooking process. &lt;br&gt;
The robot knows how to handle both the ingredients (data) and the cooking process (database operations) to create a delicious meal. &lt;/p&gt;

&lt;p&gt;There are many cooking robots, for each kind of dish (database table) : soup, pastry, ice cream...&lt;br&gt;
As a developer, you'll create one "cooking robot" for each table of the database and you'll give instructions for awaiting datas and methods to "cook".&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Mapper : the Recipes
&lt;/h3&gt;

&lt;p&gt;Data Mapper is like having a recipe book or folder. You have predefined instructions on how to prepare ingredients (data) and how to cook them (database operations) to create the same delicious meal. You just have to follow the guidelines!&lt;/p&gt;

&lt;p&gt;You can write your recipes on sheets of paper, or on a book... You can store it wherever you want (unless you know where to find it 😉) You're quite free !&lt;br&gt;
As a developer, you can deal with data and methods to interact with database the way you want: you can separate them and organize the way you want !&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros and Cons of Those "Cooking" Patterns
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Active Record is like an all-in-one solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;➕ : You don't have to worry; you'll always find your cooking robot ready to cook for you in one place (one model per table), "no more dishes to wash". Super easy to use!&lt;/p&gt;

&lt;p&gt;➖ : There is not much room for changes or improvisation. Your robot is waiting for specific ingredients; it will cook them as it knows. If a meal is attached to a specific type of dish or has to be prepared in a specific container, you won't have a choice: you have to follow the instructions (it's for your own good if you want your delicious meal).&lt;br&gt;
➖ : If you decide to cook with gas instead of electricity (changing the type of database), you may have to program a new robot!&lt;br&gt;
➖ : Also, if you decide to change the cooking container (modify the database structure), it can be a significant task. You might need to reprogram the entire cooking robot to fit the new container, making it less flexible with different database structures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Mapper is the flexible solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;➕ : You really choose the way you organize your recipes! You like to have files in a box? You prefer a folder containing pieces of sheets, or maybe write in a notebook. No problem. You can deal with it! Maybe you want to organize your recipes in alphabetical order, or by the type of dish, or related to events, or by ingredients... Imagination is the limit! &lt;br&gt;
➕ : If you have to cook one recipe with gas instead of electricity (changing the type of database), you'll just have to change the cooking instructions in your recipes, not the ingredients and the rest of the instructions. &lt;br&gt;
➕ : You may even decide to use a different container (representing a different database) for cooking, offering additional flexibility.&lt;/p&gt;

&lt;p&gt;➖ : If you're not very organized, it might be difficult to find that recipe you're looking for 😅.&lt;br&gt;
➖ : Think about future : if you're having a few recipes for now, it might be a great book one day. You'd better anticipate !&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope these culinary comparisons have helped you better understand the differences between Active Record and Data Mapper patterns!&lt;/p&gt;

&lt;p&gt;Your feedback is valuable. If you found this explanation helpful, or if you have suggestions for improvement, please let me know! 😉&lt;/p&gt;

</description>
      <category>development</category>
      <category>database</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
