<?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: pqyetman</title>
    <description>The latest articles on DEV Community by pqyetman (@pqyetman).</description>
    <link>https://dev.to/pqyetman</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%2F922627%2F70e23b24-eea0-4a16-9a4e-007159796e04.png</url>
      <title>DEV Community: pqyetman</title>
      <link>https://dev.to/pqyetman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pqyetman"/>
    <language>en</language>
    <item>
      <title>Object Oriented Programing Languages, Ruby, and Ruby Gems</title>
      <dc:creator>pqyetman</dc:creator>
      <pubDate>Wed, 26 Oct 2022 17:01:02 +0000</pubDate>
      <link>https://dev.to/pqyetman/object-oriented-programing-languages-ruby-and-ruby-gems-5g3m</link>
      <guid>https://dev.to/pqyetman/object-oriented-programing-languages-ruby-and-ruby-gems-5g3m</guid>
      <description>&lt;p&gt;Phase three of FlatIron introduced us to Ruby and SQL, but was more concentrated on Ruby. Ruby is an Objected Oriented programing language, to which we were told “Everything is an Object.” Because that sentence doesn’t hold any greater meaning to me, I decided to investigate a little further to try and make sense of that cryptic aphorism.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Object-Oriented Programing
&lt;/h2&gt;

&lt;p&gt;According to infallible Wikipedia on object-oriented programing languages, “Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).” It goes on to mention that methods can be attached to objects to modify the data (In ruby I have really been enjoying the simplicity of “dot chaining” those methods to anything I want). &lt;/p&gt;

&lt;p&gt;Also written on that Wikipedia “In this brand of OOP, there is usually a special name such as this or self to refer to the current object.” This has been especially useful in creating our custom methods, for a specific instance or an entire class.  &lt;/p&gt;

&lt;p&gt;One of the major aspects of OOP seems to be this idea of classes which according to Wikipedia is “the definitions for the data format and available procedures for a given type or class of object; may also contain data and procedures (known as class methods) themselves, i.e. classes contain the data members and member functions” and the relationship to objects which are “instances of classes”. I am not sure why but it makes me think of this Russian (&lt;a href="https://www.amazon.com/Heka-Naturals-Matryoshka-Russian-Babushka/dp/B0767F6WFQ"&gt;Matryoshka- I looked it up&lt;/a&gt;) doll, with each larger one being a class to the smaller one and each smaller one being object or instance of its larger class.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ruby
&lt;/h2&gt;

&lt;p&gt;I'd like to start off by saying I really do appreciate Yukihiro Matsumoto. This quote makes me think he is a good guy.  &lt;/p&gt;

&lt;p&gt;“Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run fast. By doing this, the machine will run more effectively. By doing this, the machine will something something something." They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.” &lt;/p&gt;

&lt;p&gt;Forget John Connor I think we know who our real champion is. For me, early on, you could tell by the naming convention of certain methods that this language was created to be, dare I say intuitive. Iterating through arrays and hashes seems much simpler than JavaScript. Even the following bit of code leaves little to guess what is going to happen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;100.times do 


        Customer.create(
        name: Faker::Company.name,
        address: Faker::Address.street_address     

        )

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

&lt;/div&gt;



&lt;p&gt;I'm sure this will change as things get more complex but for now, I am very content with the “dot-chaining” and method naming conventions. &lt;/p&gt;

&lt;h2&gt;
  
  
  Ruby Gems
&lt;/h2&gt;

&lt;p&gt;Just like the libraries and frameworks (ex: Bootstrap) with React in phase 2, ruby has a package manager called Gems. All of these Gems can be found at &lt;a href="https://rubygems.org/"&gt;https://rubygems.org/&lt;/a&gt; . Each gem has a name (ex. Rake), version (13.0.6), and platform (ex. Ruby – which means it works on any platform Ruby runs on.). Platforms depend on CPU architecture and operating system (MAC OS, Windows OS, etc). According to this following link &lt;a href="https://guides.rubygems.org/what-is-a-gem/"&gt;&lt;/a&gt; each Gem  follows the following file structure: &lt;/p&gt;

&lt;p&gt;To find out more about the GEM you would read the README file to get the proper procedure for installation and usage. The gemspec contains specific information about the author and version. The lib file contains the code, and the executable file is in the bin. A gem usually has a rake file, Rake is also a gem that was mentioned above. The gem’s rake file will allow you to automate tests, generate code and perform other actions from the CLI of your computer.  &lt;/p&gt;

&lt;p&gt;I did really enjoy this security aspect of ruby gems in the FAQ link &lt;a href="https://guides.rubygems.org/faqs/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“The same way you can trust any other code you install from the net: ultimately, you can’t. You are responsible for knowing the source of the gems that you are using. In a setting where security is critical, you should only use known-good gems, and possibly perform your own security audit on the gem code. &lt;/p&gt;

&lt;p&gt;The Ruby community is discussing ways to make gem code more secure in the future, using some public-key infrastructure. To see the progress of this discussion, visit the rubygems-trust organization on GitHub” &lt;/p&gt;

