teleren/devto huggingface dataset:
The Problem with Interfaces, and how Go Fixed it
Tags: go, interfaces
Published: 2017-05-13 03:44:22

---
title: "The Problem with Interfaces, and how Go Fixed it"
published: true
description: Interfaces have one huge flaw, that they need to be explicitly implemented. Golang fixes this problem.
canonical_url: https://blog.deanveloper.com/2017-go-interfaces/
tags: [Go, interfaces]
---

# Interfaces are great
They're honestly brilliant. Interfaces allow for simple, elegant programming. Let's use Java to get a quick idea of how to use interfaces.
```Java
package mypackage;

public interface Edible {
  public void eat();
}
```
Now, a `Burger` class to implement `Edible`.
```Java
package mypackage;

public class Burger implements Edible {
  public void eat() {
    System.out.println("Burgers, yum!");
  }
}
```
This means that we can use our `Burger` class wherever we see `Edible`, such as in method arguments!

# The problem with interfaces
But let's say that we are using a library, and that library has a class called `Salad`. Here's what `Salad` looks like:
```Java
package theirpackage;

public class Salad {
  public void eat() {
    System.out.println("I'm being healthy!")
  }
}
```
So `Salad` has an `eat()` method, but because the other library doesn't even know about `Edible` interface exists, it obviously can't implement it. This problem has definitely been encountered before, so let's talk about how Go has fixed it.

# How Go fixes interfaces
With how Go interfaces work, you don't need to declare an interface implementation. If you implement the proper methods, you implement the interface. This is very prominent in Go, and is a key feature. Let's use our previous example.

First, let's remake our `Edible` interface.
```Go
package mypackage

type Edible interface {
  Eat()
}
```
Now, let's make a `Burger` struct that implements `Edible`.
```Go
package mypackage

type Burger struct {}

// How to define a method in Go
func (b Burger) Eat() {
  fmt.Println("Burgers, yum!")
}
```
Notice that we never acknowledged `Edible` anywhere while we made the `Burger` struct. This is because *any* type that has an `Eat()` method associated with it is considered `Edible`. This means that even types from other libraries can be `Edible`, as long as they have an `Eat()` method!

This means that even this `Salad` struct from a different package is `Edible`.
```Go
package theirpackage

type Salad struct {}

func (s Salad) Eat() {
  fmt.Println("I'm being healthy!")
}
```

This shows just how awesome Golang is. I highly recommend watching their video, [A Tour of Go], which shows all of the brilliant features that Go has to offer.

EDIT: I really like the discussion on this post! One of the key things that I didn't mention here is that interfaces in Go should be used to describe simple patterns. [Here][TourInterface] is a clip from [A Tour of Go] that should hopefully describe how interfaces in Go should be used compared to how they're used in OOP.

[Go]: https://golang.org
[A Tour of Go]: https://www.youtube.com/watch?v=ytEkHepK08c
[TourInterface]: https://youtu.be/ytEkHepK08c?t=8m21s
Hi, I'm Alexander Maslakov
Tags: introductions
Published: 2017-05-13 00:18:29

---
title: Hi, I'm Alexander Maslakov
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for [number] years.

