teleren/devto huggingface dataset:
Null Object Design Pattern
Published: 2021-09-06 00:02:45

Nulls are bad!
I call it my billion-dollar mistake…At that time, I was designing the first comprehensive type system for references in an object-oriented language. My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.
– Tony Hoare, inventor of ALGOL W. 


But, why null is so evil?



1.  NULL indicates a distinct state, and any type can have this state.
Rather than defining a new type for each state, an entity needs to express.
We confuse our abstraction by this rather odd generalized value.


2. It's hard to reason about NULL when debugging.

To find the NULL-related bugs. You will have to determine which state the program was in and what leads to this state. 


3. Once NULL references are used as valid states for parameters as well as return values. We have to duplicate NULL reference checks in various places.


Taming the NULL
Enters, the Null Object Pattern

The root cause of the troubles null introduces. Is it uses a generalized value to represent a distinct state?

Why not use NullableObject? It's more work to create NullObject class for each interface with which you want to represent a special state.



But the specialization is isolated to each special state, rather than the scattered if statements.
Treating Primitive Obsession with Value Objects
Published: 2021-09-05 23:59:40

Primitive Obsession
Primitive values are your friends. We all start our programming journey by learning about the fundamentals types. Int, Double, String they are friendly familiar faces.
They are the default tyes we reach for whenever we are writing code and for a good reason they are convenient and we are very familiar with them.

But this obsession with the primitive types and the tendency to use to represent almost everything especially when presenting 'simple' abstractions like a measuring unit, postal code, or an email field.

What is wrong with that you might ask?

There are few issues with making primitives represent domain objects.



Wrong assumption
Take temperature as an example you might be inclined to present a temperature field as a double.
but this means you assume all double values are valid temperature values! which is wrong.

You assume that double representation is similar to temperature representation. which is wrong usually you want to limit the decimal points, add a prefix and maybe add a method to convert between Celsius and Fahrenheit.

Breaking encapsulation
When you use primitive values you will break encapsulation. how many times you will need to verify, transform or represent a type in your application?
Thinking about temperature, we might add a validation upon storing the value and again when updating it and then we will need to duplicate our logic. Now, think about all the places where you will need to display temperature you will duplicate this code!

Value Objects to the rescue 
Value objects are just classes but with a couple of important features.

1. Value Object can answer equality check
if we wanted to represent a currency as a <amount, currency> and later wanted to check if two points are equal. unless you are careful with your code you may get the wrong answer.
Therefore, value objects must implement a correct equality check method

2. Value Object should be immutable
What we gain from delegating the equality check to the object. can lead to aliasing bugs

Aliasing as defined by Martin Fowler is "Aliasing occurs when the same memory location is accessed through more than one reference. Often this is a good thing, but frequently it occurs in an unexpected way, which leads to confusing bugs."

This can happen when dealing with value objects as we blur the lines between values and reference.


As we have seen implementing value objects requires some extra work to make your development faster you may consider using a library that helps you with that. If you are using C# I would recommend ValueOf & for Java people, you can use the @Value annotation from Lombok

Further reading on implementing Value Objects
How to setup Cypress on Github Actions
Tags: github, javascript, testing, cypress
Published: 2021-09-05 23:48:59



In this text, I try to show you how to set up Cypress on Github Actions, but first I have one disclaimer for you.

> _I assume you know the basics about Github, that is  **commits**, **pull requests**, and **branches** need to be familiar concepts._

Github Actions it's an important tool for automating and run software workflows day by day. In this article, I show to you when every time someone creates a pull request for your project repository, you can automatically run a command that executes a software testing script.

But first, I need you to have any Github repository with any Cypress test.

So let's start the fun...

1 . In your Github repository create a new file in directory _.github/workflows_ called _github-actions-init.yml_

2 . In this file we must add content with steps of our workflow:

