teleren/devto huggingface dataset:
Back to Basics: SOLID Principles (Interface Segregation)
Tags: python, beginners
Published: 2021-08-09 12:25:22

Writing clean code is one of the core precepts of software development. 

There are various software design approaches to ensure an understandable, flexible, and maintainable code base. 

In this post, we will be try understand the fourth SOLID principle and how it can help us become better developers.

----------------------------------------------

## Interface Segregation Principle

*A client should not be forced to implement an interface that it does not use.*

Let's take an example to understand what this means:

```python

class ShapeInterface:
	def area(self):
		pass

class Square(ShapeInterface):
	def area(self):
		"""area of square = a^2"""
		pass

class Rectangle(ShapeInterface):
	def area(self):
		"""area of rectangle = l*b"""
		pass


```

The above example is good as it follows all our object-oriented programming principles. Now let's add a volume method for shapes like Sphere or a Cylinder.

```python

class ShapeInterface:
	def area(self):
		pass

	def volume(self):
		pass

class Square(ShapeInterface):
	def area(self):
		"""area of square = a^2"""
		pass

	def volume(self):
		raise NotImplemented

class Rectangle(ShapeInterface):
	def area(self):
		"""area of rectangle = l*b"""
		pass
	
	def volume(self):
		raise NotImplemented

class Sphere(ShapeInterface):
    def area(self):
		"""area of sphere = 4πr^2"""
		pass
	
	def volume(self):
		"""volume of sphere = (4/3)*πr^3"""
		pass


```

Since 2D shapes cannot have any volume, the Square and Rectangle class are forced to implement methods of an interface they don't have any use of.

**Solution?**

ISP says that interfaces should perform only one job (just like the SRP principle) any extra grouping of behavior should be abstracted away to another interface.

To conform to ISP we will segregate the volume method to another interface which will be used by 3D shapes.

```python

class TwoDShapeInterface:
	def area(self):
		pass

class ThreeDShapeInterface(TwoDShapeInterface):
    def volume(self):
		pass

class Square(TwoDShapeInterface):
	def area(self):
		"""area of square = a^2"""
		pass

class Rectangle(TwoDShapeInterface):
	def area(self):
		"""area of rectangle = l*b"""
		pass
	
class Sphere(ThreeDShapeInterface):
    def area(self):
		"""area of sphere = 4πr^2"""
		pass
	
	def volume(self):
		"""volume of sphere = (4/3)*πr^3"""
		pass


```

Now we have 2 Interfaces; TwoDShapeInterface and ThreeDShapeInterface. TwoDShapeInterface as the name suggests contains methods that are only required for 2D shapes like square, rectangle, etc. while ThreeDShapeInterface extends TwoDShapeInterface and has 3D shapes related methods like volume calculation for shapes like Sphere.

This post is Part 4 of the series, Back to Basics, each covering one SOLID principle.
Hoisting with closures example
Tags: javascript, closures, snippets
Published: 2021-08-09 12:02:20

Try guessing what is the output of the following snippet:

```javascript
function one() {
  function two() {
    console.log(`closure var1 - ${var1}`);
  }

  three();
  var var1 = 'var1';   
}

one();
```

