teleren/devto huggingface dataset:
When to not use arrow functions in JavaScript
Tags: javascript, functions, idiomatic
Published: 2021-12-17 21:07:05

---
title: When to not use arrow functions in JavaScript
published: true
date: 2018-04-02 05:35:00 UTC
tags: javascript, js, functions, idiomatic
canonical_url: https://kevinlangleyjr.dev/blog/when-to-not-use-arrow-functions
---

Arrow functions are a more concise alternative to the traditional function expression but they aren't appropriate everywhere.

Let's check out some examples of times you would _not_ want to use arrow functions.

#### Scenario 1. Callback functions that require dynamic context.

Callback functions that require dynamic context, such as the element clicked, are not good candidates for arrow functions because you are unable to change the pre-defined context of `this`.


```js
const button = document.querySelectorAll( '.cta-button' );

button.addEventListener( 'click', () => {

this.classList.toggle( 'selected' ); // `this`refers to the Window. 😔

} );
```

Using a regular function allows the value of `this` to change based on the context of the target element.


```js
const button = document.querySelectorAll( '.cta-button' );

button.addEventListener( 'click', function() {

this.classList.toggle( 'selected' ); // `this`refers to the button! 🎉🎉🎉

} );
```


#### Scenario 2. Functions that use the `arguments` object.

Arrow functions do not bind the global `arguments` object.


```js
const logUser = () => {

console.log(arguments[0]); // Uncaught ReferenceError: arguments is not defined 😕

}

logUser( 'Kevin' );
```


But with a regular function, you have access to the global `arguments` object.


```js
function logUser() {

console.log(arguments[0]); // Kevin

console.log(arguments[1]); // Langley

}

logUser( 'Kevin', 'Langley' );
```


#### Scenario 3. Prototype Methods


```js
function User(firstName, lastName) {

this.name = `${firstName} ${lastName}`;

}

User.prototype.sayHello = () => {

return `Hello, ${this.name}`;

}

const me = new User( 'Kevin', 'Langley' );

me.sayHello(); // Hello,
```


The `this` value in the `sayHello` method references the global object and not the `User` object that it is trying to access.

Instead, write your prototype methods the old fashioned way.


```js
function User(firstName, lastName) {

this.name = `${firstName} ${lastName}`;

}

User.prototype.sayHello = function() {

return `Hello, ${this.name}`;

}

const me = new User( 'Kevin', 'Langley' );

me.sayHello(); // Hello, Kevin Langley
```


#### Scenario 4. Object methods


```js
const user = {

 name: 'Kevin Langley',

sayHello: () => `Hello, ${this.name}`;

}

user.sayHello(); // Hello,
```


The `this` value in the `sayHello` method references the global object and not the `User` object that it is trying to access.

Instead, write your prototype methods the old fashioned way.


```js
const user = {

 name: 'Kevin Langley',

sayHello() {

return `Hello, ${this.name}`;

}

}

user.sayHello(); // Hello, Kevin Langley
```
Project Ideas for a Hackathon (Going for the first time)
Tags: help
Published: 2018-04-02 03:07:04

---
title: Project Ideas for a Hackathon (Going for the first time)
published: true
description: I need project ideas for a hackathon that solves a problem and uses Web Dev and ML.
tags: #help
---