You can find me on GitHub as [jmas](https://github.com/jmas)

I live in [city].

I work for [company]

I mostly program in these languages: [languages].

I am currently learning more about [topic].

Nice to meet you.
A free introduction to Elixir, OTP, Ecto, and Phoenix
Tags: elixir, programming
Published: 2017-05-12 21:19:01

---
title: A free introduction to Elixir, OTP, Ecto, and Phoenix
published: true
description: Five weeks of free content to introduce people to the Elixir programming
tags: elixir, programming
---

![](https://cdn-images-1.medium.com/max/800/0*LkS0h-J96A7w6Ajr.)

Today, DailyDrip is releasing five weeks of free content to introduce people to the Elixir programming language and prepare them for building web applications using Ecto and Phoenix. 

[Check out the entire post!](https://medium.com/@dailydrip/a-free-introduction-to-elixir-otp-ecto-and-phoenix-228d0e994fc1)
Merged code belongs to the team, not the individual. Our language should reflect that.
Tags: teams, communication
Published: 2017-05-12 18:28:48

---
title: Merged code belongs to the team, not the individual. Our language should reflect that.
published: true
description: Our codebase is the collection of deadlines, constraints, necessary hacks, or unforeseeable mistakes. Asking "why did you do it this way" instead of "why are we doing it this way" can promote feelings of shame or defensiveness.
tags: teams, communication
---

_I'm sharing an internal memo publicly because I think it applies to everyone. Feedback is super welcome._

When commenting on other people's code, whenever possible, we should be using terms like _we_ and _ours_ instead of _yours_ and _mine_. Everyone owns all the code and there are important reasons for adopting this language.

Our codebase is the collection of deadlines, constraints, necessary hacks, or unforeseeable mistakes. Asking "why did you do it this way" instead of "why are we doing it this way" can promote feelings of shame or defensiveness. We need to make it easy to discuss our mistakes and accomplishment with the fewest barriers possible. A blameless culture is the way we will achieve this. The appropriate bug rate and mistake rate is not zero. An organization that does everything perfectly will never ship code. We will take pride in our work and recognize that no individual contribution exists in a vacuum.

This is a guideline, not a rule. There are plenty of reasons to stray from this spec and none of us choose our words perfectly all the time. In general, however, let's try to take collective accountability for our contributions and mistakes. Nobody should be stifled by the fear of letting the team down.

This mostly applies to code that has been already committed and/or merged. When the idea is fresh, it strikes me as okay to ask "Why did you make this choice?". When visiting existing code, the it is more appropriate to ask "Why did we make this choice?" even when talking to the person who totally wrote that code themselves. Even the code written by your past self could benefit from being viewed through this lens. It's easier to fix the warts in the codebase we actively talk about. Most of the time, the person who wrote the code is most aware its warts, but if they feel overly guilty, they may avoid bringing up the issue as often, or at all.

Likewise, there don't need to be superstars on the team. We disperse credit, like we disperse blame. We will obviously credit each other to some extent, but always remember that we are a team looking to set each other up for success, not strive for individual accolades.

It's a small thing, but it will help us ship better code.
Hi, I'm Marco Kellershoff
Tags: introductions
Published: 2017-05-12 12:10:28

---
title: Hi, I'm Marco Kellershoff
published: true
description: My introduction post
cover_image: 
tags: introductions
---

![Picture of Marco Kellershoff](https://thepracticaldev.s3.amazonaws.com/i/9vrtqe4a1ixvusn1mx28.png)

I have been coding for ~17 years.

You can find me on Twitter as [@walialu](https://twitter.com/walialu)

I live in Cologne.

I work for T-Online.

I mostly program in these languages: JavaScript, Bash, CSharp and Java.

I am currently learning more about Go and Rust.

Nice to meet you.
Hi, I'm Thang Chung
Tags: introductions
Published: 2017-05-12 04:29:55

---
title: Hi, I'm Thang Chung
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for over 10 years.

You can find me on GitHub as [thangchung](https://github.com/thangchung)

I live in Saigon, Vietnam.

I work for NashTech company

I mostly program in these languages: C#, JavaScript.

I am currently learning more about MSA, Clean Architecture.

Nice to meet you.
Hi, I'm Shell Bryson
Tags: introductions
Published: 2017-05-11 23:04:53

---
title: Hi, I'm Shell Bryson
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for 20+ years.

You can find me on GitHub as [shellbryson](https://github.com/shellbryson)

I live in Edinburgh.

I work for a digital agency in Scotland as a lead/senior front end developer.

I mostly program in these languages: SCSS/JS/Node.

I am currently learning more about React/React Native.

Nice to meet you.
Hi, I'm SaikCaskey
Tags: introductions
Published: 2017-05-11 15:59:31

---
title: Hi, I'm SaikCaskey
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for 8 years.

You can find me on GitHub as [SaikCaskey](https://github.com/SaikCaskey)

I live in that London.

I work for [iBlocks Limited](http://www.iblocks.co.uk/)

I mostly program in these languages: Android, Swift 3, Java SE/EE

I am currently learning more about Swift 3.

Nice to meet you chum :)
Stack Overflow just released a tool called "Trends" that tracks the popularity of programming terms over time.
Tags: stackoverflow, data, languages
Published: 2017-05-11 15:47:17

---
title: "Stack Overflow just released a tool called \"Trends\" that tracks the popularity of programming terms over time."
published: true
description: This tool should allow developers to make more data-driven choices about their careers.
tags: stackoverflow, data, languages
---

It can be frustrating to post a question on Stack Overflow while worrying if the library or language you're asking about is popular enough to get the quality response you're looking for. And it can be reassuring to put up a question about widely used tools that is likely to get answered.

You can now capture those sentiments graphically with the [Stack Overflow Trends](https://insights.stackoverflow.com/trends) tool, which, given a set of tags, will whip up a chart that shows their popularity over time going back to 2009. Here's one of their suggested searches, which shows the trends for Javascript frameworks:

![](https://thepracticaldev.s3.amazonaws.com/i/kne4gu5rmqxl1sqhy6o7.svg)

As you can see, Angular and React have been increasingly asked about in Stack Overflow questions since about 2015, while jQuery's relevance has steadily declined in the same time period.

Another pre-made chart shows the emergence of technologies in the data science realm:
![](https://thepracticaldev.s3.amazonaws.com/i/imte6xt1j5bto5s7cw30.svg)

The statistical programming language R has become much more prevalent on Stack Overflow, as has the Python package pandas, while MATLAB has struggled to stay above water. More recently, questions surrounding machine learning library TensorFlow have heated up.

Of course, it's more fun to come up with your own queries. Here's one showing every iOS release since iOS 7 along with a general iOS tag:

![](https://thepracticaldev.s3.amazonaws.com/i/6pjtrbvilnr2ju91nbf8.svg)

Each iteration has a personal peak around its release in the fall, only to be replaced in the next calendar year. Meanwhile, the general iOS tag is relatively stable.

Keeping an eye on emerging technologies is an important part of being a developer, no matter what language you're working in. It's also a worthwhile intellectual exercise to wonder why certain tools decline and others replace them. So give the Stack Overflow Trends tool a try and let us know what you can dig up—I'm sure there are findings worth blogging about!
Keep working Offline with Javascript
Tags: javascript, offline, cache
Published: 2019-04-21 15:23:08

---
title: Keep working Offline with Javascript
published: true
tags: javascript,offline,cache
canonical_url: https://dev.to/arojunior/keep-working-offline-with-javascript
---

![](https://cdn-images-1.medium.com/max/1000/1*Uk_l410QQJjs_JH1gUwikw.png)

_Note: It was originally wrote in Portuguese and translated by Google_

Let’s use as an example a system of messages exchange, where each message that you send is stored in a database for later to be displayed to someone. It could be a chat.

Now let’s imagine that you are using this system on your mobile and your connection is suffering oscillations due to bad connection with the carrier… In this case, some of your messages might not be delivered.

Recently I have known the [Offline-js](https://github.com/hubspot/offline) lib that monitors the status of your connection, issues alerts in case of drops, alerts when it returns, also monitors ajax requests and tries to resend them as soon as the connection returns.   
It also promises to do everything in an “automagic” way, you just need to import the library and that’s it. At first I thought it was beautiful, it was all I needed to solve the issues in my application.

But it is not that perfect. As soon as I started to test with this lib, bugs started to appear … I went to search the issues and had more people with similar problems, but nobody answers the issues! There are also a number of pull requests with fixes and no one accepts.

So I decided to use it as a dependency for some features and make my own implementation: [**https://github.com/arojunior/handle-failed-requests-js**](https://github.com/arojunior/handle-failed-requests-js)

- Promises support (axios)
- Uses _localStorage_ to save requests
- Saves ALL the failed requests, not just the last one
- Requests keep saved even if user try to refresh the page when offline
- Sends all requests as soon as the connection is restored
- No configuration needed

Use case:

{% gist https://gist.github.com/arojunior/c888497a44830c623badc298cbbb81c1 %}

Using this method, whenever a request fails, it will be stored in _localStorage_ and once the connection is restored, it will be sent again.

It is not a silver bullet, it is not about cache as well. You probably are thinking “why don’t you use Service Workers?”. Because SW is not compatible with all browsers, but localStorage is. That’s why.

It is an extremely simple implementation to use and understand. If you have any suggestion, feel free to comment or send pull request.
Hi, I'm Marcos Brizeno
Tags: introductions
Published: 2017-05-11 11:36:45

---
title: Hi, I'm Marcos Brizeno
published: true
description: My introduction post
cover_image: https://thepracticaldev.s3.amazonaws.com/i/zipoe2s5k92df2aeike2.jpg
tags: introductions
---

I have been coding for 5 years.

You can find me on GitHub as [MarcosX](https://github.com/MarcosX) and on Twitter as [@marcosbrizeno](https://twitter.com/marcosbrizeno)

I live in Belo Horizonte working for ThoughtWorks.

I mostly program in these languages: ["ruby", "javascript", "python", "java"] and am currently learning more about elixir and crystal.

Nice to meet you.
Hi, I'm Marek Dabek
Tags: introductions
Published: 2017-05-11 10:55:18

---
title: Hi, I'm Marek Dabek
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been trying to code something useful for the past 20 years. Yet, managed to deliver my 2 cents in the USB3.0 and MA-USB. Always wanted to join polish demo-scene, but did not have enough balls and brain. I live in the only livable place in Poland - Gdansk.
I am currently trying to learn Rust, which seems like a complete waste of time.


You can find me on GitHub as [mdabek](https://github.com/mdabek)


Nice to meet you.
Hi, I'm ìœ¤í˜•ì£¼
Tags: introductions
Published: 2017-05-11 10:31:58

---
title: Hi, I'm ìœ¤í˜•ì£¼
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for [25] years.

You can find me on Twitter as [@voiceman99](https://twitter.com/voiceman99)

I live in [Seoul].

I work for [Linksys]

I mostly program in these languages: [C,Lua,Javascript,Python,Objective-C].

I am currently learning more about [Web].

Nice to meet you.
Hi, I'm Steve Jalim
Tags: introductions
Published: 2017-05-11 09:38:30

---
title: Hi, I'm Steve Jalim
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for a decade or so.

You can find me on Twitter as [@stevejalim](https://twitter.com/stevejalim)

I live in Malvern, in the UK. I work remotely from here. It's nice up in the hills.

I'm a contract senior developer and team lead. 

I mostly program in these languages: Python and JS.

I am currently learning more about Elm and Elixir -- functional programming is fun.

Nice to meet you.
OAuth for Dummies
Tags: security, oauth, authentication, software
Published: 2017-05-09 16:10:24

---
title: OAuth for Dummies
published: true
description: A simple description of how OAuth works
tags: security, oauth, authentication, software
---

If you've ever accessed a website using your Facebook or Google credentials, then you've encountered OAuth.  OAuth is a authorisation web protocol for granting websites access to some of your personal information or access rights to some system.  The analogy usually given is that of a valet key, which makes no sense to me, as I own a rusty VW Beetle, but let's not worry about that.

If you're building such a website, you'll want to register it with the OAuth provider (Google or whatever).  They will give you an application id and secret. This secret allows you to speak OAuth to the provider.

So, much later, Joe Bloggs comes along and wants to access your website.  Your website sends a request to the OAuth provider (with your application id and secret) and gets given a conversation token.

Then, you redirect the user to the OAuth provider (but include the conversation token and a callback URL, which will have been included when you registered your app).  The OAuth checks the conversation token and URL, and then works out who the user is (e.g. asking you to log in) and then presents a consent screen: "Do you want to allow application X to access your Y?"  You check out the Y list and say OK (or not).  The OAuth provider then sends an HTTP post via the browser back to your website, with two tokens:

* an access token (the valet key), which allows you to ask the OAuth provider for Y things
* a refresh token (for when the access token expires, which will be frequently)


Hang on a minute!  What about these Y things?  How does the OAuth provider know what the website wants rights for?

OAuth calls that "scopes".  A scope is a name of a user "thing" that you're allowed access to.  It could be a user name, email, or a set of access rights. When the website does OAuth, it adds a some scopes to the OAuth request, and if they are in the permitted list, they get presented to the user.

And that is basically it.  There are some other nuances and stuff, but my car's broken down again and I need to run.
Hi, I'm Madusudanan.B.N
Tags: introductions
Published: 2017-05-11 08:54:55

---
title: Hi, I'm Madusudanan.B.N
published: true
description: Greetings fellow devs
cover_image: 
tags: introductions
---

I have been coding for around 6 years now.

You can find me on Twitter as [@BMadusudanan](https://twitter.com/BMadusudanan)

I mostly program in these languages: Scala,Java,Python.

I am currently learning more about machine learning.

[My personal website](https://madusudanan.com)
Hi, I'm Sascha Plaum
Tags: introductions
Published: 2017-05-11 06:27:53

---
title: Hi, I'm Sascha Plaum
published: true
description: My introduction post
cover_image: https://thepracticaldev.s3.amazonaws.com/i/6niv4aaxfeg8hzrwfcet.jpg
tags: introductions
---

I have been coding for 12 years.

You can find me on GitHub as [vreen](https://github.com/vreen)

I live in Siegbach / Germany.

I work for Loh Services 

I mostly program in these languages: Ruby, JavaScript, Bash.

I am currently learning more about Angular2, Docker.

Nice to meet you.
Hi, I'm Marcelo Andrade R.
Tags: introductions
Published: 2017-05-10 13:59:30

---
title: Hi, I'm Marcelo Andrade R.
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for 14 years.

You can find me on Twitter as [@MarceloAndrade](https://twitter.com/MarceloAndrade)

I live in Quito - Ecuador - South America.

I work remotely with [Toptal](https://www.toptal.com/#utilize-only-hero-developers) developing software for different companies across the globe. 

I mostly program in these languages: javascript, php, bash, sql.

I am currently learning more about functional programming in any language and in frontend I'm trying to wrap my head around elm.

Nice to meet you.
Hi, I'm Radhakrishnan
Tags: introductions
Published: 2017-05-10 06:27:08

---
title: Hi, I'm Radhakrishnan
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been software developer for 8 years.

You can find me on Twitter as [@KrishSelvaraj](https://twitter.com/KrishSelvaraj)

I program in these languages: Objective-C, JS (React Native) and  Swift.

I am currently learning about functional programming languages and machine 
learning.

In my current Job, I am setting up code reviews and design reviews as a process.
Hi, I'm Ana Ma
Tags: introductions
Published: 2017-05-10 05:10:19

---
title: Hi, I'm Ana Ma
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for one year.

You can find me on Twitter as [@anama118118](https://twitter.com/anama118118)

I live in New York.

I mostly program in these languages: Swift.

I am currently learning more about Push Notifications.

Nice to meet you.

<a href="http://www.youtube.com/watch?feature=player_embedded&v=D08l0X4W-dU
" target="_blank"><img src="http://img.youtube.com/vi/D08l0X4W-dU/0.jpg" width="640" height="175" border="10" /></a>
Hi, I'm Michael
Tags: introductions
Published: 2017-05-09 22:53:51

---
title: Hi, I'm Michael
published: true
description: My introduction post
cover_image: https://thepracticaldev.s3.amazonaws.com/i/mysf0tcf1ri9kd2mhg1j.jpg
tags: introductions
---

I have been coding off and on for 12 years.

You can find me on GitHub as [michaelsobota](https://github.com/michaelsobota)

I live in Denver.

I work for Charter Spectrum.

I mostly program in these languages: JavaScript.

I am currently learning more about Value Streams, Enablement Tooling, & DevOps!

Nice to meet you.
Hi, I'm Eldlabs
Tags: introductions
Published: 2017-05-09 21:22:31

---
title: Hi, I'm Eldlabs
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for [number] years.

You can find me on Twitter as [@EldLabs](https://twitter.com/EldLabs)

I live in [city].

I work for [company]

I mostly program in these languages: [languages].

I am currently learning more about [topic].

Nice to meet you.
Hi, I'm Illia Ratkevych
Tags: introductions
Published: 2017-05-09 21:21:41

---
title: Hi, I'm Illia Ratkevych
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for almost 6 years mostly on big enterprise solutions.

I love C# and Javascript - so I'm trying to use it 50/50 at work.

I have several pet-projects which I develop myself using Node.js and all that modern stuff.

Nice to meet you ;)
Hi, I'm Tobias
Tags: introductions
Published: 2017-05-09 21:09:20

---
title: Hi, I'm Tobias
published: true
description: My introduction post
cover_image: 
tags: introductions
---

I have been coding for almost the entire duration of my life. My Twitter handle is [@_T0b1as](https://twitter.com/_T0b1as), although, I don't use it. I live near Eindhoven, The Netherlands and study at the Eindhoven University of Technology. I work for VAA ICT Consultancy, and fulfill the position of a junior developer there. I don't really have a favourite language, just whatever is handiest. I've made the switch to Linux a while back, so I can work with anything that runs on Linux. Right now I'm studying for the course Automata & Process Theory. Nice to meet you!