&lt;p&gt;Overall the message seems to be that ruby gems are a powerful tool just be careful what you download&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>backend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Beginners Explanation of Components, Props and State in React</title>
      <dc:creator>pqyetman</dc:creator>
      <pubDate>Wed, 05 Oct 2022 12:57:03 +0000</pubDate>
      <link>https://dev.to/pqyetman/a-beginners-explanation-of-components-props-and-state-in-react-28b6</link>
      <guid>https://dev.to/pqyetman/a-beginners-explanation-of-components-props-and-state-in-react-28b6</guid>
      <description>&lt;p&gt;As a beginner writing this after spending a week with REACT, this is most likely going to come across like the following link: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://tenor.com/view/charlie-day-its-always-sunny-in-philadelphia-pepe-silvia-charlie-kelly-crazy-gif-8129861"&gt;My Explanation Visualized&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  React - How do you speak it?
&lt;/h2&gt;

&lt;p&gt;It feels like the creator of react (Jordan Walke/Facebook/META/MIT?) really hated &lt;code&gt;document.createElement&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;document.querySelector("").appendElement&lt;/code&gt; and switching between screens to write HTML and JavaScript in general. So out of spite JSX was born, or at least this is the conclusion that I have come to. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Allegedly React was made it so that large amounts of code were easier to read, but as a student with just over a week in I don't believe it.&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;JSX appears to be &lt;code&gt;.innerHTML("")&lt;/code&gt; on steroids. And just as I was typing this blog, and coming to the conclusion "wow that's has to be dangerous" I came across this nugget via the following link &lt;a href="https://reactjs.org/docs/introducing-jsx.html"&gt;JSX&lt;/a&gt;: &lt;/p&gt;

&lt;p&gt;"By default, React DOM escapes any values embedded in JSX before rendering them. Thus it ensures that you can never inject anything that’s not explicitly written in your application. Everything is converted to a string before being rendered. This helps prevent XSS (cross-site-scripting) attacks."&lt;/p&gt;

&lt;h2&gt;
  
  
  Elements, Components and Props Oh My!
&lt;/h2&gt;

&lt;p&gt;Elements go inside of components and are how things get displayed on the DOM.  Elements are apparently cheap to create (I'm assuming that's cheap related to computing power as REACT only updates what's "new" when it renders?). They can contain multiple HTML components, variables, and object and array values. If you are mapping an array of elements make sure to use a key!&lt;/p&gt;

&lt;p&gt;Components (syntactically always get started with a capital letter) and are the blocks which make up the hierarchy of your application/program/website. These components can have parents or children (children must be exported in the child component and imported into the parent), not sure how many generations were allowed to use. More on that in a future blog.  &lt;/p&gt;

&lt;p&gt;Props are magical portals which allow you to share...stuff, with other components. That is so long as those Components have a parent child relationship. You &lt;em&gt;can&lt;/em&gt; share props indirectly with two sibling components, if the parent component gets involved...yeah that sounds right?&lt;/p&gt;

&lt;p&gt;These props are the logic that allows you to pass information from one component to another. This comes in handy when you have an event listener in a child component but need to re-render a parent component from that child component event. This is done using state in the parent component and by passing a callback function through &lt;em&gt;props&lt;/em&gt; to the child. Props can also be used to pass fetched API data down form parent to child components. One thing to know about props is that they have to be "pure", meaning &lt;em&gt;that if you pass a function with a parameter and argument you cannot alter that argument inside of the prop-function. So don't pass any count+= functions as props.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That should have been absolutely &lt;em&gt;crystal clear&lt;/em&gt;, now onto state...which I'm currently not a fan of. Hopefully that changes soon. &lt;/p&gt;

&lt;h2&gt;
  
  
  An Ode to State
&lt;/h2&gt;

&lt;p&gt;For a good day and a half I thought I always needed the state variable inside of the state setter function because of a misinterpreted Scrimba video, so I may still be a little bitter. &lt;/p&gt;

&lt;p&gt;Here's what I believe to be important about state:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You have to import it - &lt;code&gt;{useState}&lt;/code&gt; in the component you are using it in&lt;/li&gt;
&lt;li&gt;Its comprised of a state variable, a state function and an initial value to which your state variable is set&lt;/li&gt;
&lt;li&gt;You should use state when you need to change something in your component and re-render the page&lt;/li&gt;
&lt;li&gt;It will be initially confusing especially if you watch the Scrimba video I did.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The state variable gets set to an initial value in your component. Then if you want to change that initial value, you need to use the state function. The state function can change the value of the state variable to what ever you wrap the state function with. When this setter function is called it will re-render the page and assign the new variable value to the state variable. &lt;/p&gt;

&lt;p&gt;This was an oversimplified explanation of state, components and props. You can find out more about the items mention above in the following &lt;a href="https://reactjs.org/docs/hello-world.html"&gt;link&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
