teleren/devto huggingface dataset:
Code Review Guidelines to Live By
Tags: codereview, codequality, productivity, webdev
Published: 2020-01-31 16:59:52

Code review is both the most difficult and the most critical part of a developer's job. It's the way great code happens. But to get there, we have to get inside someone else's head and ask, why did they write this code this way? And then, after we thoroughly understand it: is there any way it could be better? Once we have that figured out, we still need to communicate it back to our fellow developer in a way that is clear, productive, and empathetic. 

I strive to achieve that balance by following these guidelines, inspired by my code review experiences:

## 1) Code reviews are a teaching opportunity.
Always explain why you're requesting a change, not only out of respect for the code author's time and intelligence, but also so that they will be better prepared for the next time they encounter the same issue. It helps to add links to any resources that could help explain concepts or patterns, and any tools that you're recommending. 

## 2) Code reviews are a learning opportunity.
If any of the code you're reviewing is new to you, or structured in a way that's unfamiliar, note it and look it up. Research if it's a best practice you should be aware of. If it is, incorporate it into your own code.

## 3) Code review comments are **not** the place to have a discussion.
As soon as the code author writes back to ask a question or make an argument, it's time to move the conversation out of the code review. Find a time that works for both of you and schedule a pairing session to hash it out. 

## 4) Use your code review to fight scope creep, not encourage it.
If a PR covers more work than the original issue or is difficult to review because of its size, flag that so the team can learn to avoid it in future. Think about ways the PR can be reduced in size, rather than expanded. Avoid the temptation to suggest changes to surrounding code, or reformats based on new style rules. Open new issues for these and unrelated bugs.

## 5) Don't Repeat Yourself.
If you catch an issue that reoccurs in multiple places in the code you're reviewing, point it out once and ask the code author to address any other instances. This demonstrates your trust in their abilities while allowing them to have the learning experience of finding and fixing the problem themselves, which will enhance their retention for next time.

## 6) Be kind, always.
“Everyone is fighting a battle you know nothing about." Keep your review positive and your language upbeat. Remember how it feels to receive criticism, and review the way you'd like to be reviewed. 

