teleren/devto huggingface dataset:
Single Responsibility Principle
Tags: solid, single, reusability, srp
Published: 2021-03-26 13:58:01

---
title: Single Responsibility Principle
published: true
description: single responsibility principle
tags: solid, single, reusability, srp
---

# Single Responsibility Principle

You may have heard the term "single responsibility principle" before, but what does it mean?

The single responsibility principle dictates that your classes should have only one responsibility. Not two. Just one. If you follow this principle, you can reduce tight coupling and make your code easier to refactor.

It can be tempting to keep adding methods to an existing class, especially when working with an older codes. Resist it. Whenever you're about to add a method to a class, ask, "does this method I am about to add fall within the scope of this class?".

If yes, add to it. If no, put it in a different / new class.

For example, if you are writing a password validator logic for the `CreateUser` class, you're thinking of adding it in that class. Take a step back and ask, "does the responsibility of validating a password fall under the `CreateUser` class?".

In this case, the answer is no. `CreateUser`'s responsibility is to handle user creation. It makes more sense to create a new class, `Validate`, to handle password validation. In the future you can reuse it to not only handle password validation, but other validations like username, email, product description, etc. By creating a new `Validate` class, you create a space to put all future validation logics in.

The single responsibility principle can be applied not only in classes, but also to modules, services, applications, and even systems.
How to avoid flow zone — a false sense of hyper-productivity
Tags: productivity, webdev, programming, javascript
Published: 2021-03-26 13:48:28

Flow zone(aka Zone) is that state of mind in which a programmer is highly focused on solving a particular problem. His brain is fully concentrated on solving the problem and he is disconnected from the rest of the world. When he gets out of the zone, he gets the feeling of getting things done. He also gets an immense feeling of being hyper-productive and wants to get into the flow zone more often.

Being concentrated to solve a problem is the most important thing that programmers should do. But what is wrong with it? According to Uncle Bob, the flow zone is a trap. It is a trap that can diminish the big picture of the problem you are trying to solve. Let me make that simple for you.

Do you remember the last hobby project you started and you stopped working on it after a few days, weeks, or months? Your hobby project was a cool idea to build a trading website but you spent hours choosing a good font for your website instead of writing an algorithm. You checked one font, the recommendation system suggested similar other, you kept on trying one and another. You entered the zone and got lost there. After an hour you realized no real work is done. Maybe at the end, you chose one descent font but the zone made you lost and you did not realize the actual problem you had to solve.

Another example of getting into the zone is that. You were asked to write a module of software and in the middle, you did not know how to handle one strange exception. You started surfing the internet and did not find anything, you started checking Github issues and didn’t find anything there either. You decided to create a new issue asking for help. You already entered into the zone and you didn’t even realize. You did not ask yourself if handling that exception was important for your use case.

Does that mean getting into the zone is no good at all? In fact, it depends, sometimes if you are in the zone for short period it can be good but for long period it is bad. It might give you a sense of being more productive but in most cases, the code written when you are in the zone will be needed to be re-evaluated and refactored later.

So how can we avoid the zone? To avoid it you must know you are in it. After reading this article, it will be easier for you to know you are getting into the flow zone. Try to avoid it after that. 

You can read some tweets or surf Reddit or check my articles in dev.to once you start feeling you are getting into the zone. You can also try pair programming which does not let you enter the flow zone since two people communicating cannot get into the flow zone at the same time.

Let me know what you think about the flow zone.
The idea and reference of the above content are taken from Uncle Bob’s Clean Coder book.
📸 How to Read and Remove Metadata from Your Photos With Python
Tags: python
Published: 2021-03-26 13:47:06

📚 Smartphones include EXIF metadata in their photos. Here’s how to read, write, and erase it using Python.

The mass adoption of smartphones — essentially portable, sensor-rich, location-aware, always-networked computers — has given us two major consequences whose effects on privacy and security aren’t yet fully understood:

1. More people than ever have a camera that’s usually within arm’s reach.
2. By default, the photos taken with these cameras can give away sensitive information, and many users are unaware that it’s happening.