I am a CSE sophomore in India. There is a [hackathon being organized by AngelHack](https://angelhack-delhi-2018.eventbrite.com/) next month in which I want to participate. 

They are asking us to build something that solves a social or environmental problem and positively impacts our local community.

I will be going to the hackathon with 2 of my friends. I have experience in MERN stack (1 year), one guy knows ML (doesn't have a lot of experience) and the other has done Frontend work.

We are ready to learn new things (that's the goal) if our project requires us to. As it is our first ever hackathon so we are not sure what to build. 

It would be a great help if you guys can give us some suggestions. Thanks.
Human Development & Tech Inclusion: An exit strategy from Poverty in the 21st century
Tags: technology, africa, techinclusion, humandevelopment
Published: 2018-04-02 00:50:29

---
title: Human Development & Tech Inclusion: An exit strategy from Poverty in the 21st century
published: true
description: Technology as an exit strategy from Poverty in the 21st century
tags: Technology, Africa, Tech Inclusion, Human Development
---
<img src ="https://thepracticaldev.s3.amazonaws.com/i/zoxem31owfkfqlkxav8d.jpg" />


According to statistics, Africa’s population as a whole is very young, with 60% of the entire continent aged below 25, making it the youngest continent in the world. This gives us a reasonable edge over other continents. However, we still wallow in the den of poverty.

Most people often believe that 70% of this youth are technology inclined, howbeit, this is far fetched.

It’s true however that Africa is full of potential, most of which are yet to undergo a transformation process that can birth Results. it's therefore high time we annex this great potential in driving our economy and our wellbeing with a desirable result to measure the potency of our claims.

It’s no longer NEWS that the 21st century is an era for digital oriented people who are willing to transform their community via the application of technology. We’ve seen this happen with some 21st-century company such as Andela and Accounteer who are driving the world with digital innovation.

This is good news for us…but the question is, how can we bring in others to drive the nation with technology when most of our youths still have little or no knowledge on how technology can be used to transform their lives and that of their Nation.

The Answer to this boiling question is You and I waking up from our slumber and engaging the power of human development in the quest to help our Nation exit poverty, by empowering them with a 21st-century tool rather than focusing all attention on roads and other amenities.

It takes a digital-oriented man to maintain a 21st-century development. Thereby, the need to build a 21st-century man. This, however, is the need that led to the development of TechWheel along with some other vibrant youths who are willing to change the narrative, by investing their time and skills in developing youths.


It is, therefore, a call for all of us to support and initiate such movement in our own way, till we transform our youths into the change agents they truly are.

Kindly spread this news by sharing with other youths in your domain. Let's make Africa a great Continent!!!!.

_This article was first published on my <a href="https://medium.com/@adetuyitolu/human-development-tech-inclusion-an-exit-strategy-from-poverty-in-the-21st-century-892c1d83e24">medium page</a>_
How I Built & Launched 'Engineering Blogs' In 2 Days
Tags: webdev, coding, developers, softwareengineering
Published: 2018-04-01 19:49:15

---
title: How I Built & Launched 'Engineering Blogs' In 2 Days
published: true
description: Building and launching a product in 2 days
tags: webdev, coding, developers, software engineering
---
![]
(https://thepracticaldev.s3.amazonaws.com/i/natgriokr2ljl5oye3g0.png)


_On Monday_, I showed article "_Reducing Slack’s memory footprint_" in my twitter feed. It was written by Slack Engineering team to explain how they solved the problem of high memory consumption of Slack’s desktop app.

It had a great explanation about how to approach the problem, think about the better solution and build the desktop application. I explored the Slack Engineering blog and it has lots of wisdom shared by the engineering team at Slack. 

As a software engineer, I am always curious to learn about development strategies behind the great tech products. 

_On Tuesday_, I started to look for more engineering blogs from different startups and tech companies. In few hours, I found out that many of tech companies have a special section or blog related to engineering and development. On these blogs, they publish lots of new things including their approach to solve the problem, their experience with different tools and technologies, story about their engineers and more. 

Finally, I decided to build a place where anyone can find all the engineering blogs.  I started working on the idea on Tuesday. 

By the end of _Wednesday_, I have built the first prototype. 

["Engineering Blogs" - A Collection of engineering blogs from top tech companies in the world.](http://quickcode.co/engineer-blogs) 

_On Thursday_, I added new features including 'submit new company blog' and 'the total users' each of these tech company manages to give more sense about how to build and scale infrastructure that handles the traffic of millions of people (Some are in billions.)

I posted on few communities and the response was amazing. In 3 days, 3000 people visited the website. Many of them left very good feedback.  Today I am sharing it with Dev.to community. 

Please share your thoughts, feedback, and suggestions to make it better.
When is it a good idea to use stored procedures?
Tags: discuss
Published: 2018-04-01 18:11:29

---
title: When is it a good idea to use stored procedures?
published: true
description: 
tags: discuss
---

From my experience, it seems DBAs want to use stored procs and application developers want to avoid them.  Who's right?  

When is the right time for stored procs, and when should you keep your logic in the application code?
Why now?
Tags: personal
Published: 2018-10-17 18:50:02

---
title: Why now?
published: true
tags: #personal
canonical_url: https://distort-roving.blogspot.com/2018/04/why-now.html
---

 [![](https://i1.wp.com/www.gagasisterhood.com/wp-content/uploads/Sandwich-generation.jpg?w=540&ssl=1)](https://i1.wp.com/www.gagasisterhood.com/wp-content/uploads/Sandwich-generation.jpg?w=540&ssl=1) 
 Image from https://www.gagasisterhood.com/2015/5-tips-for-members-of-the-club-sandwich-generation/  
 

Being aware that everything that goes into a device attached to the internet is there forever (like has been brought to awareness again with the privacy breaches of 2018) the details here may be a bit skimpy.  
The term 'sandwich generation' seems to have fallen off my radar – this is the term for those folk who have elderly parents as well as children that still depend on them. This may likely be a more-common situation as life spans increase across the globe, so I'm sharing my perspective on being in this situation, and trying to make a better life for myself.  
  

_A cup of coffee to Mom,  
 gather dishes,  
 listen to a synopsis of his night._  
Back to the title of the post: Why now?   
I need a place to post my thoughts, experiences, and hopefully learn something from myself as this goes on.   
I am a student, learning to do front-end development – for those of you who may not be aware of this, that means I build web sites, and am working on making more complex ones and applications for mobiles.  
I am trying to also do my handicrafts, volunteer with an internet organization that has a goal I know is both attainable and profitable, and keep up on new and exciting changes in the larger world. Plus find time to do the self-care things, like brush my hair.  
My goals for the past few months have looked like I simply copied them from the month before: this is not making progress. So, breaking things down into smaller goals, and doing them make help me see progress.
Conrad Maker Faire 2017
Tags: makerfaire, physicalcomputing, energystorage, solarenergy
Published: 2018-04-01 17:12:51

---
title: Conrad Maker Faire 2017
published: true
description: 
tags: maker faire, physical computing, energy storage, solar energy
---

Oh, I just realized I hadn't posted this. I was supposed to post this in December 2017. 

Well,  in December me and a friend, Katrin, took part in the Conrad Maker Faire. 

![alt text](https://i0.wp.com/maker-faire.de/wp-content/uploads/2017/08/ConradMiniMakerFaire.png?resize=300%2C300&ssl=1
 "DIY solar charger")

We were doing a demonstration on how to charge a cell phone with a solar panel. We forgot that we needed the sun also for it to work out but we managed with a table lamp and a big solar panel. 

It ended up being more like how to transfer energy for dummies. Which was also very helpful for ourselves because we didn't know anything about the subject before diving into the it.

So basically how to store energy from a solar panel to a battery and then from the battery to a cell phone battery. We could also demonstrate that you can transfer energy directly from the solar panel to the telephone but that is not exactly a best practice.

These are some pictures from our stand, which was also very DIY. Improvisation queens. 


![alt text](https://thepracticaldev.s3.amazonaws.com/i/qsi6i0v0b7of56l0v73e.jpg "DIY solar charger")


![alt text](https://thepracticaldev.s3.amazonaws.com/i/t0iir35iyaik9t3p6ji0.jpg "Solar Charger 2")
What's the weirdest easter egg you've left in any project you coded?
Tags: discuss, fun, culture
Published: 2018-04-01 17:11:56

---
title: What's the weirdest easter egg you've left in any project you coded?
published: true
description: 
tags: discuss, fun, culture
cover_image: https://thepracticaldev.s3.amazonaws.com/i/lcqkvqgbjtoib10rqibb.jpg
---

Because from what I'm told, the Konami code is still cool.

Go on, tell the world.

Cover image from pippalou at [morguefile.com](https://morguefile.com/creative/pippalou)
taking requests for short tutorials
Tags: discuss
Published: 2018-04-01 17:09:50

---
title: taking requests for short tutorials
published: true
description: 
tags: discuss
---

I want to make some brief video tutorials or explanations. What would you like to learn about? Here are some topics I have thoughts on that might be appropriate to a brief video:

* how to read a technical book
* how to evaluate technical information you find online, or, why the most uploaded answer on stack overflow may not be the answer you need 
*  Think VS code is great? There’s a Javascript IDE that’s at least as powerful and supports a killer feature VS code doesn’t have 
*  how to train your cat not to walk on your keyboard 
*  keeping a coding notebook 

 Suggest other ideas in the comments…
Golang Patterns - Part 1
Tags: programming, beginners, go, showdev
Published: 2018-04-01 16:59:11

---
title: Golang Patterns - Part 1
published: true
description: golang patterns
tags: programming,beginners,go,showdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/b9yixufwcejmrjsj91y6.jpg

---
Hi everyone! 
Today's objective is to describe and document a bunch of golang patterns.

As you know from my previous posts ([go concurrency](https://dev.to/napicellatwit/go-for-java-developers-or-is-the-java-concurrency-that-bad-6ff) and [go lambdas](https://dev.to/napicellatwit/go-for-java-developers-lambda-functions-to-the-rescue-655)), I have recently entered the Go-land and found out quite soon that common idioms I knew from my previous experience did not quite apply to golang.

Well, I found out that there are some patters that are so common that in my humble opinion should be presented  as part of any beginner guide about golang.
All the code in the examples is on [github](https://github.com/napicella/go-patterns).
 

## Group constants
The title said it all, we want to group common constants in the same namespace.
{% gist https://gist.github.com/napicella/b1ba05048a0b160dcdc6140edae28b68 %}


## Chain
A chain of suppliers that returns as soon as one of the suppliers returns a non-zero result or an error. 
The code shows an example in which we need to load a configuration value from one of the possible sources: env variable, config file or a database.
We want to stop searching for the config value as soon as a non-zero result is returned.
{% gist https://gist.github.com/napicella/d5ba583f0da4b9f5e0fa1f479be6cb25 %}
Code for the chain [here](https://github.com/napicella/Go-patterns/tree/master/src/chain).


## Options
Options shows a flexible way to construct an object.
The major benefit is being able to add more parameters in the future to the object constructor without breaking the clients.
In other languages, you would probably use an overloaded constructor or fall back to the builder pattern.
{% gist https://gist.github.com/napicella/a5b8db6d0fbd11acf9e74937cd89055f %}
Code for the option [here](https://github.com/napicella/Go-patterns/tree/master/src/options).

## Maybe
Maybe is a container which may or may not contain a non-null value.
{% gist https://gist.github.com/napicella/5082912ca89847629bf33f8199a1dfc9 %}

## Function type
Functions are first class citizen in Golang. They can be used as a type whenever we want to easily implement a Strategy pattern or similar.
This pattern is heavily used in the golang [http package](https://golang.org/pkg/net/http/#Handler).
{% gist https://gist.github.com/napicella/e2c2edca128cae1cf94faa8a7b8208ea %}

## Conclusions
Thanks for reading!

Let me know if you found it useful and if there is a key pattern that should really be part of this list.
3 friendly files you probably don't have in your project.
Tags: fun, culture, devtips
Published: 2018-04-01 15:30:09

---
title: 3 friendly files you probably don't have in your project.
published: true
description: 
tags: fun, culture, devtips
cover_image: https://thepracticaldev.s3.amazonaws.com/i/y4xqmtwk1sdawzxo9tqr.jpg
---

So you have a robots.txt and a sitemap.xml and a LICENSE and a README and so on. But do you have anything for us humans?


## humans.txt

If you couldn't guess, humans.txt is named in response to the familiar robots.txt file, and like its sibling it lives in the root of your website. As such, it doesn't tend to exist in non-web projects.

![humans.txt logo](https://thepracticaldev.s3.amazonaws.com/i/6thdsl0qopbdfg0t71yk.gif)

What's it for? It's for you. You can put anything you like in it - *that's* what it's for:

* Credit yourself and your team.
* Give your favourite text editor a shout-out.
* Dedicate the site to a fallen companion.

Remember not to slag off your employer, and don't include this file at all without the client's permission.

Here's one of mine: [moopet.net/humans.txt](https://moopet.net/humans.txt)

[Read more about humans.txt](http://humanstxt.org)


## ORIGINSTORY.md

Once upon a time, someone said the biggest question they had when checking out a new project was how it got its name. You know, like everyone always asks about [why the O'Reilly books have animals on their covers](https://www.oreilly.com/ideas/a-short-history-of-the-oreilly-animals).

{% twitter 748326674572390400 %}

Here's one of mine: [moopet/burdock/[...]/ORIGINSTORY.md](https://github.com/moopet/burdock/blob/master/ORIGINSTORY.md)

To be honest, ORIGINSTORY.md doesn't have a lot of representation yet - but you can help to change that. Everyone likes a little trivia, right?

## foaf

Friend-Of-A-Friend still exists, but it never reached the kind of critical mass you'd need to make it really seem worthwhile. It's another layer of interconnectedness between articles and authors and subjects and you-name-its; it's much more complex than the other static files. As another hypertext-specific file, it's not relevant to non-web projects.

![FOAF](https://thepracticaldev.s3.amazonaws.com/i/z5d4kgb1crqjvd3q8ai5.png)

[Read more about foaf](http://www.foaf-project.org/)

Cover photo by doctor_bob at [morguefile.com](https://morguefile.com/creative/doctor_bob)
How to generate Flutter app icons for iOS and Android
Tags: flutter
Published: 2018-04-01 15:01:39

---
title: How to generate Flutter app icons for iOS and Android
published: true
description: 
tags: flutter
---


## TL;DR
Use `flutter_launcher_icons` that Command line tool.

## Environment
- Flutter 0.1.5
- Dart 2.0.0-dev.28.0
- flutter_launcher_icons 0.2.0

## How to create

### 1. Add `flutter_launcher_icons` Plugin

Add `flutter_launcher_icons` to `pubspec.yaml`

```yaml:pubspec.yaml
dev_dependencies: 
  flutter_test:
    sdk: flutter
    
  flutter_launcher_icons: "^0.2.0"
  
flutter_icons:
  image_path: "icon/icon.png" 
  android: true
  ios: true
```

### 2. Prepare app icon

Prepare an app icon for the specified path.
e.g. `icon/icon.png`

### 3. Create app icons

Execute this on terminal.

```
$ flutter pub get
$ flutter pub pub run flutter_launcher_icons:main
```

## File list

These are file list after command execution.

```
+1 -1 M android/app/src/main/AndroidManifest.xml
+0 -0 M android/app/src/main/res/mipmap-hdpi/ic_launcher.png
+0 -0 M android/app/src/main/res/mipmap-mdpi/ic_launcher.png
+0 -0 M android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
+0 -0 M android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
+0 -0 M android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
+0 -0 A icon/ic_launcher.png
+71 -0 A ios/Podfile
+1 -1 M ios/Runner.xcodeproj/project.pbxproj
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@1x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png
+0 -0 A ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png
+56 -0 M pubspec.lock
+5 -0 M pubspec.yaml
```

## Links
flutter_launcher_icons | Dart Package
https://pub.dartlang.org/packages/flutter_launcher_icons

How to change the application launcher icon on Flutter? - Stack Overflow
https://stackoverflow.com/questions/43928702/how-to-change-the-application-launcher-icon-on-flutter
Give me a quick 101 in the Graphcool ecosystem (like Prisma)
Tags: baas, graphql, prisma, discuss
Published: 2018-04-01 14:46:11

---
title: Give me a quick 101 in the Graphcool ecosystem (like Prisma)
published: true
description: 
tags: baas, graphql, prisma, discuss
---

I found [this](https://www.graph.cool/forum/t/graphcool-framework-and-prisma/2237) forum post which explaining the differences between **Prisma** and **Graphcool framework**.

But I still don't know which is the more feature packed from these and which has the most love in active development?

I want to self-hosting everything, including the GraphQL BAAS server which connecting to my self hosted database (Dockerised approach) and I want to query the data in a **React** based single page application. Authentication is also important (with given user roles) and I don't want any third-party auth provider.

If I want to use GraphQL based BAAS, looks like I don't have any other alternative to choose right now, only Graphcool (which is not a problem at all, I just can't figure out which is the ultimate environment from these).

Or self-hosted authentication is not possible, the only alternative is **Apache Usergrid**?


If I want a hosted BAAS, I would go with **Firebase**, because of the simple setup with **React** and also handling auth.