<?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: Elvis Pestana</title>
    <description>The latest articles on DEV Community by Elvis Pestana (@elvispt).</description>
    <link>https://dev.to/elvispt</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%2F27750%2F23924a23-1b79-4503-a351-36ddb835807e.png</url>
      <title>DEV Community: Elvis Pestana</title>
      <link>https://dev.to/elvispt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elvispt"/>
    <language>en</language>
    <item>
      <title>No glorified hello worlds here</title>
      <dc:creator>Elvis Pestana</dc:creator>
      <pubDate>Mon, 08 Jan 2018 00:28:31 +0000</pubDate>
      <link>https://dev.to/elvispt/no-glorified-hello-worlds-here-4jbi</link>
      <guid>https://dev.to/elvispt/no-glorified-hello-worlds-here-4jbi</guid>
      <description>

&lt;p&gt;In the years I have been developing software, mostly web-focused, something was always missing: Unit testing. This was due to have been in companies whose culture abhorred anything that leads to delays, even justified. Something that could not be easily justified, cost-wise, as an advantage would be throw out the window.&lt;/p&gt;

&lt;p&gt;My experience is limited to personal projects with perfect world requirements. So, in the end, I consider myself as a beginner on unit testing.&lt;/p&gt;

&lt;p&gt;Where to start? I can analyze — and have analyzed — projects with unit testing implemented but nothing replaces hands-on experience in real projects with users and it’s edge cases. Glorified “hello worlds” do not count.&lt;/p&gt;

&lt;p&gt;Going back a little, I understand the advantages of unit testing. I’ve seen projects with testing implemented and the benefits it’s bringing to the table, but it’s been impossible to convince management of its importance — and even other senior developers. Maybe I’m not good at communicating the pros and cons.&lt;/p&gt;

&lt;p&gt;Finally, the other issue that unit testing brings. Testing is like digital security. Whoever is responsible for this will always be in an ungrateful position to defend. When everything is going well, that unit testing is doing its job properly and the devs reap the benefits someone will probably say — or at least think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are we wasting time with unit testing if everything is going so well? Why am I paying you?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or even when the &lt;strong&gt;inevitable&lt;/strong&gt; bugs occur:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why are we having problems? I thought we had unit testing. Why am I paying you?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q8m6a44P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACfdxLFqER3D-buDMmBh5sw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q8m6a44P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACfdxLFqER3D-buDMmBh5sw.jpeg" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/photos/5oyFrBF33Q4?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Edu Lauton&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is aggravating.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One time I was meeting the teams on a new company that, eventually, I joined and I remember asking “Do you do unit testing?”. The happy answer was “of course”. I was happy that I would be joining a company where I could get experience with unit testing on real-world projects. Little did I know he was referring to end-user testing. There was a team dedicated to testing entire user processes, from start to finish, to make sure everything was according to the requirements. This was good to have, but it was not unit testing. I later found that this company had an annoying habit of using industry standard names that meant something completely different inside the company. Consultants? = Glorified salesmen.&lt;/p&gt;

&lt;p&gt;Articulating the advantages seems hard when even seasoned devs don’t want or care about unit testing. In real life, we also have to take into account company policy, personal interests — I want this project done ASAP! — which usually means getting closer to that bonus.&lt;/p&gt;