```
name: GitHub Actions Demo
on: [pull_request]
jobs:
 cypress-run:
    runs-on: ubuntu-latest
    steps: 
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install node
        uses: actions/setup-node@v2
        with:
            node:version: '14'
      - name: Install dependencies
        run: npm install       
      - name: Cypress run
        uses: cypress-io/github-action@v2
```

In this YAML file, we have some terms that need explanation, so let's go undestand line by line: 

* `name: GitHub Actions Demo`: It's basically the name of our workflow.
* `on: [pull_request]`: Shows for github actions when running the workflow 
* `jobs`: Group all jobs in file
* `cypress-run`: It's job's name 
* `runs-on: ubuntu-latest`: Indicates to a workflow should run in a Ubuntu Linux executor.   
* `steps`: All steps to run in workflow
* `Checkout`: It's a step's name
* `uses: actions/checkout@v2`: In this line basically our workflow checks our repository allowing you to run actions against own code
* `name: Install node`: It's a step's name
* `uses: actions/setup-node@v2`: This step is used for install a specified node version
* `node-version`: Indicate a node version
* `name: Install dependencies`: It's a step's name
* `run: npm install`: Run the command install in node, to install all dependencies in project
* `name: Cypress run`: It's a step's name
* `uses: cypress-io/github-action@v2`: Run a Cypress command to execute all tests cases in project.

3 . After adding this file to the repository, it's time to create a pull request and see the magic happen.

It's all for today, but I hope this text helps you, and if you have any ask, text me in the comments. I see you soon

##### Project Repository: <https://github.com/rodrigosta/e2e-toDoList>

##### References: 
* <https://docs.github.com/en/actions/learn-github-actions/introduction-to-github-actions>
* <https://docs.cypress.io/guides/continuous-integration/github-actions>
Intro to Blockchain: ERC-20 vs ERC-721 Tokens
Published: 2021-09-05 23:47:24

Wow those are some fancy looking words! I promise theyre easy, they just look intimidating!


ERC-20 - tokens are Fungible, meaning that they are able to be replaced by one another. Compared to each other, they are not uniques. Say a penny for example. Pennies are unique and hold their own value in the American Currency system, but amongst other pennies, pennies are all the same and worth the same amount.