In addition to picture data, photos taken with smartphones and modern digital cameras contain metadata, which is additional information about the photo. This metadata is stored in a format called EXIF, which is short for EXchangeable Image File format, which is a continually evolving standard for information added to digital image and sound recordings.

In photos, EXIF can include information such as:

- The dimensions and pixel density of the photo
- The make and model of the device used to take the photo
- Zoom, aperture, flash, and other camera settings when the photo was taken
- The orientation of the device when the photo was taken
- When the photo was taken
- Where the photo was taken
- Which direction the camera was facing
- The altitude at which the photo was taken

This metadata is useful for sorting, cataloging, and searching through photos, which is why the EXIF standard was defined. However, it also introduces privacy and security concerns that many users don’t take into account.

[Read more...](https://auth0.com/blog/read-edit-exif-metadata-in-photos-with-python/?utm_source=content_syndsc&utm_campaign=python_exif)
Importing blog from Medium and make it Free blogging and free hosting with custom domain using Hashnode
Published: 2022-07-05 10:51:18

---
title: Importing blog from Medium and make it Free blogging and free hosting with custom domain using Hashnode
published: true
date: 2021-03-26 13:34:55 UTC
tags: 
canonical_url: https://lkgforit.com/importing-blog-from-medium-and-make-it-free-blogging-and-free-hosting-with-custom-domain-using-hashnode
---

Free blogging and free hosting with custom domain using Hashnode.

You can import existing blog posts from dev.to or medium to Hashnode in minutes.

Below are the steps for medium import :

1. Go to medium site settings then go to advanced.
2. Click my data in medium 
3. Click on export
4. You will receive link for zip file which all articles.
5. Then come to Hashnode my blog dashboard.
6. Go to import then select import from medium.
7. Select zip file downloaded from medium
8. It will list all articles from medium and then select all click publish.

This will publish all articles to Hashnode site one by one .

Hashnode have options to backup Our Blog posts in GitHub private repo.
Basic Haskell/VSCode/Windows environment in 2021
Tags: haskell
Published: 2021-03-26 13:28:00

*NB!* This is the best I could get in 2 hours. If you know any way to improve on this, please, share!

Global setup:
- Install latest Haskell Platform from [prior versions](https://www.haskell.org/platform/prior.html) page. Newer versions of Haskell Platform are installable only through Chocolatey and elevated command prompt, and in the end it won't work, because GHC 9 is too new and not supported by VSCode plugins.
- Restart VSCode, if it was running. On Windows global environment variables get fixed at program startup, and extensions won't find GHC.
- Install [syntax highlighting extension](https://marketplace.visualstudio.com/items?itemName=justusadam.language-haskell).
- Install [language service client](https://marketplace.visualstudio.com/items?itemName=haskell.haskell) extension. The first time `*.hs` file is opened, it will download required language server binaries.
- Open Msys command prompt (available as *Git Bash* from context menu in any folder, if Git is installed).
- Run `cabal update` to download latest package version version information.
- Run `cabal install ghci-dap haskell-debug-adapter`.
- Install [Haskell debugger](https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode) extension.

Project setup (mostly from Haskell debugger extension `readme`):
- Create a folder.
- Run `cabal init`, `cabal configure`, and `cabal bulid` in it (this time regular command prompt is enough).
- Switch to `Run and Debug` tab in VSCode and press `Create a launch.json file` link. Select `haskell-debug-adapter` there.
- In toolbar select `haskell(cabal)` configuration.
- Put a breakpoint and press F5 to run.
Avoidance of excessive access in SQL
Published: 2021-03-26 13:26:54

## Nested Loops

The described iteration above can be compared with a simple programming Loop and the table with an array. Two tables with an two dimensional array and so on. In this case it is obvious to use some nested loops like for loops or while. This is a legitimate approach up to a certain point. 

In the example above we have 100 thousands of records in one table. The nested loops for two of this tables cause a lot of accesses. The picture below shows these accesses.



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

## Field Dependencies

The picture above shows the exact match of a nested for loop of two SQL tables. These tables have at least one dependent field. So in this case the for loop go through every record in both tables. In detail: 



```sql
for select id from tabA 
do 
begin
	for select id from tabB
	do 
	begin 
	// do something
	end 
end 
```

First read a record of `TabA` and then all records of `TabB`. This is a load of accesses. in General "n²". This is a lot. Especially in SQL we have more ways to iterate through tables. The way of choice in this case is an "Inner Join". A Join matches two tables with at least on field each table. The Inner Join shows only the combined records where every condition is true. 



```sql
SELECT * FROM employee
INNER JOIN departmend on employee.departmend_id = departmend.departmend_id;
```

  

For example every employee who has an department will be shown in this combined result. This technique combined with some where conditions can reduce the records.  This will also reduce the numbers of accesses, because there are no accesses on empty records
Mail Domain and All Word Sorter
Tags: sorter, mail, domain, word
Published: 2021-03-26 13:21:25

# Mail Domain Sorter and All Word Sorter

[![Build Status](https://travis-ci.org/joemccann/dillinger.svg?branch=master)](https://github.com/v-Cx/mail-domain-sorter/releases/tag/0.1)

### What can you do with this software?
- ✨ You can save the lines belonging to all the words you want from a text file in a separate text file.

>If you want to improve the program, download it to your computer. Make improvements and send them back to the repo.
```sh
git clone https://github.com/v-Cx/mail-domain-sorter.git
```
### Screenshots of the program converted to exe

##### Opening Screen
![N|Solid](https://i.ibb.co/N1yp8Cy/giris.png)

##### The word input we want to separate
![N|Solid](https://i.ibb.co/SBNQyNm/kelime-giris.png)

##### And Finish
![N|Solid](https://i.ibb.co/v4PVZ75/son.png)

## Installation

```sh
git clone https://github.com/v-Cx/mail-domain-sorter.git
```

## Download Exe

```sh
https://github.com/v-Cx/mail-domain-sorter/releases/tag/0.2
```
Closures in Javascript.
Tags: beginners, javascript, tutorial, webdev
Published: 2021-03-26 13:19:59

Closures in javascript is one of the many questions normally asked in javascript interviews.

## What is a closure?

whenever a function is created, it forms a closure with the outer functions' scope. Think of that closure as a pack of **All the variables of the outer function scope.** 

## Let's understand this with an example.

```javascript
  function createAdder(firstNum) {

    return function (secondNum) {   //The closure function
      return firstNum + secondNum;
    };

  }

  let addOne = createAdder(1);

  console.log(addOne(10)); // 11
  console.log(addOne(2)); // 3
```

let's understand what's happening in the above code.

* First we define a function createAdder that takes _firstNum_ as a parameter.
<br>

* Then, we return an anonymous function that takes a _secondNum_ as a parameter.
<br>

* Now, we declare _addOne_ variable, with a call to createAdder function, with _firstNum_ parameter value being 1.


   ```javascript
      // so now the value of addOne should be -

      addOne = function (secondNum) {   //The closure function
                 return firstNum + secondNum;
               };
   ```


* so now, when we call _addOne(10)_. how does this _addOne_ get the value of _firstNum_? It's because of **closure**.
<br>

* so when the anonymous function (returned function) is created. It looks for parent variables. It finds _firstNum_ variable with value 1 and forms a closure with it (saves the variable) so that it can access the firstNum variable later.
<br>

* so the addOne(10) function returns 11. Because it already has the _firstNum_'s value as 1.

Now, I think you understand closure, Let's look at a practical example of where we can use closure.

{% codepen https://codepen.io/abhishekjain35/pen/zYNvLyv default-tab=js,result %}

In the above example, the _**updateClickCount**_ variable is assigned to a IIFE (immediately invoked function expression). So, the IIFE calls itself and returns an anonymous function which is finally assigned to _**updateClickCount**_.

Now, this anonymous function forms a closure with the parent function so that it has access to the parent function's variables i.e. _counter_ and _p_.

When we click, it calls the _**updateClickCount**_ which references to the anonymous function, increments the counter and updates the textContent of _p_.


Well, this is it from my side. See you soon 😁

![](https://media.giphy.com/media/hrRJ41JB2zlgZiYcCw/giphy.gif)
Object Destructuring I
Tags: javascript
Published: 2021-03-26 13:18:18

This post is a bit of a reboot from an earlier: {% link https://dev.to/codefinity/object-destructuring-2olo %}

## Destructuring ❓

Although this is not a standard English word, we could think 🧠 of it as dismantling or picking apart or as _the opposite of structuring 🏗️ something._

## Objects

Some languages have _structs._ In JS, we have these glorious things known as objects. It's amazing and incredibly flexible that we can just spin up a couple of `{}` and start adding 🔑s and values. 👏🏾

```javascript
const person = {
  fname: "Mark",
  lname: "Galloway"
}
```

And to access our 🔑, it's _dot notation, `.`_: `person.fname`. 🆒

## Back to Destructuring

If we need to access `person.fname` a lot, we can do like this one: `const { fname } = person;`.

Although when creating variables with `const` we can normally make up our own names, in this case, the name inside of `{}` **must** match the name of a property in `person` - else it will be `undefined`.

## But, I Don't Like `fname`
### Can't I Just Call It `mickeyMouse`?

Yes - but just b/c you can, doesn't mean that you should!

Nevertheless, here we go: 

```javascript
const person = {
  fname: "Mark",
  lname: "Galloway"
}

const {fname: mickeyMouse} = person;

mickeyMouse; // "Mark" - 🙄
```

---

So, we destructure a 🔑 **by its name,** then we can easily rename it to something else. This is especially handy when we retrieve JSON from a database that uses some other SQL naming conventions.

For example, we might get back something like: `{"first_name": "Mark", "last_name": "Galloway"}`.

After parsing into JS, and assigning to a variable such as `person`, we could do: `const {first_name: fname} = person`.

---

Next time (assuming there's enough 👀 on this post!) we'll see 👀 examples of using this with function parameters.
Day 12 of 100 days of SwiftUi
Published: 2021-03-26 13:14:33

I just completed day 12 of 100 days of SwiftUi. Today, I learnt about the optional type in Swift. 

The optional type is a Swift feature that is used to signify  a type that may not have no value at all. Optional types in Swift are represented with a `?`. For example
```
var gender? = nil
```
The code above is an optional type that stores the gender of a user. Some users may not input their gender so we need to use an optional here to signify this value `gender` may not have a value. 

Getting a value from an Optional is rather simple using the `if-let` or the `gaurd-let`.

The `if-let` is a conditional statement that  is used to get the value from an optional. 
For example, you can get the value from `gender?` like this
```
if let selectedGender = gender{
  print ("\(selectedGender)")
} else {
  print (" No gender selected")
}
```
The `if-let` runs the code in the else block if the optional has no value. 

The `gaurd-let` is very similar to the `if-let`. The only difference is there is no else block. The guard let returns from the function if the optional has no value.
HTTP-Equiv(alent)
Tags: html, codenewbie, webdev, beginners
Published: 2021-03-26 13:11:55

The meta tag is used to convey meta information about the webpage to the web browsers. The information conveyed is called "metadata". The data is not visible in the page or is useful for the clients, the information is used by search engines and web crawlers. 

Sometimes we may not have the access to the server that is hosting our web documents, so to send additional information we can use the http-equiv meta tag. If we have access to the server configurations we can ignore the http-equiv tags, as we don't have access to the server configuration http-equiv help us to send some additional information to browsers. Http-equiv simulate an HTTP response header, the attribute lets you to send additional information to the browser in the form of http header.

Lets look at an example

```<META HTTP-EQUIV="Expires" CONTENT="Fri, 26 Mar 2021 17:49:00 GMT">
<META HTTP-EQUIV="Keywords" CONTENT="Metadata, httpequiv">```

The above code will add the below data to the response header.
```Expires: Fri, 26 Mar 2021 17:49:00 GMT
Keywords: Metadata, httpequiv```

Some of the most used values for http-equiv are mentioned below.

1. `<meta http-equiv=”expires” content=”date-time” />`
The date indicate the date and time in which the document will expire, when the expire time is reached the document will be reloaded.

2. `<meta http-equiv=”refresh” content=”n;url=url” />`
This code cause the document to be refreshed after n seconds and if the url is specified, after the refresh time the page will redirect to the mentioned url. **Should avoid the redirect, it is not accessible.**

3. `<meta http-equiv="default-style" content="/style.css">`
Sets the name of the default alternative stylesheet set, the CSS file must be linked to the document for this to work.

4. `<meta http-equiv=”content-type” content=”type; charset=charset” />`
This meta tag inform the type of the document and the character set used in the document. For example ` <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />` Tells the browser that the encoding is utf-8 and the document is of the type html.
CI/CD for Application Express Webinar
Tags: apex, lowcode, devops, webdev
Published: 2021-03-26 13:05:32

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0avqkbvjtkiaj4ew2h6t.png)

On the 17th of April (15:00-16:00 UTC, participate in this webinar about CI/CD for APEX:

https://asktom.oracle.com/pls/apex/asktom.search?oh=13321

With the rising popularity of DevOps, database and APEX developers must evolve to embrace CI/CD pipelines for developing, testing, and deploying database code changes. Today, many database developers struggle with the concept of using a central repository for storing, reviewing, and deploying code, where traditionally, all it took was a ZIP file of scripts and SYSDBA. This session will cover using Oracle’s free development tools combined with open source repository tools to create a full CI/CD pipeline for database and apex development groups.
Flutter Tutorial - New Trick to Create Customized Bottom Navigation Bar in Flutter.
Tags: flutter, beginners, tutorial, dart
Published: 2021-03-26 13:00:56

In this tutorial, we're going to learn a new trick on how to create a customized bottom navigation bar with a custom icon in our flutter application.

Thanks for watching, please do subscribe, like, comment, and share. If you have any complaints kindly comment below and if you also want us to make any adjustments let us know in the comment section below. Thanks

[Subscribe to my Youtube Channel](https://youtube.com/c/TechWithSam): https://youtube.com/c/TechWithSam

Source Code - Show some ❤️ by starring the repo and do follow me 😄
https://github.com/techwithsam/custom-icon-with-bottom-navigation-in-flutter

Custom Icon in Flutter
https://youtu.be/FUeAr2LkSSw

Read Article ✍:
Hashnode - https://techwithsam.hashnode.dev/
Medium - https://techwithsam.medium.com/
Techpadi - https://techpadi.africa/author/acctgen1/

🔗 Social Media / Let's Connect 🔗
📂 GitHub: https://github.com/techwithsam
📱 Twitter: https://twitter.com/techwithsam_
📱 Facebook: https://facebook.com/techwithsam
📝 LinkedIn: https://linkedin.com/in/techwithsam
📸 Instagram: https://instagram.com/techwithsam_
⭐ WhatsApp: https://wa.me/message/JLGQNNTPG64IH1
daily.dev --- dev.to --- hackernon = @techwithsam

Join the Flutter Developer's Community 
Facebook - https://www.facebook.com/groups/flutterdevsgroup
WhatsApp - https://chat.whatsapp.com/Cns1jo7dc5dCNrg6aG44My
Telegram - https://t.me/flutterdevsgroup
Signal - https://signal.group/#CjQKILccbSu9GnMF_qVrkdCFVQ_i2gmnigPDvweCy86JGpL3EhBg39kp1rftGQgZDYXLty7t

Subscribe to my Telegram channel: https://t.me/techwithsam1

**#flutter #bottomnavbar #techwithsam**
Data Science Question of the Week
Tags: datascience, interview, job, statistics
Published: 2021-03-26 12:35:50

Every week I ask a data science Question of the Week.



Answer this question in a minute or less to be prepared in your next tech interview.


![How do you test your samples for independence?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bhmbjqiu4dalxtpodsh.png)
**How would you test the independence of samples in your dataset?**



Let me know in the comments!


---


Read the latest issue of Late to the Party here:

https://buttondown.email/jesper/archive/do-mathematicians-practice-solve-love/


and subscribe to get these weekly machine learning, data science, and Python insights right in your inbox!

https://dramsch.net/newsletter