<hr>
It yields `hoisting var1 - undefined`, because of [hoisting](https://developer.mozilla.org/en-US/docs/Glossary/Hoisting) of `var1` variable (it is allocated in memory with value `undefined`), but it is not initialised with the value `var1` by the time the [closure](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) is executed.


But, if we use `setTimeout()`, by the time the callback closure function is executed `var1` will have been initialised and its value is printed:

```javascript
function one() {
 setTimeout(function() {
  console.log(`closure var1 - ${var1}`);
 }, 0);
  var var1 = 'var1';
}

one();

//output
closure var1 - var1
```

<hr>
> Shared with :heart: from [Codever](https://www.codever.dev/snippets/6110fefa3e01006b23fb2f2d/details). &nbsp; :point_right:  &nbsp; use the [**copy to mine**](https://www.codever.dev/snippets/6110fefa3e01006b23fb2f2d/details) functionality to add it to your personal snippets collection.
What are method references in Java?
Tags: java, programming, beginners, functional
Published: 2021-08-09 12:00:31

Hi guys, today the post will be short, I’ll write about method references. I know that are simples to understand, but some things were stranger when I first saw them, that is why I’ll write about them.

Methods references are introduced with the Java 8, allowing done references when methods are instanced in lambda expressions, this strategy sought ways to create a non-verbose method.

Let’s go see an example.

```Java
List<Person> list = Arrays.asList(new Person("Riot", 112), new Person("Rext", 30));

// Without method reference
list.forEach(e -> System.out.println(e));

// With lambda reference
list.forEach(System.out::println);

// Without method reference
list.stream().map(e -> e.getNumber()).forEach(e -> System.out.println(e));

// With lambda reference
list.stream().map(Person::getNumber).forEach(System.out::println);
```

When using functions lambda often faces moments that need to send the only method, for example, *filter()*, *map()* like the example above, but we must remember that when we use methods reference, the parameters are passed directly to the method, don't possible do anything with this parameter.

The **::** is a delimiter, that we say we using methods references to code, that way when to run occurs is translated to a functional interface, that is why the code will compile, and this will compile without cost to the application. We must use this form of work, but without forgetting of legibility of code.
Today's Daily Dose of Programming Humor
Tags: jokes, dailydeveloperjokes
Published: 2021-08-09 12:00:11

---
title: "Today's Daily Dose of Programming Humor"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e125933e8609.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ What did the fruit basket say to the developer?

___A:___ I hope you're ready for some pear programming!
 -->
📊 Workforce and App Privacy Have Changed, So Should You
Tags: security, privacy
Published: 2021-08-09 11:44:10

### 🌎 Moving fast can create imbalances. Don’t sacrifice your worker privacy for your consumer data privacy in your app; we’ll help you do both well and fast.

### <br>

If you sped through your digital road map during the pandemic and are looking to fill security and privacy gaps right now, go back and check out my earlier posts:

* [Accelerated Your Road Map? Go Fix Workforce and App Security](https://auth0.com/blog/accelerated-your-road-map-go-fix-workforce-and-app-security)
* [Workforce and App Privacy Have Changed, So Should You](https://auth0.com/blog/workforce-and-app-privacy-have-changed-so-should-you)

<br>
This post is about making the shift from reaction to preparation so that you are ready for the next moment that requires speed – and set up to scale.

## Find Your Balance

In all of these posts, we mention speed and imply pressure. There is always going to be a business reason to get an app to market as quickly as possible. You will discover vulnerabilities that require your immediate attention. And regulations will set deadlines for you. 

So there is always going to be more you could do to improve security for your customers, your business, and the rest of the internet. Even for veteran security professionals, the pandemic was a reminder that we still need to pick and choose priorities. If you have an internal security team, lean into their expertise. Give them the time and space to guide you on priorities. Listen to their assessments of risk and let them set a pace that works for your business.

Longer-term security and privacy improvements can have big payoffs. Like the previous posts, these things require action. You’re also going to need to support your existing security team or create one. By support, I mean backing conversations about risks with budget for tools, external vendors, and hiring internal talent.

If you don’t currently have security or privacy teams, we’ll cover a bit of advice on what to look for as well.

## Consumers Expect and Deserve Strong Security and Privacy

Let’s also set some context.

There was a time when businesses leaned heavily into just shipping the product. Speed often won over security or privacy.

> Consumers are telling us that time is over.

In a [recent global survey](https://www.mckinsey.com/business-functions/risk/our-insights/the-consumer-data-opportunity-and-the-privacy-imperative), McKinsey found that 87% of consumer respondents said security practice concerns would mean they wouldn’t do business with a company, and 71% would stop doing business if it gave away sensitive data without their permission. 

> The more secure and private app is now the one that keeps and attracts customers. 

## Security: Longer-Term Planning

If you’re looking to make a dramatic improvement in your cybersecurity, these best practices will help get you there.

[Read more...](https://auth0.com/blog/time-to-prepare-be-ready-to-scale-your-workforce-and-app/?utm_source=content_synd&utm_medium=sc&utm_campaign=growth)
Week Update
Published: 2021-08-09 11:42:07

# Indexer
It is a project which basically aims to provide the query processing all the transaaction details and all the holding of a account with just entering the account associated.

___
### Benefits
User will be able to track all the holdings across all token.
 ___

### Update (2 Aug - 7 Aug)
Started exploring the ethplorer api
Setting up the environment 
Getting familiar with js and ts
Made the doc about the [project](https://docs.google.com/document/d/1Nn6D-ufe69nDQObpSJQOMaAhYeAo9nmN9Ga5zRB85NI/edit)
Started with Alchemy docs
7 Rules That Every Designer Must know
Tags: design
Published: 2021-08-09 11:41:58

*7 RULES THAT EVERY DESIGNER MUST KNOW*

1. CONSISTENCY AND STANDARD:
When working on a project, you must use the same type of icons and fonts throughout a particular project. Make use of standard icons and generally accepted contents. 
If you are creating your own icons, then you should make sure they are of standard and maintain the use of it throughout the project.
For instance if you choose to use font 16px for your headings and 12px for your paragraphs, you have to maintain those number through out that particular project.

2. COLOR SCHEME
Your choice of color combination in a design should be based on  logical combination of colors from the color wheel. An in depth knowledge of monochromatic or complementary colors should be known. For example the color purple and yellow are complementary to each other on the color wheel; thus they are perfect to be used together in a design. 

3. SPACE MANAGEMENT:
Spaces invokes imagination, when we see space in design, it allows us to imagine and roam free. It creates readability to the elements when gaps are created to ensure that the users can find and digest information presented more easily.
Adequate use of the spaces on your design page should be utilized to avoid congestion of contents on a particular page. 

4. VISUAL HIERARCHY:
This is a design techniques whereby designers makes a particular section on a page to be viewed first. 
There are different characteristics used to achieve hierarchy in design: Size – Users notice larger elements more easily. 
Color – Bright colors typically attract more attention than muted ones.

5. READABILITY:
Ability to manipulate contrast of the background and the text color to ensure that the texts are visible to the readers without straining the eyes. 
As a designer you make use of colors, fonts and thickness of text to achieve this. 
Note: Always have a text background when writing on an image. 

6. SIMPLICITY AND MINIMALISM:
Always focus on using the minimalist designs on a page. Less of contents is more. Avoid congestion of contents on a particular design page. 
Never add a lot of content in a page in the name of beautifying it. Utilize the least contents to ensure simplicity of your designs. 

7. WHITE SPACE:
These are areas on your design without contents. White spaces are the spaces between your images, texts and contents on a design page. 
One may refer to it as emptiness, and may be pushed to fill them up. But I tell you to always give room for white spaces in your design to help balance out the part with contents.
A quick Big O recap for devs
Tags: bigonotation, beginners, algorithms, computerscience
Published: 2021-08-09 11:38:54


About a year ago, as I started doing some small recap on algorithms, I came to an interesting realization: as enterprise developers we don't give a lot of thought to the Big O Notation because we're constantly using and reusing frameworks and algorithms that are already implemented. It's certainly there in the back of our minds in order to be able to optimize, but it's not often "fully activated".

This year I'm preparing to become the buddy of a few students joining our company as part of their university studies. That means I'm putting together a study guide and an onboarding roadmap, but I also get to look back on all the things I wish I knew better when I was in their situation. Of course the learning path will not be that granular, but my mind wanders, so I dug up what used to be a tweet and turned it into a small article. 
I hope this will be helpful for beginners, but also for devs that jumped straight into coding. And if you’re anything like me, you’ll enjoy following along with the growth chart.

## Big O Notation

The Big O Notation is an abstract way to characterize algorithms according to how the running time or space (in memory or on disk) necessities grow as the size of the input grows.This is purely independent of programming languages, operating systems or hardware. Here is short sorted list of common growth rates: 

![algorithm complexity growth chart](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0whj4fbczwye5b521i3.png)

* Constant time - O(1) - The input size does not influence the required number of operations. Examples: printing a single value or accessing an array element by its index.

* Logarithmic time - O(log n) -  The number of required operations has a slow growth in relation to the input size. Example: binary search in a sorted array, where with each iteration the workload is being halved.

* Square-root time - O(sqrt(n)) - The number or operations is proportional to the square root of the input size.Example: primality test.

* Linear time - O(n) - The number of operations grows along with the size of the input.Examples: algorithms that involve iterating over a collection once, sequential search.

* Log-linear time - O(n log n) - The number of operations grows proportionate to n log n. Example: merge sort.

* Quadratic time - O(n<sup>2</sup>) - The number of operations is equal to a squared n, usually by running two nested for loops.Examples: bubble sort, insertion sort.

* Exponential time - O(2<sup>n</sup>) - The number of operations doubles with every input increase.Example: finding Fibonacci numbers recursively.
Update/Questions
Tags: flutter, dart, ux, design
Published: 2021-08-09 11:26:43

## Hey guys!
Sorry I have been MIA for awhile, I was caught up with assignments and exams from the end of the semester but I'm done now so I just took a little break but I'm here and back. I have mostly been searching for a job and or internship as this is my last year of college but unfortunately my country doesn't offer jobs in my chosen profession of a software developer so I have to constantly search online and hope I get lucky so that has been taking up most of my time.

Aside from that, I will try to be more active here so my question to you guys:
* What content would you like to see?
* Do you have any questions?
* Any specific projects you would like to see?
* Any specific UI Designs you would like to see? 

---

I have been getting back into [Pen Note](https://dev.to/meshamakes/pen-note-a-flutter-markdown-editor-3if5) however I chose to restart the project to implement some better practices and to just essentially restart the process but I ran into a problem with the mark down package that I was using so I'm stuck with two options:
* Create my own markdown package, and then implement it into the project
* Wait until they sort the issue with the markdown package.

I think my only real option is to sit and create my own package and continue on, so I'm not so far behind but what do you think? Tell me below.


[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z860Z55)

![Thank you image](https://steamcdn-a.akamaihd.net/steamcommunity/public/images/clans/32193639/37697d2c0376739048f5e612f1ed837dd4f62075.jpg)
Blockchain - The Bigger Picture
Tags: blockchain, firstpost
Published: 2021-08-09 11:21:22


## Introduction

According to [IBM](https://www.ibm.com/topics/what-is-blockchain):
**Blockchain defined**: Blockchain is a *shared*, *immutable ledger* that facilitates the process of *recording* transactions and *tracking* assets in a business network. An asset can be *tangible* (a house, car, cash, land) or *intangible* (intellectual property, patents, copyrights, branding). Virtually anything of value can be tracked and traded on a blockchain network, *reducing risk* and cutting costs for all involved.

**Why blockchain is important**: Business runs on information. The faster it’s received and the more accurate it is, the better. Blockchain is ideal for delivering that information because it provides *immediate*, *shared* and *completely transparent* information stored on an *immutable ledger* that can be accessed only by permissioned network members. A blockchain network can track orders, payments, accounts, production and much more. And because members share a single view of the truth, you can see all details of a transaction end to end, giving you greater confidence, as well as new efficiencies and opportunities.

## Where can we apply Blockchain technology?

### Food Safety - Walmart
Walmart has been working with [IBM and Hyperledger](https://www.hyperledger.org/learn/publications/walmart-case-study) for over a year on using the blockchain to **digitize the food supply chain process**. In fact, supply chain is one of the premiere business use cases for blockchain (beyond digital currency). Walmart is using the IBM Food Trust Solution, specifically developed for this use case.

“We built the IBM Food Trust solution using IBM Blockchain Platform, which is a tool or capability that IBM has built to help companies build, govern and run blockchain networks. It’s built using Hyperledger Fabric (the open source digital ledger technology) and it runs on IBM Cloud,” Bridget van Kralingen, IBM’s senior VP for Global Industries, Platforms and Blockchain explained.

### Document Signing

With blockchain, you can imagine a world in which documents are embedded in digital code and stored in transparent, shared databases, where they are protected from deletion, tampering, and revision. [https://mydocuments.tn/] is a Tunisian solution made by [ATI](https://www.ati.tn/) and [UniversaBlockchain](https://universablockchain.com/) collaboration.

### Supply Chain

[Singapore-based VeChain](https://www.vechain.org/) created a permissioned blockchain-based supply chain to monitor products as they move along from manufacturer to store shelf.

## Blockchain Demo
This is a very basic visual introduction to the concepts behind a blockchain by [Anders Brownworth](https://www.youtube.com/channel/UCx7YSpyYtgaYik1Wen9jYSA) introduce the idea of an immutable ledger using an interactive web demo.
{% youtube _160oMzblY8 %}
This is part two in my basic visual introduction to the concepts behind a blockchain. We build on the concepts from the previous video and introduce public / private key pairs and signing using an interactive web demo.
{% youtube xIDL_akeras %}
Learn Blockchain Development and get PAID per Task
Tags: blockchain, nervos, ethereum
Published: 2021-08-09 10:18:01

Welcome to this mini blockchain development lesson, in which we are going to learn about the new open source blockchain - Nervos, and earn money, crypto ($CKB) or USD, for each task we complete.

The Nervos Training Hackathon is a way for developers to complete Blockchain development tasks and get paid for their completion. There are 11 in total as of today, so you could win a sum of 340USD or the equivalent in crypto, and to get you started I'm here with a special guest Jordan, a senior Blockchain Developer who is going to help us through the first 3 tasks.

What we will be covering:
00:00 Intro
00:45 What is Nervos
03:50 Prerequisites
04:46 Task 1 - Setting up your CKB Node and CKB Indexer
09:00 CKB Node
19:21 CKB Indexer
33:55 Claiming your prize money
35:34 Task 2 - Create a Godwoken Account on the EVM Layer 2 Testnet
44:47 Create and fund an account with CKBytes on Layer 1
54:21 Deposit some CKBytes on Layer 2
01:03:10 Make a Deposit to Layer 2
01:05:18 CKBytes and Shannons
01:06:04 Creating a Transaction
01:10:35 Claiming your prize money
01:11:08 Task 3: Deploy a Simple Ethereal Smart Contract on Polyjuice
01:23:57 Claiming your prize money
01:25:26 Where to go next

By the end of all 11 tasks you would have **successfully taken an existing Ethereum app and put it on Nevros**. 


Links mentioned in the video:
🔗 Introduction: https://github.com/Kuzirashi/gw-gitcoin-instruction
🔗 Task Setup and Requirements: https://github.com/Kuzirashi/gw-gitcoin-instruction/blob/master/src/task-setup-and-requirements/task-setup-and-requirements.md
🔗 Gitcoin Bounties: https://gitcoin.co/hackathon/nervos
🔗 Nervos Discord (Join #gitcoin-hackathon): https://discord.gg/AqGTUE9
🔗 Nervos Network's Twitter: https://twitter.com/nervosnetwork
🔗 Jordan Mack's Twitter: https://twitter.com/jordan_mack

{% youtube 5tK2s_rWA7c %}
___


You can also find me on:
Twitter: https://twitter.com/ania_kubow
Instagram: https://instagram.com/aniakubow
How you tackle a bug?
Tags: discuss, watercooler, javascript, python
Published: 2021-08-09 11:08:15

# Introduction

We all have encountered bugs either small or big. Sometimes it was quick and we solve the bug in few minutes but sometimes it even takes days for solving a particular bug.

![BUG](https://media.giphy.com/media/oYQ9HRm5Mo7VXeMNVR/giphy.gif)

So today, we are going to discuss "How we solve the bug?"

## How I did?

I did following this when I encountered with bug:
- First I tried all of my knowledge to solve the bug🧠
- If it persists then I go to look on the web especially the savior Stack Overflow and documentation🌐
- If it persists, mostly I take a break then I go for walk, listen to music, meet my friend, etc💆
- After coming from break, most of the time I cracked the bug as I was able to see things that I was probably had missed during the coding👨‍💻
- If it persists, mostly it won't, I call my other developer friends to have an eye on the bug😄

## Discuss
- What is your method of solving a bug?