Further reading: [How to Make Good Code Reviews Better](https://stackoverflow.blog/2019/09/30/how-to-make-good-code-reviews-better/)
PayPal Integration in Laravel 6 Example from Scratch
Tags: laravel, paypal, payment, gateway
Published: 2020-01-31 17:14:19

Hi Artisan,

In this tutorial, i would like to guide you step by step paypal integration with laravel 6 application. we can easily integrate paypal payment gateway in laravel 6. i written laravel 6 paypal integration so your user can easily payment vie paypal account and credit card information.

https://www.codechief.org/article/how-to-integrate-paypal-payment-gateway-in-laravel
Exponents in Golang
Tags: go, beginners
Published: 2020-01-31 17:08:27

You can use exponents in <a href="https://golang.org/">Golang</a> *(Exponents are shorthand for repeated multiplication of the same thing by itself.)*. 

You need to import the math module to do that. It comes with the Pow function. This function works like this:

    math.Pow(base, exponent)

Go is not installed by default, so if you want to use Go, <a href="https://golangr.com/install/">install Go</a> first.

## Exponents example

Import the math module. Assign a base and exponent. Then you can call the Pow method and output the result:

```go
package main
import (
 "fmt"
 "math"
)

func main() {
 var exponent, base float64
 base = 2
 exponent = 3
 output := math.Pow(base, exponent)
 fmt.Printf("Result is %.2f\n", output)
}
```

## User input

For output, we wrote %.2f, which means two digits after the dot. You can use %f or %.4f if you need. What about input?

You can let the user type the base and exponent like this:

```go
package main
import (
 "fmt"
 "math"
)

func main() {
 var exponent, base float64
 fmt.Print("Base:")
 fmt.Scanln(&base)
 fmt.Print("Exponent:")
 fmt.Scanln(&exponent)
 output := math.Pow(base, exponent)
 fmt.Printf("Result is %.2f", output)
}
```

For numeric input you can use the Scanln() function, for plain text input you can use <a href="https://golangr.com/keyboard-input/">ReadString()</a>
How should a total beginner to the field of CS and Programming get started?
Tags: discuss, beginners, help, computerscience
Published: 2020-01-31 16:59:14

Hey DEV community! I have recently come across a situation that has put a great sense of responsibility on me. I come from a family where even the cousins like to stay in touch and meet regularly and I have turned out to be the eldest in my generation of cousins. 😲🎉

Now the time has finally come where I have a younger cousin who has finally reached the age of selecting what career she wants to pursue in the future. The awesome part is that she is interested in looking into the field of computers as a future. The catch is that I am the first person in this giant household/family to have ever pursued the field of Computers as a study choice and I still am pursuing my masters. 👨‍🎓

![A baby trying to read hard](https://media.giphy.com/media/8dYmJ6Buo3lYY/giphy.gif)

Her family would like me to help her out on checking out the field and decide whether she wants to fully commit or not! **How do I do that?**

She has **never had any computer subject as a study course in her school and high-school** tenure, so one can assume she is a total newbie to the field.

- Should I introduce her to the concepts of computer science like logical thinking,  algorithms, basic data structures initially?
<center>**OR**</center>
- Should I go for a basic programming language like C/Python?
<hr/>
- Should I find and introduce her to some of those *no-code drag and drop* tools which I have seen in news articles help children of much younger age than her learn too? (Do recommend if you have used any and loved it!)
<center>**OR**</center>
- Should I introduce here to a get started with XYZ Language?

I would love to hear from people more experienced in the field, both computer science, and the elder brother ones 😆, on what they think should be a sound option. Thank you for your time and help!
What Hollywood Can Teach You About Writing Good Unit Tests
Tags: productivity, webdev, computerscience
Published: 2020-01-31 16:58:08

There’s a surprising number of parallels between a good unit test and a good movie. Learning to write good unit tests is important since good unit tests are proven to increase velocity, while bad unit tests can have a detrimental effect on velocity. So let’s break down some of the elements of a good movie, and what that can teach us about good unit tests.

- A good movie takes time to establish character and motivations — a good unit test has the important parts of the initial setup in the test itself, and not in the beforeEach.
- A good movie doesn’t spend unnecessary time before the action — a good unit test puts uninteresting setup into the beforeEach.
- A good movie shows characters undergoing meaningful change — a good unit test covers a meaningful state change.
- A good movie shows the protagonist triumphing — a good unit test uses asserts appropriately to demonstrate correctness of code.
- A good movie doesn’t try to develop too many characters (sorry Game of Thrones fans) — a good unit test covers a single state change.
- A good movie has a clear beginning, middle, and end — a good unit test has the same with the AAA pattern: Arrange, Act, Assert.
- A good movie has a single climax — a good unit test only tests a single state/state change
- A good movie doesn’t take too long to end (sorry Return of the King fans) — a good unit test has a single “logical” assert and not a long series of different asserts.
- A good movie is filmed with the audience in mind — a good unit test is written with readability in mind.
- A good movie is filmed because someone had a story they needed to tell — a good unit test is written because a piece of code truly needed to be tested, and not just because a developer was jumping through hoops, or trying to hit a coverage requirement.
- A good movie is easy to follow and doesn’t confuse the audience — a good unit test doesn’t make use of branching or looping logic.

Did I miss any other parallels between good movies and good unit tests?

Happy coding!

Signup for my newsletter at [here.](https://is-tracking-link-api-prod.appspot.com/api/v1/click/4616255200034816/5570275139911680)
Visit Us: [thinkster.io](https://thinkster.io/) | Facebook: @gothinkster | Twitter: @GoThinkster
The Life-Changing Magic of Flat Code
Tags: tutorial, beginners, technique
Published: 2020-01-31 16:57:17

---
title: The Life-Changing Magic of Flat Code
cover_image: https://source.unsplash.com/ObpCE_X3j6U/900x500
published: true
tags:
- tutorial
- beginner
- technique
---
Here’s the situation, you come across some code and you have to start making sense of it. As you read the code you begin to build a mental model of how the pieces work, and then slowly but surely you get enough of it in your head that you see potential bugs or areas to improve.

The problem is that doing this is arduous work, and we can only accurately keep very little code in our head before we begin to over-generalize or lose detail.

When I’m working with teams of developers, I often will teach them to flatten their code. The idea is simple enough to demonstrate, but in this article I’m going to focus only one way to flatten code: **If statements**

Let’s take a look at a common block of code:

	function doAwesomeWork(isNotUnset) {

  	  result = null

	  if(isNotUnset) {
  	    for(int i = 0; i < 20; i++) {
    	      result = ...
   	    }   
  	  }
  	  else {
   	   return result
  	  }
	}

Ok, so this isn’t the most complicated thing I can produce, but it does force the mind to work. We have to remember what the `result` variable is doing, what we are checking in the first `if`, the purpose of the `for`, and within that what the `result` is being set to. Then we have to remember that if `isNotUnset` is false, then we send back a null `result`.

Also, I named `isNotUnset` that way to be mean. Though I bet you can find an example of that easily in every codebase you’ve seen.

Here’s the way I’d flatten the if:

	function doAwesomeWork(isNotUnset) {
	  if(!isNotUnset) {
	    return null
	  }

	  result = null
	  for(int i = 0; i < 20; i++) {
	    result = ...
	  }
	  return result
	}

Reading this is a little different. We check the first `if`, and we might be done there. Mentally we can treat this as a self-contained section and not have to remember it once it is understood.

Now we move to the meat of what this does. When I see the function, I can see very quickly that this function is about the loop. I can focus on that behavior instead of remembering the conditions that get me to it.

That is what this technique is about. So the goal when flattening `if` statements are:

- Get the business logic as close to the left margin as possible
- Use conditionals for errors and exceptions
- Remove `else` statements where possible

In this case, the business logic is the `for` loop, so I want that to the left. The way I break the `if` that contains it is to use it as an error check. I inverted the logic and turned it into an early return. That left me with the business logic as the only thing the function does if the pre-conditions are correct.

When you’re coding, give this technique a whirl. You’ll find that the code is way easier to understand, refactor, and test.

---

Hey devs I've launched a [newsletter](https://ryanlatta.com) for developers who want to make the most of their career. Come check it out!

*image credit [unsplash](https://unsplash.com)*
Where to look when you see "Job has been attempted too many times or run too long"
Tags: laravel, queues
Published: 2020-01-31 16:55:53

If you've seen this MaxAttemptsExceededException in your error logs or failed_jobs table and you don't have a clue what happened to the job, let me try to explain what may have happened. It's either:

1. The job timed out and it can't be attempted again.
2. The job was released back to the queue and it can't be attempted again.

If your job processing time exceeded the timeout configuration, the worker will check the maximum attempts allowed and the expiration date for the job and decide if it can be attempted again. If that's not possible, the worker will just mark the job as failed and throw that MaxAttemptsExceededException.

Also if the job was released back to the queue and a worker picks it up, it'll first check if the maximum attempts allowed was exceeded or the job has expired and throw MaxAttemptsExceededException in that case.
Exponents in Python
Tags: python, beginners
Published: 2020-01-31 16:53:02

You can use exponents in <a href="https://python.org">Python</a>, without using any modules. Let's see an example. To raise 3 squared, would look like this:

```python
    >>> 3**2
    9
```

Easy. So when using a single * it's multiplication, when using two ** it's raised.

To get 2 to the power of 3, you would use:

```python
    >>> 2**3
    8
```

## Raise many

To get a lot of exponents, you can use it combined with a for loop:

```python
    >>> for i in range(1,10):
    ...     3**i
    ... 
    3
    9
    27
    81
    243
    729
    2187
    6561
    19683
```

In these examples I'm using the <a href="https://pythonprogramminglanguage.com/repl/">Python interpreter</a>, you can <a href="https://pythonbasics.org/execute-python-scripts/">run it in code</a> too. But then you have to print the output.

```python
    x = 2**3
    print(x)
```

## Explicit output

You can output variables together with text like this:

```python
    for i in range(0,10):
        print("Exponent, 3 to the power of",i,"=",3**i)
```

This outputs the data in more descriptive terms:

```python
Exponent, 3 to the power of 0 = 1
Exponent, 3 to the power of 1 = 3
Exponent, 3 to the power of 2 = 9
Exponent, 3 to the power of 3 = 27
Exponent, 3 to the power of 4 = 81
Exponent, 3 to the power of 5 = 243
Exponent, 3 to the power of 6 = 729
Exponent, 3 to the power of 7 = 2187
Exponent, 3 to the power of 8 = 6561
Exponent, 3 to the power of 9 = 19683
```

**Related links:**
* <a href="https://python.org">Official Python site</a>
* <a href="https://pythonbasics.org">Learn Python</a>
Byteconf GraphQL - a free, virtual GraphQL conference - is LIVE now!
Tags: graphql, showdev, webdev
Published: 2020-01-31 16:44:59

**Today's the day – [Bytesized's](https://www.bytesized.xyz/s/youtube) free, live-streamed GraphQL conference is [airing right now](https://www.youtube.com/watch?v=IPQ-eBM9-BY)!**

[Tune in on YouTube and join attendees from around the world.](https://www.youtube.com/watch?v=IPQ-eBM9-BY) We're super excited for the first Byteconf of 2020, and couldn't be more proud of the excellent talks and speakers that we've been able to work with on this conference.

[Check out the conference here](https://www.youtube.com/watch?v=IPQ-eBM9-BY), and make sure to join our live chat to chat with attendees and speakers at the conference.

[![Byteconf GraphQL 2020](https://dev-to-uploads.s3.amazonaws.com/i/6cizhpm5co9jkvtlc9kp.png)](https://www.youtube.com/watch?v=IPQ-eBM9-BY)

[**Watch Byteconf GraphQL 2020 live on YouTube →**](https://www.youtube.com/watch?v=IPQ-eBM9-BY)
Example Golang with GraphQl
Tags: go, graphql, react, websocket
Published: 2020-01-31 16:11:35

Hello friends!
I'm glad to present a small project, which has the following stack:
1. Golang
2. GraphQl
3. WebSocket
4. ReactJS

You can try it out by [this link](https://react-kahoot.herokuapp.com/). It can be seemed not so interesting like a value project but if you look at [repo](https://github.com/sergey-telpuk/gokahoot) you can find some interesting practice like DI(dependency injection), ORM, gin+graphQl+websocket.
if you have any questions, don't hesitate, leave comments.
Derek Banas: UML 2.0 Tutorial
Tags: uml, architecture, patterns, review
Published: 2020-01-31 16:10:46

The course of lecture introduces an audience to different types of UML diagrams useful for software developers. They can describe a software system from different standpoints. It is utilised for the design of software systems and communication between engineers.

# For beginners: 
The knowledge might help to read some programming books. It is especially useful for learning of software design patterns.

# For experienced:
Refresh of UML might improve communication in a team. It should be beneficial for individuals who write articles or share knowledge in some other way.

The videos are available on [YouTube]
(https://youtube.com/watch?v=OkC7HKtiZC0)
What was your win this week?
Tags: discuss, weeklyretro
Published: 2020-01-31 16:01:16

---
title: What was your win this week?
published: true
description: Got to all your meetings on time? Started a new project? Fixed a tricky bug?
tags: discuss, weeklyretro
cover_image: https://cl.ly/188e843c2985/download/Image%202019-02-15%20at%202.36.37%20PM.png
---

👋👋👋👋

Looking back on your week -- what was something you're proud of?

All wins count -- big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Cleaning your house...or whatever else that may spark joy 😄

![](https://media.giphy.com/media/23lzAGaZOXkomLSR8c/giphy.gif)

Happy Friday!
Is it better to focus on one coding curriculum at a time as a newbie❓
Tags: discuss, beginners
Published: 2020-01-31 15:50:26

This year, I started [my self-directed journey in learning how to code](https://dev.to/maelingmurphy/my-self-directed-journey-to-becoming-a-software-engineer-begins-5g8j) and decided to start off with these three online curriculums:

- [freeCodeCamp Responsive Web Design](https://www.freecodecamp.org/learn/)
- [The Odin Project - Full Stack Ruby on Rails](https://www.theodinproject.com/tracks/1)
- [CS50 - Introduction to Computer Science](https://courses.edx.org/courses/course-v1:HarvardX+CS50+X/course/#block-v1:HarvardX+CS50+X+type@chapter+block@b94adcd6bd6b4e69b2af7eef0d828674) 

Throughout the course of this month, I decided to pause on The Odin Project about halfway during the Web Development section since I was covering HTML and CSS already in the freeCodeCamp curriculum. I'm now in the midst of the first project (Tribute Page) for freeCodeCamp and also in Week 2 of CS50.

I'm now starting to wonder if I should just focus on one curriculum fully and wait to finish one before attempting to complete the other. This is my first time learning how to program in C (in CS50) and because the other project in freeCodeCamp has a different focus (HTML & CSS), I wonder if I need to focus all my efforts on CS50 for the time being.  

So I want to know, what does your learning process look like? Have you ever worked on multiple courses (in different languages) at the same time? If so, what was that like? If you made the switch to just focus on one at a time, was that helpful for you? 

I would greatly appreciate your helpful input!
Beginners, What Would You Most Like to Build in a JavaScript Tutorial?
Tags: discuss, beginners, codenewbie, javascript
Published: 2020-01-31 15:45:10

---
title: Beginners, What Would You Most Like to Build in a JavaScript Tutorial?
published: true
description: Discussion of what content beginner JavaScript developers would like to see included in tutorials. 
tags: discussion, beginners, codenewbie, javascript
---

In many beginner JS tutorials, the end goal is to build an app of some sort, and they are frequently of a similar type: todo lists, stopwatch timers, pared down clones of common social media apps, etc. 

There's obviously good reason for this - when you don't have to expend too much mental energy understanding *what* you're building, it's easier to understand *how*. They are also limited in scope, which makes them more manageable.

However when I was working through many of this type of tutorial a few years back, I've got to admit that I sometimes found myself getting a little bored...

<hr/>

So I'm interested to hear from the beginners out there - ignoring any issues of difficulty or complexity - what kind of app would **you** want to build in a project style tutorial?
Switch – JavaScript Series – Part 10
Tags: javascript, codenewbie, beginners, webdev
Published: 2020-01-31 15:29:36

Switch can be used instead of if else. It’s almost like if else too.
```
switch(expression) {
case x:
code block
break;
case y:
code block
break;
default:
code block
}
```
First we need to write the switch then expression, this is mean on which variable you are trying to apply.

Cases are the specific if. Like case “todoroki” will be same of variable===”todoroki”

Let’s try the last code in switch.

First we need the variable name. Then we’ll write the switch for the name – switch(name) {} everything will go inside the second brackets.

Finally –

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4g7mnvj7u4fpml2pt05h.png)

This is almost same right ? So which one we should use ?

"As it turns out, the switch statement is faster in most cases when compared to if-else, but significantly faster only when the number of conditions is large. The primary difference in performance between the two is that the incremental cost of an additional condition is larger for if-else than it is for switch. Therefore, our natural inclination to use if-else for a small number of conditions and a switch statement for a larger number of conditions is exactly the right advice when considering performance.
Generally speaking, if-else is best used when there are two discrete values or a few different ranges of values for which to test. When there are more than two discrete values for which to test, the switch statement is the most optimal choice." - [oreilly.com]

So which one you are goint to use ?

You can see the graphical version here
{% instagram B78zoxVg_Mq %}

Source Codes - { Check commits }
{% github nerdjfpb/javaScript-Series %}

Originally it published on [nerdjfpbblog](https://blog.nerdjfpb.com/javascript-part-10/). You can connect with me in [twitter](https://twitter.com/nerdjfpb) or [linkedin](https://www.linkedin.com/in/nerdjfpb/)!
What's one thing you wish every developer knew?
Tags: beginners, discuss
Published: 2020-01-31 15:25:31

---
title: What's one thing you wish every developer knew?
published: true
description: If there was one  thing you'd like everyone to know, what is it?
tags: beginners, discuss
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/rx212xvea6h2h79wzlxp.jpg
---

If I could tell every single developer one thing, it's that there are more people using accessibility settings than they know. A huge chunk of users have the text size turned way up, are using screen readers, or can't get the sound the way the dev intended.

But I'd also like to tell everyone that regex can save them so much effort.

Oooooh oooh I'd also like to teach them a simple Unix search... 

Okay, what's one thing YOU would tell every single developer, senior or junior, in the tech industry?