ERC-721 - tokens are Non-Fungible (NFT's). Meaning that they aren't able to be replaced by one another. Lets go back to the pennies. Since ERC-721 tokens are non-fungible, one token would differ in price or value than another token. Lets pretend these ERC-721 tokens were pieces of art, it's a perfect analogy because no one piece of art is the same as another. Therefore each token having a different price.
Why JavaScript?
Tags: javascript, beginners, codenewbie
Published: 2021-09-05 23:21:38

As a web developer, we have our favorite programming languages that we use for our web applications.  Mine is JavaScript! In this post I'm going to share some of the reasons why.

1. JavaScript is the most popular language and is the foundation for todays web applications. 

2. JavaScript initially was used as a front-end interpreted language. When Node.js (a JavaScript runtime environment) emerged, JavaScript could be used for front-end AND back-end programming. Hence making it Full-Stack!

3. JavaScript brings interactivity with users with features like forms, browser and HTML handling.

4. JavaScript is faster due to being able to re-use code. Less lines of code need to be written.  And to add to that, it offers a higher level of abstraction, meaning the developer can achieve the same functionality with less lines of code.

5. JavaScript has turned web browsers into single page applications (SAP).

6. JavaScript is easy to learn and easy to read.

These are just a handful of reasons to use JavaScript.  I'm sure if you look into it further you will see many more reasons to give JavaScript a try!

Happy Coding!
11 Youtube Python Courses
Tags: python, codenewbie, beginners, computerscience
Published: 2021-09-05 23:06:53

## 11 Youtube Python Courses

+ [Python Crash Course](https://www.youtube.com/watch?v=f79MRyMsjrQ)(2h)(Programming with Mosh)
+ [Python Tutorial - Python for Beginners](https://www.youtube.com/watch?v=_uQrJ0TkZlc) (6h 15min)(programming with mosh)
+ [Python for everybody - Full University Python Course](https://www.youtube.com/watch?v=8DvywoWv6fI)(13h 30min)(freeCodeCamp)
+ [Python for Beginners - Learn Python in 1 Hour](https://www.youtube.com/watch?v=kqtD5dpn9C8)(1h)(Programming with Mosh)
+ [Learn Python - Full course for beginners](https://www.youtube.com/watch?v=rfscVS0vtbw) (4h 30min)(freeCodeCamp)
+ [Python Tutorial For Beginners](https://www.youtube.com/watch?v=t8pPdKYpowI)(5h 30min)(TechWorld With Nana)
+ [Python As Fast as Possible - Learn Python in ~75 Minutes](https://www.youtube.com/watch?v=VchuKL44s6E)(75min)(Tech With Tim)
+ [Python full course](https://www.youtube.com/watch?v=XKHEtdqhLK8) (12h) (bro code)
+ [Python full Course](https://www.youtube.com/watch?v=WGJJIrtnfpk)(12h)(Edureka)
+ [Intermediate Python Programming Course](https://www.youtube.com/watch?v=HGOBQPFzWKo)(6h)(freeCodeCamp)
+ [Python Advanced Course](https://www.youtube.com/watch?v=tdn9_MZ0lN4)(8h 30min)(Externe Code)

Have an amazing day
My open source journey.
Tags: opensource, beginners
Published: 2021-09-05 23:05:23

I started out my open source journey when I got a whatsapp link from [@saintmalik](saintmalik.me) for the open source community in Ado Ekiti.

At first I did not know what open source was about but with the help of several engagement and seminar from the community I got to know about what Open Source is all about.
We had an online session about benefits of contributing to Open Source, using Git as a version control system and how Github is used by developers to collaborate amongst themselves.


Open Source projects are projects whose implementation are readily and freely available for use and modification by anyone in the world. The source code of Open Source projects can be changed and contributed to by anyone willing to contribute to the project.


The Open Source challenge started on the 16th of August and it was fun all through. I was made to learn more about contributing to open source projects. This challenge gave me the opportunity to join an organization (Zero To Mastery) on Github after my first PR to their repo.


I learnt about forking repo, cloning repo, creating a new branch for a repo, pulling from upstream, pushing to the branch, merging and making pull requests.


Open source has a lot of benefit and I encourage you guys to participate in contributing to Open Source projects.

Thank you.
Intro to JavaScript Variables
Published: 2021-09-05 22:22:36

**1. Using reserved keywords**
In JavaScript, we use one of the three reserved keywords - `var`, `let`, `const` - to declare and assign a variable.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6eo85qgztu4l0shwfynr.JPG)

**Note:**
(1). If the const value is an array or an object, we can modify the properties or the elements.
(2). When to use:
DO NOT use `var`
Use `let` for variables where the value may change
Use `const` whenever possible 

**2. Without reserved keywords**
If we assign a variable without using any of the keywords, the variable will be a global variable. We should avoid defining global variables because they can be accessed and changed EVERYWHERE.
Restaurant Website
Tags: restaurant, mongoose, express, node
Published: 2021-09-05 22:17:40

Hello Everyone, please refer to me as Khal...Khal Mykey lol. I recently started working at a restaurant, after a few weeks I told the Owner I'm a Web developer side note I really wanted to introduce myself as a Software Engineer. So she decided to hire me to build a restaurant website for her frontend and backend. This was my first client, I was excited so excited that imposter syndrome hit me. The tools I used for the frontend were mainly bootstrap and a few lines of CSS here and there and a library for a few frameworks. I am currently working on the backend now and again my archenemy imposter syndrome is coming for me again. The restaurant owner wants to be able to take orders online, My biggest fear is security and poor design causing a slow backend. The tools I'm using for the backend are Node.js, Express, Mongoose, and a few other libraries or frameworks. As of right now, I'm working on adding all the menu items and their prices to the database. And in the process of using async-await, I heard it's good to use lol.
ShareASale  Affiliate Marketing Platform Review
Published: 2021-09-05 22:11:11

Who We Are

Of #1 importance to ShareASale, is the set of values that we represent. We believe in fair business practices, socially responsible individuals, and a general concept of “doing the right thing.” It is our goal to hire like-minded professionals and grow a positive, socially altruistic workplace. Additionally, we operate with a customer-first mentality and are always prepared to go the extra mile for our clients.

The Awin Group Story
In 2017, Awin acquired one of North America’s largest platforms, ShareASale. ShareASale has been a pure-play affiliate marketing network, successfully growing its business by nurturing relationships, building cutting-edge technology and guiding clients to success in affiliate marketing since 2000. As a leading network in the US, ShareASale is known as a fair and ethical business partner with the goal of supporting performance-based partnerships.

With over 20 years of affiliate marketing experience for both Awin and ShareASale, our trusted platforms offer a global community of people, technology, and business intelligence insights. No matter what type of partner, level of service, or tools your business needs, the Awin Group provides solutions to drive sustainable growth.

Part of the Axel Springer and United Internet Groups, with Commission Factory, Awin and ShareASale are powered by 15 offices worldwide, over 1,000 employees, 225,000+ contributing publishers, and 16,550+ advertisers. Connecting businesses with customers around the world across the retail, telecommunications, travel, and finance verticals, the Awin Group generated $14 billion in revenue for its advertisers and $1 billion for its publishers globally in the last financial year.

Together, we are affiliate marketing.


Let shareasale.com find sales leads for you. Only pay when it works!

Find a sponsor for your website. Get paid for your great content. shareasale.com.
BEM Methodology in CSS
Tags: css, html, codenewbie, programming
Published: 2021-09-05 21:21:16

Hola Friends, In this article we'll learn about BEM Methodology.

## BEM

- BEM divides the layout into 3 main parts: - **Block** - **Element** - **Modifier**

- It's a CSS naming convention for writing cleaner and more readable CSS classes. BEM also aims to write independent CSS blocks to reuse them later in your project.

- BEM is ideal for teams of developers on larger projects where designers and developers consistently name components for easier communication between the team members.

- BEM syntax usually looks like this: 

```css
.block__element--modifier

```

Let's explore this in more detail:

### Block

Encapsulates a standalone entity that is meaningful on its own. It is usually a bigger component of a webpage. for example header, card, div, etc.

```html
<div class= "card">
. . .
</div>
```

### Element

It is a part of a block and has no standalone meaning. Any element is semantically tied to its block. It is represented using `[block-name](double underscore)[element-name]` like `card__header`.

```html
<div class= "card">
    <div class= "card__header">
         . . .
    </div>

    <div class= "card__body">
         . . . 
    </div>
</div> 
```

In the above example, `card__header` & `card__body` represents the **Elements** which resides inside the **Block** `card`.

### Modifiers

It represents the flags on blocks or elements. Use them to change appearance, behavior, or state.

A modifier is an extension that specifies some change in the style of the block or the element it is applied to.

A modifier is indicated by using `double dashes` after the class name which allows you to overwrite the styles for a specific type of block, or an element.

```html
<button class="btn btn--active"> Click Me </button>
<button class="btn btn--disabled"> Clicked </button>
```

In the above code snippet, `btn--active` & `btn--disabled` represents the **Modifiers**.

Corresponding CSS code would be:

```css
.card { ... }
.card__header { ... }
.card__body { ... }

.btn { ... }
.btn--active { ... }
.btn--disabled { ... }
```

In case you are using some CSS preprocessor, you can modify your CSS file in the following way:

```CSS

.card {
    &__header { . . . }
    &__body { . . . }
}

.btn {
    &--active { . . . }
    &--disabled { . . . }
}
``` 

BEM makes our CSS easier to read, helps to write clean code, and also saves a lot of time to decide the class name.

## References

- http://getbem.com/naming/

- https://9elements.com/bem-cheat-sheet/

## Wrap Up!!

Thank you for your time!! Let's connect to learn and grow together.

[LinkedIn](https://www.linkedin.com/in/anuradha-aggarwal-4a2751107/) [Twitter](https://twitter.com/Anuradh06359394)

[![Buy-me-a-coffee](https://cdn.buymeacoffee.com/buttons/v2/default-blue.png)](https://www.buymeacoffee.com/anuradha2612)
Docker Environment Setup
Tags: docker, devops, linux, cloudskills
Published: 2021-09-05 21:12:59

### * Create DigitalOcean Account

You can use my referral you will get $100 free usage for 3 months.
By clicking below.

[![DigitalOcean Referral Badge](https://web-platforms.sfo2.cdn.digitaloceanspaces.com/WWW/Badge%201.svg)](https://www.digitalocean.com/?refcode=625e4379d2d4&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=badge)

### * Create a Droplet

![Create Droplet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fiim487xmtjxnhgbtq73.png)

### * Use the following Configuration for Droplet.
*You have to open image and zoom*
![Droplet Configuration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wy1lp0csxsg90k5sf80.png)

#### In case of ssh key generation

Click on **New SSH Key** as shown in above image.

![DigitOcean SSH Key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qy1sas185ulhfm767xh.png)

And Run these commands in Local System.

```shell
$ ssh-keygen
$ cat /c/Users/<Your User>/.ssh/docker_rsa
```
![Local SSH Key Generation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/75yfjzk39065tssmcctu.png)

### * Droplet after Creating

In you Project, you will be able to see one droplet.
Where you will get the public IP of that droplet and we will access that using that.

![dropletIP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsb7ey85lgz5ikk873vb.png)

### * Login and update Droplet

```shell
$ ssh -i docker_rsa root@165.22.212.229
$ sudo apt-get update
```

![login and update](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j366vs7yqoocnno28zgs.png)

After updating kernal, installing docker to the droplet.
Below is specific to Ubuntu

```shell
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
Then we need to install Docker.

```shell
$ echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 

$ sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io
```

### Verify Docker

To Verify Docker is running.

```shell
$ systemctl status docker
```
![Docker Verification](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ukim3x74bblq1jyrlmxu.png)

Hurray!! you are inside your first Droplet....
API
Published: 2021-09-05 20:47:28

Applications can access data and interact with external software components, operating systems, or microservices through APIs (Application Programming Interfaces).

To put it simply, an API sends a user's response to a system and receives the system's response back. An API notifies the site that you have added a product to your cart; the website adds the product to your cart, and your cart is updated.
With regards to API, you could encounter the phrase "microservices." Nevertheless, they're not the same thing! In a web application, microservices are used to separate functions. API, on the other hand, is the structure through which web application developers communicate with a web site. As a matter of fact, microservices can communicate via APIs.
## What are APIs and how do they work?
An Application programming interface is made up of two parts that are interconnected. Firstly, there is a specification that explains how information is shared between programmes, in the form of a request for processing and a return of the necessary data. An interface developed to that standard and made available for usage is the second. Calling and publishing are two terms that refer to software that wishes to use the features and capabilities of an API. In other words, APIs allow users and other programmes to access data that has been requested by them.For example, preset roles govern which services may access certain actions or data, and access to a given service or feature is authenticated against predefined roles. APIs also offer a system audit trail that shows who or what accessed the system when.

A lot of the time, the applications that call APIs have been developed in a specific programming language. However, web APIs may also be accessible using HTML or application generation tools. Representative state transfer (REST) and Simple Object Access Protocol (SOAP) are the two most prevalent API architectures, and they both offer standard communication protocol specifications for XML-based message exchange. However, REST APIs are easier to scale and redeploy as well as to build and connect with websites and services than SOAP APIs, which need less low-level infrastructure-related code. Particularly for web-based interactions, REST APIs are the current industry standard.