<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Brian Bissette on Medium]]></title>
        <description><![CDATA[Stories by Brian Bissette on Medium]]></description>
        <link>https://medium.com/@bbissette3?source=rss-2e81a420702c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RNL7XUnDdGgk48U5qn3q6g.jpeg</url>
            <title>Stories by Brian Bissette on Medium</title>
            <link>https://medium.com/@bbissette3?source=rss-2e81a420702c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 06:11:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bbissette3/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating a PostgreSQL database on AWS!]]></title>
            <link>https://medium.com/@bbissette3/creating-a-postgresql-database-on-aws-63f9b3a9c8cd?source=rss-2e81a420702c------2</link>
            <guid isPermaLink="false">https://medium.com/p/63f9b3a9c8cd</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Brian Bissette]]></dc:creator>
            <pubDate>Wed, 24 May 2023 01:26:24 GMT</pubDate>
            <atom:updated>2023-05-24T01:28:21.064Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*zHpWO2926r9n4cBggFS8gQ.png" /></figure><p><strong>Introduction</strong></p><p>Effective data management and safe data storage are essential for businesses and organizations of all sizes in today’s data-driven environment. PostgreSQL has become a reliable and well-liked option for managing relational databases. A PostgreSQL database can be easily created and hosted when using the strength and adaptability of Amazon Web Services (AWS).</p><p>I will walk you through every step of setting up a PostgreSQL database on AWS in this extensive manual. By the end of this lesson, whether you’re an experienced developer or a novice, you’ll have the skills and confidence to build and administer your own PostgreSQL database in the AWS environment. So let’s dive in and learn more about PostgreSQL on AWS to realize its promise for reliable performance and effective data management.</p><p><strong>Step 1:</strong></p><p>You can find the AWS website <a href="https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fconsole.aws.amazon.com%2Fconsole%2Fhome%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26nc2%3Dh_ct%26src%3Dheader-signin%26state%3DhashArgsFromTB_us-east-2_aca9421e231ced97&amp;client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fcanvas&amp;forceMobileApp=0&amp;code_challenge=K-GcpvQlph8sUb8fIaL4B1989p13AQYlWPb2p86nuwQ&amp;code_challenge_method=SHA-256">here</a>. Once you have navigated to the AWS website you can either create an account or login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMju6Dx8OssKR6xX2WKg7Q.png" /></figure><p>After you have created an account (if you did not have one already) you can log in and you will see the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ixRrHRxI9oscR0CngUTU1g.png" /></figure><p><strong>Step 2</strong></p><p>Once you are here it is easiest to navigate to the Relational Database Service (RDS) by searching for it on the search bar.</p><p>Now that you are on the RDS page you will see a new navigation on the left side where you can click on Databases to navigate to the databases that you either already have or to create a new one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*ZRuH_RMco_rb3vIUZM62aQ.png" /></figure><p><strong>Step 3</strong></p><p>The Databases is where you can manage the databases that you have as well as create new ones. Now click on the Create Database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0YtU5es-xDl1SXNyJC2Fw.png" /></figure><p>Now you can start to create our Database. I recommend doing the standard create. This will allow you to make changes to your preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*2zBJUV5vfu-CHb5WkkG9Fw.png" /></figure><p><strong>Step 4</strong></p><p>Next you can chose the type of Database you want to make. I will be using PostgreSQL. You can also pick the version that you want to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*_qKLRititRTtdY1wQM3aeQ.png" /></figure><p><strong>Step 5</strong></p><p>Next you can chose the template you want to use. I recommend using the Free Tier, unless you have other needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*r9MzySI1VnuF3vtzDjyKiA.png" /></figure><p><strong>Step 6</strong></p><p>With the free tier you are restricted to certain options for some things. Which just means that you will leave many of the options as they are. Because I am using the free tier the next option to change will be the settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*vEOII-n1vx4KmnKQq2auHg.png" /></figure><p>Here you can change the DB instance identifier to what you want. I have used “test-1”. The Master username always defaults to postgres if you are making a PostgreSQL database. You can change it if you like, or leave it as postgres.</p><p>You will also needs to set a password for your database as well as confirm the password. The master username and password is what will be used to connect to the database for instance using PgAdmin.</p><p><strong>Step 7</strong></p><p>The next settings you will have to change are the connectivity. You will need to set the public access to “yes”. This will allow access from PgAdmin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*EtaIgQhkh3aUSVinosOVVw.png" /></figure><p>In the same settings at the bottom you should expand the additional configuration. This is where you can verify the port that the database will be on. If you are using PostgreSQL it should be 5432, this is the default port.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*yU7aqSlcAw_RpG7bzQAOQQ.png" /></figure><p><strong>Step 8</strong></p><p>Moving on you can skip the rest of the settings until you see Additional Configuration. This is an important step because, it is where you will set the Database name. If you skip this step when you make your database the name will default to “postgres” but it will show a “-” in the database name. This could become confusing so ensure that you name your database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*v1xXzSjmH-UKTkPUkGtwuA.png" /></figure><p><strong>Step 9</strong></p><p>Once you have named your Database you can scroll down to the bottom and create your database!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*Ox7AG4AnOggzgsMC_xyOkg.png" /></figure><p>This does unfortunately take some time, but you can see the status and you will know when it is done being made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXgFtjULcn0oYA28EW1vTw.png" /></figure><p>Once the status has changed to available you can click on your database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3s5XPAzJqRsFYfh2zU9PHw.png" /></figure><p><strong>Step 10</strong></p><p>After you have clicked on your Database you will see this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LEQu2KBVuBdA17t84ignsw.png" /></figure><p>The endpoint what you will use for connections such as PgAdmin. Lets click on the configuration tab to see more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ufD2uyXoVyfW6xbd01pRkg.png" /></figure><p>Here you can see that because I named our Database when I created it there is a DB name. If you forgot to do <strong>Step 8</strong> yours will default to posgres if you are making a PostgreSQL Database, and it looks like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*frpn6QNDBNch0PoLqDpgWQ.png" /></figure><p>On this one you can see the DB name is “-”. This is what happens if you do not name your Database. Make sure to name it in <strong>Step 8</strong>.</p><p><strong>Step 11</strong></p><p>Now you will need to configure your VPC security rules to allow for inbound request. This setting is in the Connectivity and Security tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*raOlc6cuQ9hr2Z7sYVXClg.png" /></figure><p>Click on the link and it will bring you to this page. Where you can Edit the Inbound rules. Go ahead and click on Edit Inbound Rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fBgnBEc77Tkg31KhANDXg.png" /></figure><p><strong>Step 12</strong></p><p>If there is already a rule there you can delete it by clicking the Delete rule button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8Z9MH_arrp-12TohWAGSA.png" /></figure><p>Now I will add a rule that will allow for inbound request. You can do this by clicking the Add Rule Button. Make sure it is configured like this and press the Save Rules Button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDXHmftq7LH5dFVsdWuzZg.png" /></figure><p><strong>Conclusion</strong></p><p>Congratulations on establishing your PostgreSQL database on AWS successfully! You now possess the knowledge and confidence necessary to set up and administer your own PostgreSQL database in the AWS environment thanks to the detailed instructions provided in this book.</p><p>You now have access to a solid platform that delivers scalability, dependability, and built-in security measures thanks to the strength and flexibility of AWS. As you proceed on your trip, think about investigating more AWS services and sophisticated customizations to improve your PostgreSQL database even further.</p><p>Recall to adhere to best practices for security, backups, and monitoring, and keep up with the most recent AWS technology developments. You have a potent mix that enables you to effectively manage your data and spur innovation with PostgreSQL on AWS.</p><p>I appreciate you being a part of this PostgreSQL and AWS adventure. I hope that this book has given you the knowledge and abilities you need to be successful in your data management activities. I wish you well in your upcoming endeavors!</p><p><strong>Resources</strong></p><ol><li><a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Welcome.html">AWS Documentation</a></li><li><a href="https://www.postgresql.org/docs/">PostgreSQL Documentation</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63f9b3a9c8cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Many-to-Many Relationships in Flask Using the Association Proxy of SQLAlchemy]]></title>
            <link>https://medium.com/@bbissette3/understanding-many-to-many-relationships-in-flask-using-the-association-proxy-of-sqlalchemy-4b408d51f10b?source=rss-2e81a420702c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b408d51f10b</guid>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[sqlalchemy]]></category>
            <category><![CDATA[many-to-many-relationship]]></category>
            <dc:creator><![CDATA[Brian Bissette]]></dc:creator>
            <pubDate>Mon, 08 May 2023 13:23:53 GMT</pubDate>
            <atom:updated>2023-05-10T17:37:12.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*8tnv-WQ5aQ36BQRj3Dc5Vg.png" /></figure><p><strong>Introduction</strong></p><p>Web applications frequently involve many-to-many relationships, so it is crucial for developers to know how to handle them well. We will examine how to use the potent association_proxy feature of SQLAlchemy to enhance and simplify the management of many-to-many relationships in Flask applications in this blog post.</p><p>Python developers frequently utilize the Flask web framework to create online apps, and SQLAlchemy is a well-liked object-relational mapper (ORM) that facilitates smooth interaction between Python objects and relational databases. Combining these technologies through the Flask-SQLAlchemy extension offers a versatile and effective solution to manage the data in your application.</p><p>In this post, we will cover the following topics:</p><ol><li>Recognizing the significance of many-to-many relationships in web applications</li><li>Using SQLAlchemy and Flask-SQLAlchemy, one may build many-to-many relationships.</li><li>Describe association_proxy feature and its advantages.<br>Setting up an association_proxy in a Flask application for a many-to-many relationship</li><li>Investigating complex use cases and performance issues<br>Implementing an association_proxy real-world example in a Flask application</li><li>You will have a firm grasp on using association_proxy to manage many-to-many relationships in Flask apps by the end of this post, which will make your code cleaner, more effective, and simpler to maintain. So let’s get going!</li></ol><p><strong>Understanding Many-to-Many Relationships</strong></p><p>The data we work with in web applications frequently consists of relationships between several entities. The many-to-many relationship is one of the most prevalent kinds of relationships. When many records from one table are linked to several records from another table, this is known as a many-to-many relationship. We employ an association table, which stores the connections between the two tables, to manage these interactions effectively.</p><p>Think of a blogging application, for instance, where each blog post can have several tags, and each tag can be connected to numerous blog entries. In this instance, the link between tags and blog articles is one of many to many.</p><p><strong>Using SQLAlchemy and Flask-SQLAlchemy to Build Many-to-Many Relationships</strong></p><p>Using SQLAlchemy and Flask-SQLAlchemy, we must define the association table and use the relationship function to connect the two tables in order to create a many-to-many relationship in a Flask application. Here’s an illustration:</p><pre>from flask_sqlalchemy import SQLAlchemy<br>from sqlalchemy_serializer import SerializerMixin<br>from sqlalchemy.ext.associationproxy import association_proxy<br><br>db = SQLAlchemy()<br><br>class Post(db.Model, SerializerMixin):<br>    __tablename__ = &#39;posts&#39;<br><br>    serialize_rules = (&#39;-post_tags&#39;,)<br><br>    id = db.Column(db.Integer, primary_key=True)<br>    title = db.Column(db.String(100), nullable=False)<br>    content = db.Column(db.Text, nullable=False)<br>    post_tags = db.relationship(&#39;PostTag&#39;, backref=&#39;post&#39;, cascade=&#39;all, delete, delete-orphan&#39;)<br>    tags = association_proxy(&#39;post_tags&#39;, &#39;tag&#39;)<br><br>class Tag(db.Model, SerializerMixin):<br>    __tablename__ = &#39;tags&#39;<br><br>    serialize_rules = (&#39;-post_tags&#39;,)<br><br>    id = db.Column(db.Integer, primary_key=True)<br>    name = db.Column(db.String(50), nullable=False, unique=True)<br>    post_tags = db.relationship(&#39;PostTag&#39;, backref=&#39;tag&#39;, cascade=&#39;all, delete, delete-orphan&#39;)<br>    posts = association_proxy(&#39;post_tags&#39;, &#39;post&#39;)<br><br>class PostTag(db.Model, SerializerMixin):<br>    __tablename__ = &#39;post_tags&#39;<br><br>    serialize_rules = (&#39;-post&#39;, &#39;-tag&#39;,)<br><br>    post_id = db.Column(db.Integer, db.ForeignKey(&#39;posts.id&#39;), primary_key=True)<br>    tag_id = db.Column(db.Integer, db.ForeignKey(&#39;tags.id&#39;), primary_key=True)</pre><p><strong>Introducing the association_proxy feature and its benefits</strong></p><p>We talked about using SQLAlchemy and Flask-SQLAlchemy to build a many-to-many relationship in the previous section. However, dealing with the association table or intermediate model directly might occasionally be difficult when working with connected entries. The association_proxy enters the picture at this point.</p><p>You can design a more practical and user-friendly method to access and query related entries in a many-to-many connection using the association_proxy feature in SQLAlchemy. Working with linked records is made simpler by constructing an association_proxy, which eliminates the need to directly interact with the association table or intermediary model.</p><p>The code sample we previously gave makes use of association_proxy to establish a fictitious connection between the Post and Tag models via the PostTag model</p><p>Without having to deal with the PostTag model, you may access the linked Tag objects for a Post instance directly through the tags attribute, and the related Post objects for a Tag instance directly through the posts attribute.</p><p>The following are some advantages of using association_proxy:</p><ol><li>Access to linked records is now more straightforward because of association_proxy, which offers a more logical and direct method of doing so.</li><li>Simpler querying: Association_proxy enables you to run queries on related records without explicitly joining the association table or intermediary model.</li><li>Cleaner code: Association_proxy produces cleaner, more maintainable code by abstracting away the specifics of the intermediate model or association table.</li></ol><p><strong>Setting up an association_proxy in a Flask application for a many-to-many relationship</strong></p><p>The previous code sample demonstrated how easy it is to set up an association_proxy in a Flask application. We specify the association_proxy attributes in the Post and Tag models as follows:</p><pre>class Post(db.Model, SerializerMixin):<br>    # ...<br>    tags = association_proxy(&#39;post_tags&#39;, &#39;tag&#39;)<br><br>class Tag(db.Model, SerializerMixin):<br>    # ...<br>    posts = association_proxy(&#39;post_tags&#39;, &#39;post&#39;)</pre><p>The name of the relationship attribute in the current model that connects to the association table or interim model is the first argument of the association_proxy function. The name of the connection attribute in the association table or intermediate model that connects to the target model is the second argument.</p><p>After setting up association_proxy, you can now use the tags and posts properties to directly view and interact with linked records:</p><pre># Querying all posts with a specific tag<br>tag = Tag.query.filter_by(name=&#39;Flask&#39;).first()<br>flask_posts = tag.posts<br><br># Querying all tags associated with a specific post<br>post = Post.query.get(1)<br>post_tags = post.tags</pre><p><strong>Examining intricate use cases and performance problems</strong></p><p>Using association_proxy and many-to-many relationships, you could run into challenging use cases or performance problems. Although working with linked records is made simpler by the association_proxy, there is occasionally a performance hit or additional database requests as a result.</p><p>Use SQLAlchemy’s joinedload function to minimize the number of queries run in order to improve performance. With the help of this function, you may define a single query to load many related models from the database:</p><pre>from sqlalchemy.orm import joinedload<br><br># Query all posts and their associated tags with a single query<br>posts = Post.query.options(joinedload(Post.tags)).all()<br><br># Query all tags and their associated posts with a single query<br>tags = Tag.query.options(joinedload(Tag.posts)).all()</pre><p>You might need to combine the association_proxy with other SQLAlchemy features, such as unique join criteria, filtering, and aggregation methods when dealing with complex use cases. You can improve the efficiency of your queries by tuning them to the association_proxy underlying mechanics and the relationships it represents.</p><p><strong>Conclusion</strong></p><p>The association_proxy SQLAlchemy functionality and its advantages for managing many-to-many relationships in Flask applications were discussed in this blog article. We spoke about how to set up an association_proxy in a Flask application and gave examples of how to use it to make it easier to access related records. We also discussed association_proxy’s potential for complex use cases and performance problems. You may write clearer, more effective, and easier-to-maintain code for handling many-to-many relationships by comprehending and using the association_proxy functionality in your Flask apps.</p><p><strong>Resources</strong></p><ol><li><a href="https://docs.sqlalchemy.org/en/14/orm/extensions/associationproxy.html">association_proxy</a></li><li><a href="https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html#sqlalchemy.orm.joinedload">joinedload</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b408d51f10b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Lambda Functions: Understanding and Utilizing Them!]]></title>
            <link>https://medium.com/@bbissette3/python-lambda-functions-understanding-and-utilizing-them-a50ff9caa861?source=rss-2e81a420702c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a50ff9caa861</guid>
            <dc:creator><![CDATA[Brian Bissette]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 17:51:35 GMT</pubDate>
            <atom:updated>2023-04-19T18:49:26.070Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*hvUvMrIgn3Dez6PfncNNHQ.jpeg" /></figure><p><strong>Introduction</strong></p><p>Have there ever been times when you needed to create a quick function for a particular purpose but didn’t want to deal with the effort of developing a comprehensive function? Let’s introduce lambdas, which are many programming languages’ compact, strong, and expressive methods for writing anonymous functions. In this article, we’ll look at lambdas, their advantages, and practical ways to use them in Python. You’ll have a firm understanding of lambdas by the end of this article and how they can streamline your code and improve your programming experience.</p><p><strong>What are Lambdas?</strong></p><p>Lambdas, also referred to as anonymous functions, are a technique to build short, one-time functions without naming them. They are in use when you require a quick, straightforward function for a particular task, like sorting or filtering data. Many programming languages support lambdas, but the syntax varies slightly amongst them.</p><p><strong>Named Functions vs. Lambdas</strong></p><p>Named functions can be called several times throughout your code because they are defined with distinct names. Lambdas, on the other hand, are anonymous, meaning they have no name and are only ever used once. Lambdas’ key benefit is their clarity, which makes them perfect for quick, straightforward operations.</p><p><strong>How to write Lambdas in Python</strong></p><p>The lambda keyword, a list of parameters, a colon, and an expression is used to generate lambdas in Python. The lambda function evaluates the expression and returns it when it is called. A lambda function in Python has the following syntax:</p><pre>square = lambda x: x*x<br><br>result = square(5)<br>print(result)<br><br>#Output: 25</pre><p><strong>When to use Lambdas</strong></p><p>In Python, lambdas are especially helpful for quick, one-time functions that handle straightforward tasks or work with data. The following are some typical Python use cases for lambdas:</p><p>Using lambdas with map(): The map() method returns a new iterable that contains the results after applying a specified function to each item in an iterable (such as a list or tuple). Map() accepts lambdas as a function argument.</p><p>Example:</p><pre>numbers = [1, 2, 3, 4, 5]<br><br>doubled_numbers = map(lambda x: x * 2, numbers)<br>print(list(doubled_numbers))  <br><br># Output: [2, 4, 6, 8, 10]</pre><p>Using lambdas with the filter() function: The filter() function filters elements from an iterable according to the conditions of a function. The function argument for filter() can be a lambda.</p><p>Example:</p><pre>numbers = [1, 2, 3, 4, 5]<br><br>even_numbers = filter(lambda x: x % 2 = 0, numbers)<br>print(list(even_numbers))<br><br>#Output: [2,4]</pre><p>The sorted() function can be used with lambdas to order items in an iterable based on a given key. The main function for custom sorting is lambda.</p><p>Example:</p><pre>words = [&#39;apple&#39;, &#39;banana&#39;, &#39;cherry&#39;, &#39;orange&#39;]<br><br>sorted_words = sorted(words, key=lambda x: len(x))<br>print(sorted_words)  <br><br># Output: [&#39;apple&#39;, &#39;cherry&#39;, &#39;banana&#39;, &#39;orange&#39;]</pre><p>These are just a few instances of how Python can make use of lambdas. When utilized properly for brief, one-time actions, they can make your code simpler and easier to comprehend.</p><p><strong>Advantages and Disadvantages of Lambdas in Python</strong></p><p><strong>Advantages:</strong></p><ol><li>Concision: You can build one-line, brief functions using lambdas that may be more concise than corresponding named functions. Your code may become shorter and simpler to read as a result.</li><li>Simplicity: When combined with higher-order functions like map(), filter(), and sorted(), lambdas can aid in the simplification of your code. You can avoid defining separate, one-use functions by using lambdas as arguments for these functions.</li><li>Lambdas can be defined and used right within an expression or function call, which can make your code more condensed and possibly easier to read.</li></ol><p><strong>Disadvantages:</strong></p><ol><li>Lambdas are limited to single expressions; they are unable to include numerous statements, assignments, or intricate reasoning. You must utilize named functions for more intricate processes.</li><li>Lambdas can make your code more concise, but if they are overly complex or nested, they can also make it harder to read. When employing lambdas, it’s crucial to achieve a balance between conciseness and clarity.</li><li>Problems with debugging: Because lambdas are anonymous and lack a name, they can make debugging more difficult. The lack of information in error messages and stack traces can make it more challenging to pinpoint the problem’s origin.</li></ol><p>In conclusion, when utilized properly, lambdas may be a strong and useful tool in Python. To maintain legible and maintainable code, it’s crucial to comprehend its benefits and drawbacks and to apply them intelligently. In conclusion, when utilized properly, lambdas may be a strong and useful tool in Python. To maintain legible and maintainable code, it’s crucial to comprehend its benefits and drawbacks and to apply them intelligently.</p><p><strong>Tips for Using Lambdas Effectively in Python</strong></p><ol><li>Keep it simple: Lambdas work best for brief, straightforward actions. Consider utilizing a named function in place of your function if it requires numerous lines of code, complicated logic, or multiple statements.</li><li>Avoid using nested lambdas: Although nested lambda functions can be written, doing so can dramatically limit readability. It’s always preferable to utilize named functions or modify your code if you frequently find yourself nested lambdas.</li><li>Use with the right functions: Higher-order functions like map(), filter(), and sorted() work nicely with lambdas. Lambdas are the ideal solution because these functions frequently call for brief, one-time functions.</li><li>Limit the number of arguments that are accepted because lambdas are designed to be brief. Consider whether a named function might be better appropriate if your lambda function has numerous arguments.</li><li>Choosing clear, descriptive names for the arguments is crucial when utilizing lambdas, even though the names should be brief and to the point. Your code will be easier to understand and maintain readability as a result.</li><li>Lambdas should typically be used for pure functions without side effects to avoid them. This means that they shouldn’t alter any external data or global state; instead, they should only rely on their input arguments.</li><li>Strike a balance between brevity and readability: While lambdas might make your code more succinct, it’s crucial to maintain readability. A named function can be preferable if your lambda function is convoluted or occupies several lines.</li></ol><p><strong>Conclusion</strong></p><p>Python’s lambdas are a strong and useful feature that let you write short, anonymous functions for straightforward, one-time actions. In this blog post, we’ve looked at lambdas’ syntax and use cases, talked about their benefits and drawbacks, and given advice on how to utilize them efficiently.</p><p>Lambdas can result in cleaner, more understandable code and speed up your development process when utilized properly. To balance readability and conciseness, though, and to know when a named function could be more appropriate, is crucial.</p><p>I invite you to experiment with lambdas in your own projects now that you have a better knowledge of how they work in Python. Examine how they can make your code simpler and your programs’ general structure better. To master lambdas and realize their full potential, like with any programming approach, practice is essential. Happy Coding!</p><p><strong>Resources</strong></p><p>You can click on the following links for further details on the various tasks and ideas addressed in this piece:</p><ol><li><a href="https://www.geeksforgeeks.org/python-map-function/">map() in Python</a></li><li><a href="https://www.geeksforgeeks.org/filter-in-python/">filter() in Python</a></li><li><a href="https://www.geeksforgeeks.org/python-sorted-function/">sorted() in Python</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a50ff9caa861" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prop Drilling with React!]]></title>
            <link>https://medium.com/@bbissette3/prop-drilling-with-react-9a45ae80182c?source=rss-2e81a420702c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a45ae80182c</guid>
            <dc:creator><![CDATA[Brian Bissette]]></dc:creator>
            <pubDate>Wed, 29 Mar 2023 01:01:33 GMT</pubDate>
            <atom:updated>2023-04-19T13:57:12.454Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting the Hang of Prop Drilling in React: A Complete Guide</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*xpb0_ogn300hU8n0kXpRYg.png" /></figure><p><strong>Introduction</strong></p><p>React has emerged as a well-liked library in the realm of contemporary web development for making effective and interactive user interfaces. Although it has numerous benefits, component communication and state management can occasionally be difficult for developers. Prop drilling, a React technique that can be confounding for beginners, is one such difficulty. We will debunk prop drilling, examine usage cases, and arm you with the information you need to grasp it in your React projects in this in-depth guide.</p><p><strong>What is prop drilling?</strong></p><p>Data is transmitted from a parent component down via several levels of interdependent components — a process known as “prop drilling,” also referred to as “threading” — until it reaches the component that needs the data. This is achieved by ‘drilling’ the data down the component tree by transferring the data as ‘props’ (short for properties) from one component to another. While this approach may work well for simpler applications or when there are just a few levels of components, it may become burdensome and challenging to manage in complex applications.</p><p><strong>When to Use Prop Drilling and Its Importance</strong></p><p>Proper drilling allows data to flow between components, allowing them to communicate and share state without the need for a central mechanism for managing state. When there are only a few levels of nested components or in smaller applications, this strategy is extremely helpful. Prop drilling can be a simple and direct way to transmit data between components in certain circumstances.</p><p>Prop drilling should only be used when absolutely necessary to optimize React applications and guarantee a maintainable codebase. You may decide which state management approaches are ideal for your projects by being aware of its significance and constraints.</p><p><strong>Prop Drilling in Action</strong></p><p>To better understand prop drilling in a React application, let’s look at a straightforward example. In this illustration, we have an app with the structure shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*5vV5LrhX4FOtCVswpiCEgg.png" /></figure><p>The Category Filter determines which Task components are shown on the page. To pass the pertinent data, we’ll prop drill from App down to Task.</p><p><strong>Step 1: Fetch Data and Set State</strong></p><p>First, utilize the useState and useEffect hooks to collect the data and set the state:</p><pre>import React, { useState, useEffect } from &quot;react&quot;;<br><br>function App () {<br>  <br>  const [tasks, setTasks] = useState([]);<br><br>  useEffect(() =&gt; {<br>    const fetchData = async () =&gt; {<br>      const response = await fetch(&quot;http://localhost:3001/Tasks&quot;);<br>      const tasksData = await response.json();<br>      setTasks(tasksData);<br>    }<br>    fetchData();<br>  }, []);<br><br>  console.log(tasks)<br>}</pre><p>Check the console log to make sure the fetch and state setting is functioning properly.</p><p><strong>Step 2: Pass Data From App to Task List</strong></p><p>Now, use prop drilling to send the data to the Task List component:</p><pre>  return (<br>    &lt;div className=&quot;App&quot;&gt;<br>      &lt;h2&gt;My tasks&lt;/h2&gt;<br>      &lt;CategoryFilter /&gt;<br>      &lt;TaskList tasks={tasks} /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p><strong>Step 3: Access the Data in Task List</strong></p><p>Accept the tasks prop in the task list component to gain access to the information:</p><pre>import React from &quot;react&quot;;<br><br>function TaskList({ tasks }) {<br><br>  return (<br>    &lt;div className=&quot;tasks&quot;&gt;&lt;/div&gt;<br>  )<br>}<br><br>export default TaskList;</pre><p>You can now use the information from the prop to begin your job. We can begin by importing the Task because we are aware that it is a child component of the Task List.</p><p><strong>Step 4: Render the Task Component</strong></p><p>Render a Task component for each task after importing the Task component, mapping over the tasks array:</p><pre>import React from &quot;react&quot;;<br>//This is how you import the Task Component<br>import Task from &quot;./Task&quot;;<br><br>function TaskList({ tasks }) {<br>    <br>  const taskList = tasks.map((task) =&gt; (<br>    &lt;Task key={task.text} text={task.text} category={task.category} /&gt;<br>  ));  <br><br>  return (<br>    &lt;div className=&quot;tasks&quot;&gt;{taskList}&lt;/div&gt;<br>  );<br>}<br><br>export default TaskList;</pre><p>Now that you have told it to do so, tasks will be rendered with a key, text, and category for each Task. But is it providing all the information you require? Because you passed Task a Prop of Text and Category, you should check at Task.</p><p><strong>Step 5: Access the Data in Task</strong></p><p>Lastly, access the text and category properties in the Task component:</p><pre>import React from &quot;react&quot;;<br><br>//make sure to take in the props that you passed down inside the Task()<br>function Task({ text, category}) {<br><br>  return (<br>    &lt;div className=&quot;task&quot;&gt;<br>      &lt;div className=&quot;label&quot;&gt;{category}&lt;/div&gt;<br>      &lt;div className=&quot;text&quot;&gt;{text}&lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default Task;</pre><p>Prop drilling in more extensive applications with more complex hierarchies can be confusing and challenging, despite the example’s comparatively simple structure.</p><p>Take a look at a bigger App layout bellow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*nQ1I1b4BZwVpTeLjT45jDw.png" /></figure><p>Due to the larger number of components in this app, additional prop drilling may be necessary depending on which components are needed and where specific states must be located.</p><p><strong>Best Practices for Prop Drilling in React Applications</strong></p><p>It’s crucial to adhere to recommended practices while working with prop drilling in React applications to ensure effective and maintainable code. Here are a few suggestions:</p><ol><li>Components should be few and targeted. Make components focused on a particular task and have a single responsibility. This strategy makes it simpler to handle prop drilling because each component will likely need fewer props, simplifying the component hierarchy.</li><li>Deconstruct Props for clarity. Deconstruct various props that a component receives to make the code more accessible and understandable.</li><li>Limiting the depth of prop drilling. Code gets more difficult to monitor and maintain as prop drilling depth rises. If you frequently need to drill props more than a few levels deep, think about adopting Redux or React Context as an alternative state management option.</li><li>Be cautious of how it may affect performance. When the data changes, prop drilling can result in needless re-rendering of components. Be mindful of the performance consequences and reduce needless re-rendering by using techniques like memoization (React.memo) or PureComponent.</li></ol><p><strong>Conclusion: Mastering Prop Drilling in React Applications</strong></p><p>In React applications, prop drilling is a crucial method for transferring data between components. You may develop apps that are more effective and maintainable if you understand how prop drilling functions and when to use it. With more React experience, you’ll be better able to judge when prop drilling is the best option and when alternate state management strategies like React Context or Redux should be taken into account.</p><p>We’ve debunked the myths around prop drilling in this extensive manual, offered best practices for using it, and included a real-world example to let you see the idea in action. You’ll be better able to control the data flow within your React applications by implementing these lessons learned and best practices to your own projects, which will ultimately lead to more efficient and successful web development.</p><p>Continue to experiment, pick up new knowledge, and hone your React development skills. You’ll continue to advance in your software engineering career with practice and tenacity.</p><p><strong>Resources</strong></p><ol><li><a href="https://legacy.reactjs.org/docs/hooks-state.html">useState with React</a></li><li><a href="https://legacy.reactjs.org/docs/hooks-effect.html">useEffect with React</a></li><li><a href="https://legacy.reactjs.org/docs/react-api.html#reactmemo">React.memo</a></li><li><a href="https://legacy.reactjs.org/docs/react-api.html#reactpurecomponent">PureComponent</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a45ae80182c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The importance of code quality and writing maintainable code.]]></title>
            <link>https://medium.com/@bbissette3/the-importance-of-code-quality-and-writing-maintainable-code-aece3738dfc?source=rss-2e81a420702c------2</link>
            <guid isPermaLink="false">https://medium.com/p/aece3738dfc</guid>
            <dc:creator><![CDATA[Brian Bissette]]></dc:creator>
            <pubDate>Wed, 08 Mar 2023 02:35:03 GMT</pubDate>
            <atom:updated>2023-03-08T02:35:03.039Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MyWhesc9hpbBrANMQW0jHA.png" /></figure><p><strong>Introduction</strong></p><p>Hello I’m Brian. I am currently in phase 1 of a software engineering bootcamp and I wanted to talk about something that I struggled with at first but learned was a valuable tool while coding. At first I did not understand the importance of writting quality code and the reason behind it.</p><p><strong>Why is having quality code important?</strong></p><p><strong>Readability:</strong></p><p>Code that is easy to read and understand is much easier to maintain and debug. Having code that is not easy to read can cause mistakes or errors that can be difficult to locate and fix.</p><p><strong>Maintainability:</strong></p><p>Writing code is only part of being a software engineer. Maintaining previously written code is arguably a larger part. Having a good code quality is crucial because in the long run it makes code easier to maintain.</p><p><strong>Efficiency:</strong></p><p>Writing high quality code not only improves its performance, but it also makes it significantly easier to debug and maintain, improving its overall efficiency.</p><p><strong>Here is an example of poorly organized code:</strong></p><pre>function myFunction() {let a = 1; let b = 2; let c = a + b; console.log(c);)</pre><p>You could write your function like this. However, the code is not easily readable.</p><p><strong>Well organized code:</strong></p><pre>function myFunction() {<br>  let a = 1;<br>  let b = 2;<br>  let c = a + b;<br>  console.log(c);<br>};</pre><p>The difference here is that it was written in a more organized manner. Not only is the code organized, but the indenting method used here makes it easier to see what belongs inside the function. You can also see that the closing bracket is under the function declaration indicating that it’s the closing to the function.</p><p>Writing your code in this manner makes it easier for anyone that you are collaborating with to understand what the function itself is doing and what is within the function. This will also make it easier for anyone to debug, especially if they were not originally part of the project.</p><p><strong>How meaningful variable declarations can help:</strong></p><p>Another thing to consider is meaningful variable declarations. When making variable declarations you want to be as specific as possible. This will help eliminate confusion as to what the variables are representing.</p><pre>const a = 5;<br>const b = 10;<br>const area = a * b;<br><br>console.log(`The area of the rectangle is ${area} square units.`)</pre><p>Looking at this we know that we going to be getting the area of something, but the variable declarations don&#39;t really tell us anything.</p><pre>const rectangleWidth = 5;<br>const rectangleHeight = 10;<br>const rectangleArea = rectangleWidth * rectangleHeight;<br><br>console.log(`The area of the rectangle is ${rectangleArea} square units.`)</pre><p>Compared to the other code snippet here we are being more precise with our variable naming and can clearly tell that the variables are representing rectangle width and height.</p><p>While coding you will work with multiple functions and variable declarations. Think about how you can easily get lost in a file that has multiple functions or functions within functions. You definitely want to be able to understand what is going on.</p><p>Take a look at this code snippet from a lab I was working on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*gBYjBWVPPdAHGEmg-A37cA.png" /></figure><p>Lets not worry about what is going on in this code, but just look at it and see if the coding itself is consistent and easily readable.</p><p>You can see that there are multiple functions as well as different events happening. However, with the way it is written you can easily see where each function starts and ends. You can easily identify what belongs to each function and understand the purpose of each variable declaration.</p><p><strong>How writing my code more consistently and at a better quality has helped me</strong></p><p>When I first started I was not separating anything and just jumble it all together. Because of this I would always struggle to find syntax errors within my code. I would also have a lot of scope issues because I was not able to tell what was on a global or function scope.</p><p>With the way I am writing my code now, I find it easier to locate and fix my syntax errors. I can also understand scoping considerably easier which helps me while writing out my functions.</p><p>While I have not perfected this yet I am happy with the progress that I have made so far with making my code more readable and consistent. I hope that what I talked about today will help you improve your code quality and consistency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aece3738dfc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>