<?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>Forem: presh900</title>
    <description>The latest articles on Forem by presh900 (@presh900).</description>
    <link>https://forem.com/presh900</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%2F427558%2F595f0e5c-16bb-4416-b73d-6ed915769221.png</url>
      <title>Forem: presh900</title>
      <link>https://forem.com/presh900</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/presh900"/>
    <language>en</language>
    <item>
      <title>Why I switched to Object Oriented PHP</title>
      <dc:creator>presh900</dc:creator>
      <pubDate>Fri, 17 Jul 2020 11:21:02 +0000</pubDate>
      <link>https://forem.com/presh900/why-i-switched-to-object-oriented-php-1203</link>
      <guid>https://forem.com/presh900/why-i-switched-to-object-oriented-php-1203</guid>
      <description>&lt;p&gt;Anyone starting programming with PHP automatically starts with procedural PHP. It's like the defacto mode for writing programs because it takes everything step by step and is easier to teach newbies. &lt;br&gt;
Having worked a little with Java and noticing how oop  made everything a little abstracted so you don't have to get your hands dirty, I knew if I wanted to write quality code, I will have to eventually switch to Oop PHP. &lt;br&gt;
Here are some things I noticed. &lt;/p&gt;

&lt;p&gt;Cleaner Code:&lt;br&gt;
This is like a no-brainer, I put all database queries in a class in a 'classes' folder and when ever I needed to perform any query all I had to do was&lt;br&gt;
$query = new DB;&lt;br&gt;
$insert=$query-&amp;gt;insert($Table, $column,$value);&lt;/p&gt;

&lt;p&gt;Notice how clean it is?? &lt;/p&gt;

&lt;p&gt;Helps in understanding Frameworks:&lt;br&gt;
All modern frameworks are written using oop so switching to this makes it easier to understand any framework at all. In my code. I implemented a logon class that logs in users and redirects them to Dashboards depending on whether they are admin or users. I implemented it with a static class like this &lt;br&gt;
Auth::isAdmin and Auth::is user so when I saw almost the exact syntax when works with laravel, I understood it immediately. &lt;/p&gt;

&lt;p&gt;Reduces Lines of Code:&lt;/p&gt;

&lt;p&gt;This is a no-brainer. No need to write long lines of code to check for  conditions or perform arcane logic or write 5 database queries in one script. All you need is to call the particular class and pass it the values and it performs  everything for you. &lt;/p&gt;

&lt;p&gt;Better IDE  usage:&lt;br&gt;
If you are writing Procedural PHP, you are not really making full use of your IDEs tools like intellisense and etc because they are built to work well with oop code and offer better code structures and autocompletes. &lt;/p&gt;

&lt;p&gt;🤔 There are other benefits, just try it out. I will suggest learning resources for oop in my next post. &lt;/p&gt;

</description>
      <category>php</category>
      <category>oop</category>
      <category>software</category>
      <category>laravel</category>
    </item>
  </channel>
</rss>