&lt;p&gt;What are the usual pros? Let’s list them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finds bugs early — The sooner a bug is found, the less likely it appears on production.&lt;/li&gt;
&lt;li&gt;Improves code quality and readability — A big advantage for big projects.&lt;/li&gt;
&lt;li&gt;Facilitates changes giving greater confidence to the developer that his changes did not break existing functionality, therefore…&lt;/li&gt;
&lt;li&gt;… boosts developer productivity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sum all of the above and you have the biggest pro since it reduces costs in the medium to long-term.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I can analyze projects with unit testing implemented but nothing replaces hands-on experience in real projects with users and it’s edge cases. Glorified “hello worlds” do not count.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What are the downsides? Let’s take a look:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does not guarantee bug-free code. This is the obvious one, but somehow some people believe unit testing to be magical.&lt;/li&gt;
&lt;li&gt;Time-consuming. Same as saying it costs more. Can’t release the project on time, or the project must have features cut. Managers/Clients don’t like to hear that.&lt;/li&gt;
&lt;li&gt;Unit tests can/will have bugs. This one is down to the quality of the dev team. Have less discipline here and you will get in trouble.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It boils down to cost. A company culture that does not allow a developer to fail will not have unit testing. If you cannot count on your teammates to help, you will not have unit testing. If your company only sees you as a row on an excel spreadsheet, that means you will actually get burned with unit testing (cost) and then you will not have unit testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nIzM3WfH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AJsodd7y2uNxBeWED_ufuHg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nIzM3WfH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AJsodd7y2uNxBeWED_ufuHg.jpeg" alt=""&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/photos/82TpEld0_e4?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;G. Crescoli&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After reading much about unit testing the greatest advantage I see is that it makes us focus and reflect on the code written. If your code is too big or hard to read, you will most likely refactor it. In a team, this will lead to increased productivity with higher quality code bases. As a developer, I don’t need any more reasons to like unit testing.&lt;/strong&gt;&lt;/p&gt;


</description>
      <category>programming</category>
      <category>unittesting</category>
      <category>testing</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>And these debts will be paid with interest</title>
      <dc:creator>Elvis Pestana</dc:creator>
      <pubDate>Mon, 01 Jan 2018 22:23:51 +0000</pubDate>
      <link>https://dev.to/elvispt/and-these-debts-will-be-paid-with-interest-150i</link>
      <guid>https://dev.to/elvispt/and-these-debts-will-be-paid-with-interest-150i</guid>
      <description>&lt;p&gt;Something that has always bothered me, in my programmer career is building code for the short term, or the temporary hack, that will remain forever in the code base. I find it that temporary hacks are nothing more than ignorance on how, and how long, it takes to solve a specific problem.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“There’s nothing more permanent than a temporary hack.” — Kyle Simpson&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Does this mean I have never done it? Of course I have, and all programmers have done it at some point in their career and, like me, will probably do it again.&lt;/p&gt;

&lt;p&gt;So we do it on purpose, right? Well &lt;strong&gt;yes&lt;/strong&gt; and  &lt;strong&gt;no&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yes because we are pressured by deadlines to deliver a product on time and on budget. A good developer that does this on purpose is aware of its problems, so it takes notes and/or creates an issue on the issue tracker to solve it a later time. The problem here is the “ &lt;strong&gt;a later time&lt;/strong&gt; ”. If your teammates and management in your company don’t understand that it has to be done, this will, almost every time, come bite you in the ass at a later date.&lt;/p&gt;

&lt;p&gt;How? The two most common scenarios.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Another hack will be made to compensate the shortcomings of the first one. This will pile on and a third, fourth, ad infinitum, hacks will be made to compensate the shortcomings of the previous one.&lt;/li&gt;
&lt;li&gt;Since your name was on the commit and due to the shortcomings of said hack, you will take the blame for the time it takes to “fix” the hack — see scenario 1.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Aog3DjfY1v_eU4q6vNRqXHw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2Aog3DjfY1v_eU4q6vNRqXHw.jpeg"&gt;&lt;/a&gt;Photo by &lt;a href="https://unsplash.com/photos/rX12B5uX7QM?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Ian Espinosa&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This eats away at the productivity of your team and causes a &lt;a href="https://en.wikipedia.org/wiki/Sunk_cost" rel="noopener noreferrer"&gt;sunken cost&lt;/a&gt;. The reasons for this cost are not obvious. The only thing that is noticed, by management, is that more money has to be spent on the project.&lt;/p&gt;

&lt;p&gt;If someone on your team does not take notes on the hacks, this is a sign of future pain and suffering for the entire team.&lt;/p&gt;

&lt;p&gt;Every month or so — your mileage may vary — some time should be set aside to solve these issues or risk getting drowned in them.&lt;/p&gt;

