<?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 Mark Bacon on Medium]]></title>
        <description><![CDATA[Stories by Mark Bacon on Medium]]></description>
        <link>https://medium.com/@mark.n.bacon.jr?source=rss-d2729df3753c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*jQ8GQYRuM3oBdRWW</url>
            <title>Stories by Mark Bacon on Medium</title>
            <link>https://medium.com/@mark.n.bacon.jr?source=rss-d2729df3753c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:14:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mark.n.bacon.jr/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[What I learned in B̶o̶a̶t̶i̶n̶g Coding School is… A Guide to Maximizing your BootCamp Experience.]]></title>
            <link>https://medium.com/@mark.n.bacon.jr/what-i-learned-in-b%CC%B6o%CC%B6a%CC%B6t%CC%B6i%CC%B6n%CC%B6g-coding-school-is-a-guide-to-maximizing-your-bootcamp-experience-c8a0ac353623?source=rss-d2729df3753c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8a0ac353623</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[bootcamp-experience]]></category>
            <category><![CDATA[bootcamp]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Mark Bacon]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 16:10:14 GMT</pubDate>
            <atom:updated>2022-06-21T16:10:14.746Z</atom:updated>
            <content:encoded><![CDATA[<p>Everyone tells you that a Software Engineering bootcamp will be intense but I don’t think one can ever be prepared for just <em>how </em>intense the process of learning how to Develop web applications can be in such a truncated period of time. One fact-forward tidbit Flatiron gives you upon entry into the program is that you will not in fact learn everything there is to know about SE in the short 15 weeks you are involved in the program. Much the opposite. There is so much to know about the world of Development and it is unreasonable to assume that any human can learn, process, assimilate, and then <em>retain</em> the information that was fired off at them when you are switching gears. Here I will discuss a key takeaway from each of the phases in Flatiron School’s curriculum in order to put your best foot forward.</p><h3>Phase 1: JavaScript…</h3><p>This phase is arguably the most difficult phase in the curriculum because the learning curve is so steep. Not only are you learning a language that is very syntax heavy, the error handling is a bit nebulous, and this is the first jump into understanding <em>how to communicate </em>with a computer. My biggest piece of advice is to really double down and understand the Pre-Course Work so that you have a solid understanding of what you are doing when starting the course. JavaScript is the building block of front-end computer programming and it is imperative to really learn from the ground up so that you can build upon your knowledge.</p><h3>Phase 2: React</h3><p>React is such a fun landing pad after slogging through JavaScript. It is a front-end framework that focuses on separation of concerns within your application. This allows each component to have a certain level or reusability. For example in React if you create a Button component, that same button can just be <em>imported </em>into other components instead of creating a whole new button! Neat! React’s major gotcha in my opinion is the concept of state. Specifically when state in the child component needs to be updated but lives in a parent component. This is handled with callback functions that fire off at top level and are drilled down as props. Understanding this concept will allow you to soar through React and create really interesting projects that are able to persist changes.</p><h3>Phase 3: Ruby</h3><p>If there is another contender for the hardest Phase at Flatiron school this is definitely it. Not only is the focus shifting from front to back-end, Ruby is a totally new language with different syntax (albeit, much better error messages than JavaScript!) and there is no immediate <em>tell </em>of if what you were working on is being sent to the front-end (no pretty pictures show up on the screen — or don’t — to tell you that the task is complete). On top of all of this, Flatiron throws so much at you at once during this phase: Ruby, Sinatra, SQLite3, and your first dive into Object Relational Mapping (ORM) specifically with Active Record Associations. The sheer <em>volume </em>of information crammed into these two weeks of learning can (and will) be overwhelming. My best advice during this phase is to power through in very very broad strokes as fast as you can. This was counterintuitive for me as I like to deeply understand the concept before moving on to the next one. However when I just forged ahead with even the smallest understanding, each new lesson shed light on what I didn’t understand before. And because I was able to go through it quickly, there was ample time to start from the beginning to reiterate and recognize the overarching themes upon rereading the material. Getting a jump on this phase will serve you greatly if you are able to go over it twice, basically; one for broad concepts and the second time for fine tuned understanding.</p><h3>Phase 4: Rails</h3><p>This phase took me by surprise because everyone involved in the learning process is like “This will be such a breath of fresh air and a nice change of pace”. And they were correct. Rails is a framework that takes away a lot of the legwork for you by special methods that are built out under the hood. That being said, with the newfound knowledge that this was gonna be an “easy” phase, the apathy started kicking in. After feeling burned out by the pace at which I learned Ruby, I felt entitled to a break and as a result, my determination to deeply understand the material started to wane. The biggest takeaway from this module in my opinion is to keep forging ahead; go to that lecture when you don’t want to, attend standup even when you feel like you couldn’t possibly get out of bed. I promise you will learn something you already thought you knew.</p><h3>Final Phase: Capstone</h3><p>This is a tricky phase because you are totally on your own here. I have watched people in my cohort and others flourish. I have watched other people who did the bare minimum during the first four phases flounder. We will all struggle during Phase 5 because now the focus shifts not only onto the project you are going to create alone, but on the job search. The scope of <em>why</em> you attended the bootcamp in the first place is broadened and you, feet to the fire, and actually forced to put your skills to the test. The biggest advice in Phase 5 for me would be time management. Of course you want your solo project to look good. After all, it is the only one you created by yourself and a direct reflection of your ability as a Dev to date. That being said, make sure you are finding the balance of Data Structure and Algorithms, job applications, and learning to balance you normal everyday life with this crazy thing you have been doing (hopefully) 60 hours a week for the last 3.5 months. This culmination of your learning is not only about the project you produce but how you set yourself up in a work environment that will be similar upon graduation. These habits that you build in Phase 5 will start to carry over into your day to day so make sure they are good ones!</p><p>And that’s it! My very informed, <em>very </em>important blog about major focuses on each Flatiron Chapter. You might find some of what I said helpful. I certainly learned a ton about myself going through the program but ultimately what I can leave you with is what you put in is what you will get out. Never have I seen that manifest in my life quite like my time at Flatiron.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8a0ac353623" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CSS Tweaks to really make your project shine]]></title>
            <link>https://medium.com/@mark.n.bacon.jr/simple-css-tweaks-to-really-make-your-project-shine-2bf63e997653?source=rss-d2729df3753c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bf63e997653</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[styling]]></category>
            <category><![CDATA[style]]></category>
            <dc:creator><![CDATA[Mark Bacon]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 15:24:15 GMT</pubDate>
            <atom:updated>2022-06-21T15:24:15.205Z</atom:updated>
            <content:encoded><![CDATA[<p>As an application gets built, oftentimes the Dev focuses on functionality and leaves the styling for the end creating a massive headache for adjusting, rearranging and general congruency. Here are some tips for Devs to make their project feel more congruent and avoid an hours-long restyle after all is said and done.</p><h3>Start with Vanilla CSS</h3><p>My first suggestion would be to start with the very basics. There are so many incredible styling packages available to us as Devs such as Bootstrap, MUI and TailWind, but the quickest way to learn style (much like functionality) is to start at its roots and learn what each facet of the program does. CSS is a great tool for this because there are no flashy tools to just slap on a project and call it a day. You are required to sit with each class you name and make a deliberate decision about using that specific attribute. This builds a fabulous understanding of <em>just how much</em> is at our fingertips when we style with Vanilla CSS.</p><h3>Have a Global or “baseline” style</h3><p>In most applications you are able to see a root selector (sometimes identified as *) at the top of a CSS file. This is called the universal selector. There are mixed opinions on the use of this particular selector to set up a baseline style, but I recommend selecting something top level early on in the process (be it * or the body tag) where you can set up how the style should appear on the page with no alterations. Want all of your text to be centered as a baseline? Put it in this tag. Want the font to be congruent? Goes here. Should the width of the page not be larger than the viewport? That’s another good thing to notate in this selector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*UgQyUBD13728NqT6z_r7GA.png" /><figcaption>An example of Global styling</figcaption></figure><h3>Start Styling Early</h3><p>I mentioned this in the intro but it is <em>imperative </em>in my opinion to style as you go. When you are working with both functionality and style in tandem, we can use <em>thin vertical slices </em>to accomplish one piece of your application at a time. That way you have fully built out components one piece at a time. This really helps down the line when deadlines approach and the panic sets in of having to style an entire app in the matter of a few days (or *GASP* hours!). Another benefit of styling early is that you have a structure for how things <em>were </em>going and what <em>was </em>working regarding the app’s style instead of first figuring it out on the fly and<em> then</em> making decisions about the congruency of each component. Having a blueprint makes the work much easier down the line.</p><h3>Make the page responsive</h3><p>Finally, friends, we are in the age of cell phones. A key element in making your app stand out is to style a website that is not only beautiful for the desktop but also for a mobile device. This comes in large part with media queries. You can dictate how certain elements appear on the screen given the min (or max!) screen width. There is no limit to the amount media queries you can insert so if you’d like to style for every screen (most popularly a Computer, Tablet, and Smartphone) then go off! An example of a media query is below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*w-Phou_olSKPUVNbEV1RDw.png" /><figcaption>A Media Query for a smartphone screen.</figcaption></figure><p>These simple reminders can really help your page pop when it comes time to think about styling. And hopefully after reading this article, you start styling sooner rather than later and save yourself the headache of the century!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bf63e997653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails! Yay! Ok, but where do I start…? A step-by-step guide to setting up your backend]]></title>
            <link>https://medium.com/@mark.n.bacon.jr/rails-yay-ok-but-where-do-i-start-a-step-by-step-guide-to-setting-up-your-backend-75caf27e76c9?source=rss-d2729df3753c------2</link>
            <guid isPermaLink="false">https://medium.com/p/75caf27e76c9</guid>
            <category><![CDATA[rails-generators]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[setup]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Mark Bacon]]></dc:creator>
            <pubDate>Mon, 23 May 2022 00:02:33 GMT</pubDate>
            <atom:updated>2022-05-23T00:02:33.996Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Over the past few weeks I dove into Rails and after I installed all the bundles, gems and other dependent features, I was stumped. While I had a general understanding of the *magic* that was happening for me when I typed certain commands, I quickly found myself overwhelmed with the <em>size </em>of my to-do list when setting up my Backend relationships. “WHERE TO START?!”, I would scream. I’ve put together a handy guide/example to take you stepwise through the process of setting up your relationships and what Rails does for us at each point!</blockquote><h3>TL/DR;</h3><pre>The Steps: </pre><pre>rails g resource &lt;Thing&gt; column:type<br>rails db:migrate<br>rails db:seed<br>build Model Relationships<br>handle Validation<br>define Controller CRUD<br>use Private methods<br>error handling in Application Controller</pre><h4>Let’s build out a gym-membership manager and it’s relationships!</h4><p>A Gym has many Memberships, and has many Clients through their Memberships.</p><p>A Client has many Memberships, and has many Gyms through their Memberships.</p><p>A Membership belongs to a Client and a Gym.</p><p>With this knowledge let’s begin building the associated data with Rails! The first thing I like to do is think about the <em>basics </em>that Rails initially needs: controllers, models, and a schema/migration setup. In our case, we will need one of each for a Gym, Membership, and Client. Luckily there is a handy terminal command that will generate all of this (and more!) for us. The rails g resource &lt;Thing&gt; column:type command will allow you to type the name of the table you wish to create as well as in-line table columns (and their data types, string being the default). I recommend checking out <a href="https://medium.com/@matt.readout/rails-generators-model-vs-resource-vs-scaffold-19d6e24168ee">this article</a> that talks about different ways you can set up your files with one terminal command. Scaffold is also cool but be sure to understand <em>why </em>you are using each of these commands to safely and knowledgeable build out your project.</p><p>If we want our Client table to have a name and age attribute, we could type rails g resource Client name age:integer. <strong>Note:</strong> in this example, the name attribute doesn’t specify name:string rather it is the default data type when using this command. rails g resource Client name:string age:integer would work as well. If you check it out, we will have a Migration, Model, Controller, full CRUD routes (and a Serializer, if you have already included the gem ‘active_model_serializers’ in your Gemfile!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K23gOTjCksu1vqYGQPeyuw.png" /><figcaption>A quick peek at all the <strong>r</strong><strong>ails g resource</strong> command gives you</figcaption></figure><p>Let’s repeat this process for Gym and Membership as well…</p><p>rails g resource gym name address</p><p>rails g resource membership charge:integer client_id:references gym_id:references</p><p>The second one is a little spicy, no? Basically by using references, we are setting foreign keys (and constraints, a built-in safeguard) to protect and associate our data. More on this later! The two above commands will produce the below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mpp_W6xlUo5S5BivLlYu7Q.png" /><figcaption><strong>Gyms</strong> creation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gaIsNHgDP8lP8rvPtpQwRA.png" /><figcaption><strong>Memberships</strong> creation</figcaption></figure><p>Neat! We have a bunch of things created! But how will all these new resources <em>talk</em> to each other?! The first step is to rails db:migrate and then rails db:seed. While the rails g resources command <em>created</em> these migrations, it is up to us to migrate them. We should also develop some data in our seeds file in order to have initial information to work with. That has been provided below. Having this in our seeds file <em>before </em>we rails db:seed is paramount.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOj7d2DenX1SfdlkVVS4XQ.png" /><figcaption>Generic Seeds file for testing relationships</figcaption></figure><p>With our <strong>migration complete</strong>, we should set up <em>how </em>these models are related. If you notice above when we view ourGym model, the belongs_to relationship was already created for us thanks to the references type we used when generating our Membership resource, however we still need to add has_many: side of the relationship. Say an instance of a Gym should close (be deleted off the data table), we want to be able to destroy all relationship instances (in this case memberships) that theGym had. <strong>Note: </strong>You could also <em>technically</em> do the same for Clients, but that is beyond the scope of this example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CY3bCsOMHxEza8uxHAE7ww.png" /><figcaption>Relationships between model, note the <strong>dependent: :destroy</strong>!</figcaption></figure><p>Now that every model knows how it is related, we should look at the :client_id and :gym_id as a pair and make sure a Membership can’t be duplicated. <strong>Validation </strong>comes into play here. <a href="https://nelsonfigueroa.dev/uniqueness-constraint-between-two-columns-in-rails/">This article</a> sums the process up perfectly! First create and migrate a new migration to add_index, specify the table and put the two related attributes in an array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ji1-CR_pcZRlcLca0QK1LA.png" /></figure><p>Next make sure to write your validations. We are checking one of the two attributes in the add_index array, ensuring that it has uniqueness within the <em>scope</em> from the other attribute, else returning a validation error message.</p><p>Ok! Resources Generated, Migrated, Seeded, Model-Relationships established, Validations set. Now what? These models need a way to <em>interact </em>with the front end. We do that in the Controllers. Because rails g resource opened up full CRUD capability for each resource generated, we need to create those methods in the Controller to <em>view and manipulate </em>the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8WWMwqetGslDQ0zEsodtw.png" /></figure><p>A closer look will reveal that these controllers aren’t so different. Each of these similarly-named-methods has the same functionality across the classes; and they use the <strong>private methods. </strong>One isolates an instance of its Class for view (show) or manipulation (update and destroy). The other allows only permitted params to be accessed in order to create or update.</p><p>With our communication between front and back end set up, I recommend one last thing before we can start building out our site/displaying information.<strong> Error handling.</strong> What if the Gym we search for doesn’t exist? Or the Membership one is trying to create <em>already</em> exists? Our Server should have a way to communicate that to our Client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HzNghv6ZeM9s7DxJN64q9Q.png" /></figure><p>If you notice I have included bang operators when I call the .create and .update methods in the above Controllers. This will ensure if something goes wrong (either a record isn’t found or it isn’t able to be processed) an invalid exception will be raised. In <em>application_controller.rb </em>we have created some rescue_from rescue exceptions that are raised in controller actions, then pointed them to which ActiveRecord error class it is coming from, and and an action (method) to execute when that exception is raised (as referenced in private methods below). This way, a much more comprehensible error message is thrown for us to dive deeper into what actually went wrong.</p><p>Whew! That was a lot, but hopefully this stepwise understanding helps uncover the logic of <em>why </em>things are done in this order and how you can best set yourself up for success!</p><p>Thanks for tuning in.</p><p>Bye.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75caf27e76c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[These Ruby/Active Record Methods will save you hours! (also, refactoring is your friend!)]]></title>
            <link>https://medium.com/@mark.n.bacon.jr/four-ruby-active-record-methods-that-will-save-you-hours-3f8e2ba3f029?source=rss-d2729df3753c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f8e2ba3f029</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[activerecord]]></category>
            <dc:creator><![CDATA[Mark Bacon]]></dc:creator>
            <pubDate>Sun, 08 May 2022 17:50:12 GMT</pubDate>
            <atom:updated>2022-05-08T17:52:06.670Z</atom:updated>
            <content:encoded><![CDATA[<p>I have this saying when I see a problem with my code and the dread starts to mount regarding how tackle it: “Just start with what you know”. This has served me very well in my beginning stages as a developer to quell my anxiety about how to work through seemingly insurmountable problems.</p><p>Sure, starting with what you know is important, but equally as important is challenging yourself with what you <em>don’t know</em>. This (<em>in my humble opinion) </em>is what sets a colorful, creative Dev apart from a milquetoast one. By refactoring you learn not only how to make your code more Time/Space complexity-efficient, but you get to exercise your mental stamina by solving a problem from another approach.</p><p>When I first began my Ruby journey I realized that while my JavaScript-trained brain could eventually bang out an algorithm that ran the code I desired, Ruby in combination with an Object Relational Mapping program (like Active Record) had so many other ways to skin that proverbial cat.</p><blockquote><strong>Example 1</strong>: A Dev receives Freebies (has_many :freebies) from a convention, and is by proxy connected to many Companies (has_many :companies, through: :freebies). What if we wanted to take an example item and compare it against the items the Dev has in their Swag Bag?</blockquote><p><strong>Start with what you know</strong>: Iterate over each item in the Dev’s Swag Bag, compare it to the item in question; if they are deeply equal push into the array, else do nothing. Return the array. **Note: this example only works because if nothing exists in the bag, the value will be Null which is a falsy value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXhD3yG4KSNJGrwZP96PqA.png" /><figcaption>A long-form approach to returning a boolean based on an item’s existence</figcaption></figure><p><strong>Rethink our approach</strong>: Great! It’s working! But surely there is a way to make this better…. Luckily, Ruby has a method called <a href="https://apidock.com/ruby/Enumerable/any%3F">.any?</a> that minimizes our work! This enumerable allows us to iterate through the freebies of our Dev instance and implicitly return a boolean based on if <em>any of the values iterated </em>are equal! No more creating an empty array and returning it at the end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*gSJ00nUPOpl6d2NG55UKKQ.png" /><figcaption>A refactored way using the .any? Ruby enumerable method</figcaption></figure><blockquote><strong>Example 2:</strong> Let’s talk Bank Accounts. Total all international funds that a User has. An account belongs_to: a Bank and also belongs_to a User (while a User has_many :accounts and has_many :banks, through: :accounts).</blockquote><p><strong>Start with what you know</strong>: Initially, I set a variable equal to 0, iterated over all accounts the user owned, created a conditional that stated if the Bank’s country was <em>not equal </em>to the User’s country of residence, reassign the international_funds variable to be that instance of the balance <em>plus </em>itself. Once iteration is finished, return the variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4ohmMG3uUhSj42DADPAww.png" /><figcaption>An initial approach to getting the sum total of all foreign bank balances</figcaption></figure><p><strong>Rethink our approach</strong>: This totally runs! But look at how many SQL queries that were made — one for each Bank. Imagine if our data was larger than 10 banks, how could we optimize this? Enter <a href="https://apidock.com/rails/Enumerable/sum">.sum</a>— this handy Enumerable Method allows us to look at each accounts and aggregate the total using similar logic to above; if the User.country_of_residence is different from bank.country, then add that balance, else add 0. I even threw it all onto one line because who doesn’t love a one-liner? Here, SQL is only querying each bank where the user holds an account, bringing our calls down from 9 to 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIctPgaG7PkBt9B4eRHMPw.png" /><figcaption>Using .sum to cut down the amount of SQL queries</figcaption></figure><p><strong>Extra Credit: </strong>The above is good, but <em>can it be better? </em>Using the .where.not Active Record method in conjunction with .sum, we are able to make it so. This newfound method is iterable so we can set the truthy ids array to a variable, foreign_accts, and use that as our value for when we call .sum. WOW. This only calls three SQL queries and still gives us what we desire.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LmHlmICU8B_adcbNS15lQ.png" /><figcaption>Look at us, refactoring for optimization</figcaption></figure><blockquote><strong>Example 3: </strong>For the final example, let’s take a look at some concerts and venues. A Concert has_many: venues and has_many: bands, through: :venues. We want to find the band with the most concerts played at a given venue.</blockquote><p><strong>Start with what you know</strong>: Using what we know, we could create an empty hash, concert_hash and then map over each concert played in the venue. We want to get an <em>aggregate </em>of the total concerts played for each band, so using a ternary we can determine if the band.id exists in concert_hash, we will will increment it, else we will initiate it by setting that band’s value to 1. We now have a has that would look similar to {1=&gt;3, 3=&gt;5, 2=&gt;7} where the key represents the Band&#39;s id and the value is the number of times they have played at the Venue. Now to find the max. Set a variable, max_v to the hash’s values and call the max method. Set <em>another </em>variable, b_id, in which we iterate over the hash, and select the value that matches max_v (our maximum value). Look at the keys, and take the [0] index of the selection to pick the band id out. Then use the .find method on Bands with b_id to find the Bandinstance and not just the number of times they played. WHEW. That’s a lot. But hey, if it runs, it runs!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mc9Y7dxtcBmaUHNWmvRx2g.png" /><figcaption>Doing the actual most</figcaption></figure><p><strong>Rethink our approach</strong>: Ok, certainly we can save a few keystrokes… but how? We can use our pre-existing logic as a jumping off point. The objective is to go through each concert at the venue and <a href="https://apidock.com/rails/v4.0.2/ActiveRecord/QueryMethods/group">group</a> by some unique factor (in this case by :band_id) then to take the <a href="https://apidock.com/ruby/Array/count">.count</a> of each grouping to get the same concert_hash as we created above. And now, please welcome to the stage the .max_by method! <a href="https://apidock.com/ruby/Enumerable/max_by">Max_by is cool</a> because it iterate <em>and </em>enumerates at the same time. Using a key/value pair code block we can go through the hash and return key/value hash with the maximum value count of concerts played in this Venue. Of course we don’t need the number of concerts played once we have already found the max, simply the id of the band so grab the [0] index. Great! Call the find method on this id we have discovered and viola! We have come to the same conclusion, saved ourselves a ton of keystrokes, asked SQL to make less queries, <em>and</em> we have something that is easier for Dev’s down the line to read and understand!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7hK4uf8YMO_19wpBGLEHQ.png" /><figcaption>Knowledge of more methods allows us to tackle problems from different angles</figcaption></figure><p>Conclusion: While the objective at first is to write code that <em>runs, </em>there are many ways to get there.<em> </em>Eventually it becomes paramount that we learn different ways to refactor our code so that it can run more efficiently, more creatively, or just in a way that we previously didn’t know it could run! Using methods that Active Record and Ruby give us like .group, .count, .sum, .max_by, .any?, and .where/.where.not allow for our programming to become flexible. I hope it was enlightening for you to see <em>just</em> how flexible our code can become.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f8e2ba3f029" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Browser Console and it’s methods: A Deep Dive]]></title>
            <link>https://medium.com/@mark.n.bacon.jr/if-you-have-been-computer-programming-for-more-than-a-few-days-chances-are-you-have-utilized-the-f61c70c8285b?source=rss-d2729df3753c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f61c70c8285b</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[browser-console]]></category>
            <category><![CDATA[console-log]]></category>
            <category><![CDATA[flatiron-school]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mark Bacon]]></dc:creator>
            <pubDate>Sun, 17 Apr 2022 02:35:03 GMT</pubDate>
            <atom:updated>2022-04-17T02:36:51.088Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have been computer programming for more than a few days, chances are you have utilized the console tool in your browser.</p><p>When one right clicks, they may open up the browser Dev Tools by clicking “Inspect” and there, a litany of information about the page they are currently viewing can be explored, including but not limited to what Elements exist (and how they are styled) on the page, the <em>waterfall </em>of response requests in the Network tab, and even some Security elements for our more skeptical Devs who want to ensure the connection is secure.</p><p>When troubleshooting, however, a developer’s <em>best </em>friend can be the Console tab. This single tool allows us to find out what the browser understands given the information that we as programmers have told it. Think of this console.log as a translator between the programmer ‘human’ language and the computer’s <em>internal</em> language that actually executes the functionality we write for it.</p><p>Now I don’t know about you, but as I begin my Software Engineering journey, I have used the console.log <em>extensively. </em>So much so, that in my short time I feel like somewhat of a savant when it comes to understanding the return of what console.log produces — be it the variable in question, the definition of a function that I write, or the data I pull from an API in knowing how to distribute it appropriately.</p><p>But did you know the Console has multiple methods? <strong>22 methods </strong>to be exact<strong> </strong>(<a href="https://developer.mozilla.org/en-US/docs/Web/API/console">according to MDN</a>) . And while some are non-standard (recommended not to be used in client facing programs due to their erratic nature across different browsers), I have spent my first months as a Dev without fully utilizing any method <em>but </em>console.log because it was ~scary~ to use something different. But I’m greedy. And curious. If 22 methods are available to me, why would I only explore 4.5% of the Console’s capability?</p><p>My goal is to demystify some of the more important console methods so that you and I can effectively use them in not only debugging but learning to be a more well rounded Engineer. Come with me!</p><p>Probably the most related to <strong>console.log()</strong> are the <strong>console.warn()</strong> and <strong>console.error()</strong> methods. They behave similarly in that they both produce output to the console but the output is presented in different ways. You have probably seen these before even without recognizing it — these methods are used for testing purposes, the best example being a rejected promise from a fetch request. If the Dev is forward-thinking and pessimistically rendering, a bad request will throw an error to the console usually, alerting them that something isn’t right. Example from MDN linked <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/reject">here</a>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FlBkRfl3ksojEpxAPyQdhg.png" /><figcaption>These are the different outputs for the console.warn and console.error methods. Note one in yellow and the other in red!</figcaption></figure><p>A quick learn is the <strong>console.clear()</strong> method. This is a relatively simple one — it just <em>clears </em>the console when things are too congested. If you are working within console, the shorthand for this is to just type <strong>clear()</strong>. There is also a button that looks like stop that will do the same!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2nU_9JwTYx39-08wg5_Qw.png" /><figcaption>Click the button that is circled or type console.clear() (or just clear() ) in order to get a fresh console!</figcaption></figure><p>If you aren’t sure what properties you have access to within the object that you are working with <strong>console.dir()</strong> is your best friend. This one is probably the most fascinating find of my deep dive into console methods. All you need to do is specify the object you want to look into and you will get a list of <em>every </em>property attached to it. Go ahead, try this out in your browser now! Neat stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*JuHgLozOWmjneKzhejj8EA.gif" /></figure><p>If you are looking to track user interaction, or even just how long it takes for an application to load, then <strong>console.time()</strong> is right on the money. This method allows you to clock how long it takes for a certain set of actions to complete. Specify in the parentheses a name for your timer — console.time(“foo”) and stop the timer with console.timeEnd(“foo”). When finished, it will print the time in ms it took for the action to complete! If you want to have logs in between, console.timeLog(“foo”) will log the interim actions in between start and end! The best part? The browser allows a Dev to create up to <em>10,000 timers per page. </em>I challenge you to find a use for that many timers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UM8OTXK6ebZ7NL13vlNjNg.gif" /><figcaption>This mockup shows how long it took a user to accept Terms and Conditions, then be redirected to the site!</figcaption></figure><p>Think of <strong>console.count()</strong> and <strong>console.countReset() </strong>as yin and yang. The first allows you to keep track of how many times something was called — this can be used one of two ways; if the argument is empty, just the number of times it has been invoked will be counted, but if a label (or <em>variable</em>) is passed in, the method will count how many times each of those variables were called. This is especially helpful for recounting how often something occurs in your code. Below you can see for each time the function of spending was invoked, or each time the value of count <em>itself</em> changed, there is a record of that number! <strong>Console.countReset()</strong> works similarly but allows us to reset the counter upon invocation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*jWS1K0YBcNGWfDe489BUmw.png" /><figcaption>Here you can see that variable wallet’s value was 15 <em>one time, 100 two times, and then 14.99 one time!</em></figcaption></figure><p>For our last example, I want to talk about <strong>console.table(). </strong>Rarely is the data we are working primitive (booleans, numbers, or strings). Often we are working with Arrays, Objects or a nested combination of both! Enter console.table(). This method allows a Dev to input these difficult data types and outputs an indexed table (as well as the original object underneath!) for easier comprehension of the data to be worked with. One caveat here is that this method is not compatible with Internet Explorer!</p><p>Check out <a href="https://dev.to/nehasoni__/power-of-console-table-in-javascript-18n0">this example</a> from dev.to below!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzR1KJL8oBfqM5wlRgHySA.png" /><figcaption>A Table of the information in this nested object. All laid out for easier readability.</figcaption></figure><p>There are a few additional methods like <strong>console.group()</strong> and <strong>console.assert()</strong> that I didn’t cover but really recommend looking into all methods that console has graced us with. After all knowledge is power, and in our quest for knowledge as Devs, I hope to be the most powerful I can be ^_^.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f61c70c8285b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>