&lt;p&gt;No , because the developer is unaware of the problems due to having low experience on how the code affects the code base. This is either inexperience as a programmer or inexperience with the code base itself. These hacks work great in the short term and give the appearance that the programmer can work in any environment, but is only leading to technical debt.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And these debts will be paid with interest.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you scale of perfection is 1 to 10, with 10 being perfect, then always aim to 10 even though you will never get there. You will reach, hopefully, an 8 or even 9, but if you aim to the 8, you will be content with a 6 — until the day you have to maintain that code.&lt;/p&gt;

&lt;p&gt;So my new year’s resolution will be to avoid hacks whenever possible and make sure my teammates understand the consequences of technical debt. Use mentoring, use technical tools — code reviews — or anything that is required to make sure everyone is on board.&lt;/p&gt;




</description>
      <category>softwaredevelopment</category>
      <category>technicaldebt</category>
      <category>teamcollaboration</category>
    </item>
    <item>
      <title>Adventures in Laravel 5.4 land — view management</title>
      <dc:creator>Elvis Pestana</dc:creator>
      <pubDate>Thu, 03 Aug 2017 19:01:02 +0000</pubDate>
      <link>https://dev.to/elvispt/adventures-in-laravel-54-land--view-management-2k8o</link>
      <guid>https://dev.to/elvispt/adventures-in-laravel-54-land--view-management-2k8o</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AolJUeL2ziDvUPnXBBbPCYA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AolJUeL2ziDvUPnXBBbPCYA.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;update: This also works fine in Laravel 5.5&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recently started working with Laravel (5.4) and so far it’s been a joy to work with.&lt;/p&gt;

&lt;p&gt;The first roadblock I encountered was on &lt;strong&gt;how to organize views/templates&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Page templates
&lt;/h3&gt;

&lt;p&gt;I went down the simplicity path, having the following rules:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Grab the controller name, exclude the &lt;em&gt;Controller&lt;/em&gt; part of the name, put it to lowercase. With this we have a folder that will house the templates that are used by that controller. For example: &lt;em&gt;HomeController&lt;/em&gt; &amp;gt; Home &amp;gt; home.&lt;/li&gt;
&lt;li&gt;Let’s assume that we create a method inside HomeController whose job is to load a generic &lt;em&gt;about us&lt;/em&gt; page. So we create the method &lt;strong&gt;aboutUs&lt;/strong&gt; and call the relevant view. What’s the name of view? Just call it &lt;strong&gt;about-us&lt;/strong&gt; , which means a path &lt;strong&gt;/resources/views/home/about-us.blade.php&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The default controller method has a special name, &lt;em&gt;__invoke&lt;/em&gt;, and since I did not want to have a view called &lt;strong&gt;invoke.blade.php&lt;/strong&gt; I decided to just use the same name of the controller. So for now we have a folder called &lt;strong&gt;home&lt;/strong&gt; with a file called &lt;strong&gt;home.blade.php&lt;/strong&gt;. Based on these rules we can immediately assume, with a high degree of certainty, that the view &lt;strong&gt;home.blade.php&lt;/strong&gt; is called inside &lt;em&gt;HomeController::__invoke&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What about partials?
&lt;/h3&gt;

&lt;p&gt;Partials are blocks of code that are reused in more than one page/view, so I needed a set of rules for creating these, so that the location where they exists makes sense and gives an ideia of how it’s used. &lt;strong&gt;These rules assumed you are following the previously laid out rules.&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When the partial is only used among the views of a single controller, create a folder called &lt;strong&gt;partials&lt;/strong&gt; inside the controller view folder. Put your partials in these. Ex: &lt;strong&gt;/resources/views/home/partials/example-partial.blade.php&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When the partial is used by different controllers, then put them inside a &lt;strong&gt;partials&lt;/strong&gt; folder inside the views folder, on the same level as the controller views folder. Ex: &lt;strong&gt;/resources/views/partials/example-partial.blade.php&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Layouts
&lt;/h3&gt;

&lt;p&gt;I did not see a reason to change the location of layout files (&lt;strong&gt;/resources/views/layouts/master.blade.php).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’m sure there will be edge cases in which these rules cannot be applied, but I hope that these rules minimize those cases, instead of having the mess of view files that makes it hard to pinpoint what are it’s intended uses.&lt;/p&gt;




</description>
      <category>programming</category>
      <category>laravelblade</category>
      <category>laravel</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
