teleren/devto huggingface dataset:
Quais são as boas práticas do Código Limpo?
Published: 2023-10-26 19:59:52

Neste artigo, vamos explorar o conceito e demais princípios que estão relacionados a ele. Existe algumas formas simples e algumas boas práticas para a realização correta do Clean Code, ou Código Limpo, como conhecemos. 






## Boa nomenclatura - escolha bons nomes para o seu código:
Os nomes são muito importantes para facilitar a comunicação e a compreensão do projeto ou software. Eles devem ser simples e diretos, sem ambiguidades ou confusões. Isso vale para qualquer elemento do código, como variáveis, funções, parâmetros, classes ou métodos.

## Tratamento de erros: 
Estamos acostumados a erros no processo. Mas, precisamos garantir que o software continue funcionando, mesmo diante de contratempos. Portanto, a gestão de erros é essencial e deve informar o usuário de forma simples. Assim, o software se mantém funcionando e o usuário entende o que ocorreu de errado.


## Faça testes:
Testar o software é tão importante quanto tratar os erros, pois garante que o projeto funcione bem e atenda aos requisitos. Eu diria que é essencial, pois sem testes não dá para saber se o software está fazendo o que deveria ou não.



###  Aqui estão três exemplos de princípios de Código Limpo. 


### Java - Comentários Significativos:
Comentários bem colocados explicam a finalidade e o contexto do código, tornando-o mais claro para outros desenvolvedores que podem precisar trabalhar nele no futuro.

### // Exemplo não limpo:

int resultado = calcular(idade, salario, true);



### // Exemplo de código limpo:

// Calcula o bônus com base na idade e no salário, aplicando o ajuste para novos funcionários.

int bonus = calcularBonus(idade, salario, true);



## JavaScript - Funções Pequenas e Focadas:

Dividir uma função grande e complexa em funções menores, cada uma com uma única responsabilidade, torna o código mais fácil de entender e de manter.



### // Exemplo não limpo:

function processarPedido(pedido) {

    // Lógica complexa de processamento de pedido

    // ...

}



### // Exemplo de código limpo:

function validarPedido(pedido) {

    // Lógica de validação do pedido

    // ...

}



function calcularTotal(pedido) {

    // Lógica de cálculo do total

    // ...

}




##  Python - Nomes Descritivos Significativos:
No exemplo de código limpo, as variáveis e funções têm nomes descritivos que indicam claramente o que estão fazendo, tornando o código mais legível.



### // Exemplo não limpo:

def f():

    x = 5

    y = 10

    return x + y



### //Exemplo de código limpo:

def calcular_soma():

    valor1 = 5

    valor2 = 10

    return valor1 + valor2


## 5 livros sobre Código Limpo, ou Clean Code:

- Clean Code - A Habilidade Essencial para o Desenvolvedor Moderno, do autor Robert C. Martin;

- Clean Architecture: Um Guia Prático para Desenvolvedores e Designers, do autor Robert C. Martin;

- O Programador Pragmático: Sua Jornada para se Tornar um Excelente Desenvolvedor, dos autores Andrew Hunt e Dave Thomas; 

- Refatoração: Aperfeiçoando o Design de Código, do autor Martin Fowler;

- Projeto Limpo: Best Practices, do autor Robert C. Martin;
Let's play a game "Your Topic My Article"
Tags: discuss, webdev, beginners
Published: 2023-10-26 19:59:13

I'm thinking about writing some article about Web Development based on my experience, but I'm not sure what people are interested in. Is there anything you want to know more about Web Development? Most of the time, I work with JS and React ecosystem. I'd be happy to share my experience if I'll find some topic I'm good at ☺️ I could alway learn something if it's new and share my finding.
Placeholder Maintainer
Tags: hack23maintainer
Published: 2023-10-26 19:48:52

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a maintainer. Is this your first Hacktoberfest, or have you maintained in others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Project
<!-- Tell us about the repository that you hosted. What processes did you set up to review and merge pull requests? Feel free to embed your GitHub repo by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your project goals changed since publicly maintaining it? -->
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-26 19:47:16

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a contributor. Is this your first Hacktoberfest, or have you contributed to others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your learning or career goals changed since working on these new projects? -->
Trilhando o meu primeiro Hacktoberfest 2023
Tags: hacktoberfest, hacktoberfest23, opensource
Published: 2023-10-26 19:40:44

Olá rede, muito prazer me chamo Hebert Montarroyos, sou Desenvolvedor FullStack, é meu primeiro contato com o [hacktoberfest](https://hacktoberfest.com/), na verdade, acabei entrando um pouco mais tarde já na metade de outubro, porém pretendo me comprometer e além de colaborar com a comunidade, pretendo manter um projeto, que já tenho faz um tempo open source, para que outros devs possam ajudar e também aprender com ele. 


Durante o Hacktoberfest, vou explorar projetos de código aberto alinhados aos meus interesses e habilidades. Seja codificando, corrigindo erros, melhorando a documentação ou sugerindo recursos, estou pronto para me envolver. Acredito que o código aberto é sobre colaboração e inovação. Espero conectar-me com pessoas que compartilham essa paixão pela tecnologia e o desejo de fazer a diferença no mundo através de contribuições com o open source. 

Há um tempo escrevi um artigo ensinando como colaborar com projetos open source, deixo o [link](https://dev.to/hmontarroyos/como-contribuir-com-projeto-open-source-e-apoiar-a-comunidade-5g7a) aqui também. 

Além de divulgar ainda mais meu projeto open source que se trata de uma biblioteca de componentes para React a qual deixo o [link](https://github.com/HMontarroyos/FeboUI) aqui também, caso queiram colaborar e também está com a flag do #hacktoberfest2023.

Dito tudo isto fico aberto a novas oportunidades, caso queiram trocar alguma ideia só me chamar por aqui ou em alguma rede social minha, um ótimo hacktoberfest a todos, e vamos codar. 


### 🚀 Let's code! 🚀 ###
My sister and I just launched our brand-new app, 'FunKey' on the Mac App Store
Tags: ios, macos, keyboard, swiftui
Published: 2023-10-26 19:28:57

I'm the creator of FunKey. FunKey is a Mac menu bar app that enhances your typing with enjoyable sounds of mechanical keyboards and mouse clicks, making your work more productive, whether it's coding, designing, or anything else.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aj5zfuoxhzq9flkruk5i.png)

**Funkey features:**

• Enjoy pleasing keyboard sounds.
• Get immersive typing experiences.
• Hear the sounds instantly as you type.
• Easy access in your Mac menu bar.
• It's a fast native Mac app. Built exclusively for your Mac.

Download - https://apps.apple.com/us/app/funkey-mechanical-keyboard-app/id6469420677
How to check Postgres VACUUM process progress?
Tags: devops, database, sql, postgres
Published: 2023-10-26 19:27:02

The following query allows you to check the Postrges VACUUM process progress.

```
SELECT
  p.pid,
  now() - a.xact_start AS duration,
  coalesce(wait_event_type ||'.'|| wait_event, 'f') AS waiting,
  CASE
    WHEN a.query ~*'^autovacuum.*to prevent wraparound' THEN 'wraparound'
    WHEN a.query ~*'^vacuum' THEN 'user'
  ELSE 
    'regular'
  END AS mode,
  p.datname AS database,
  p.relid::regclass AS table,
  p.phase,
  pg_size_pretty(p.heap_blks_total * current_setting('block_size')::int) AS table_size,
  pg_size_pretty(pg_total_relation_size(relid)) AS total_size,
  pg_size_pretty(p.heap_blks_scanned * current_setting('block_size')::int) AS scanned,
  pg_size_pretty(p.heap_blks_vacuumed * current_setting('block_size')::int) AS vacuumed,
  round(100.0 * p.heap_blks_scanned / p.heap_blks_total, 1) AS scanned_pct,
  round(100.0 * p.heap_blks_vacuumed / p.heap_blks_total, 1) AS vacuumed_pct,
  p.index_vacuum_count,
  round(100.0 * p.num_dead_tuples / p.max_dead_tuples,1) AS dead_pct
FROM pg_stat_progress_vacuum p
JOIN pg_stat_activity a using (pid)
ORDER BY now() - a.xact_start DESC;
```

`ask_dima@yahoo.com`
Postgres. CREATE INDEX concurrently <index_name> ON <table_name> ... takes too long.
Tags: database, devops, postgres, sql
Published: 2023-10-26 19:22:46

Postgres. CREATE INDEX concurrently <index_name> ON <table_name> ... takes too long.

Check that you see the index as invalid when running \d+ <table_name>. If you don't have the index, it means its creation didn't start. There is some process that blocks the index creation.

To find out which process blocks the creation of an index run the following SQL command:

```
select pid, 
       usename, 
       pg_blocking_pids(pid) as blocked_by, 
       query as blocked_query
from pg_stat_activity
where cardinality(pg_blocking_pids(pid)) > 0;
```

Terminate the session that blocks index creation.

Wait till the index is created.
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-26 19:08:00

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a contributor. Is this your first Hacktoberfest, or have you contributed to others? Feel free to embed your GitHub account by using {% embed LINK %} -->
It is my First time participating in Open Source hoping to have fun and learning new Things  {% embed https://github.com/ArnabBCA %}

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->
I have Succesfully Completed Hacktoberfest Challenge and merged 12 prs {% embed https://github.com/SarthakKeshari/calc_for_everything/pull/57 %}

{% embed https://github.com/arc53/DocsGPT/pull/384 %}
### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your learning or career goals changed since working on these new projects? -->
I knew React.js and Build MERN stack Projects
Function declaration vs Function expression
Tags: javascript, beginners, programming
Published: 2023-10-26 19:07:13

Function declaration vs Function expression  

In JavaScript, a function is a reusable block of code that performs a specific task or set of tasks. It's like a recipe: you define the steps to be taken, and then you can reuse that recipe (function) whenever you need to perform those steps.

**Function declaration**

A function declaration creates a Function object. Each time when a function is called, it returns the value specified by the last executed return statement, or undefined if the end of the function body is reached.

Let's break this down in more simple terms

To use a function you must first declare it. In javascript, the function is declared by using the function keyword.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayznaf7dxnjhg2qvubhe.png)

Here are the steps to declare a function in javascript.

1. Start function with the function keyword
2. Then write the name of the function with a space. The 
   naming convention of function is the same as a variable 
   naming convention.
3. Then give arguments to the function enclosed in parentheses 
   and separated by commas like (parameter1, parameter2, ...)
4. Then define the function body by curly braces {...}
5. At the end of the function use return keyword to return any 
   object or value.

**Function expressions**

Function expression is similar to function but the difference is function name. Let's take a deeper dive into this. In order for use function expression we will need to use the following with a `name` 

**Let** vs **Const** vs **Var**

Let 
Use **let** when the variable needs to be reassigned or its value will change.
It's a good choice for variables that are expected to have different values at different points in your code.

Example:

```
let counter = 0;
counter = 1; // Valid

```

Const
Use **const** when the variable should not be reassigned. It creates a constant reference to a value.
It's particularly useful for declaring values that are meant to remain constant throughout the program.

Example:

```
const PI = 3.14;
```



Var 
**var** is less commonly used due to its function-scoping behavior.

Example:

```
var x = 10;

```


In the world of JavaScript, variable declarations play a crucial role in managing data. Whether you're declaring a constant that holds an unchanging value, using let for variables that might evolve, or opting for var in specific scenarios, understanding when to use each is key.

In a nutshell:

Use const for values that remain constant throughout your program.

Turn to let when your variable's journey involves reassignment.
Consider var cautiously, as its function-scoping behavior might not always align with modern best practices.

Remember, the choice between let, var, and const depends on the scope and mutability requirements of your variables. By mastering these declarations, you pave the way for more robust and readable JavaScript code.

Happy coding! 🚀
Survey about security issues for MERN stack developer
Tags: webdev, javascript, mern, developers
Published: 2023-10-26 19:06:27

This is survey for seeing which are the security problems faced by most MERN stack developers.
*This is exclusively only for MERN stack developers*
Please fill up this form as correctly as possible and as understandable as possible.
https://forms.gle/EH3kHjoKae8ZC15q9
DATA APPEND SERVICES
Tags: dataappend, ipaddressappend, emailappend, ethnicityappend
Published: 2023-10-26 19:04:26

We provide many data append option like phone append , email append ,demographic append and many more is available on [datazapp.com](https://www.datazapp.com/data-append)

Our Feature Are:-

MATCH RATE
- Industry leading match rate as high as 60%
 
QUALITY DATA
- Triple-verified & enhanced for accuracy and deliverability

TURN-AROUND
- Most appends processed in minutes

AUTOMATED
- Upload your lists directly 24X7

**                DATA APPENDS & ENRICHMENT
**
With Datazapp's Data Append services, you can reach your audience through more channels of communication and gain a deeper understanding of your audience by completing the gaps in your customer and prospect data.


**Better Understand Your Audience
**
Append demographics such as age, gender, ethnicity, political affiliation, and 50+ other demographics data appends to identify characteristics of your best customers.

- Recognize patterns in your audience’s buying behavior
- Create focused marketing campaigns to increase ROI

More data append option is available on [datazapp.com](https://www.datazapp.com)
JavaScript ES6 Features Every Developer Should Know
Tags: beginners, javascript, tutorial, webdev
Published: 2023-10-26 18:57:01

---
canonical_url: https://baransel.dev/post/javascript-es6-features/
---

## JavaScript ES6 Features Every Developer Should Know

JavaScript is constantly evolving, and ECMAScript 6 (ES6) brought a wealth of new features that can supercharge your coding experience. In this article, we'll delve into some of the key ES6 features that are essential knowledge for every JavaScript developer. From arrow functions to promises, these tools will help you write cleaner, more efficient code and elevate your JavaScript skills to the next level.
  
1. **Arrow Functions**

Arrow functions provide a concise way to write functions in JavaScript. They have a shorter syntax and automatically bind the `this` keyword. Here's an example:

```js
// Traditional function
function add(a, b) {
  return a + b;
}

// Arrow function
const add = (a, b) => a + b;
```

2. **Template Literals**

Template literals allow you to embed expressions inside strings using backticks (\). This makes it easier to create dynamic strings:

```js
const name = "John";
console.log('Hello, ${name}!');
```

3. **Destructuring**

Destructuring enables you to extract values from objects and arrays effortlessly. For instance:

```js
const user = { name: "Alice", age: 30 };
const { name, age } = user;
```

4. **Spread and Rest Operators**

The spread operator ('...') allows you to split an array into individual elements or merge objects and arrays. The rest operator does the opposite:

```js
const numbers = [1, 2, 3];
const newNumbers = [...numbers, 4, 5];

const { a, b, ...rest } = { a: 1, b: 2, c: 3, d: 4 };
```

5. **Promises**

Promises are a cleaner way to handle asynchronous operations in JavaScript, making it easier to manage callbacks and avoid callback hell:

```js
const fetchData = () => {
  return new Promise((resolve, reject) => {
    // Perform async operation
    if (success) {
      resolve(data);
    } else {
      reject(error);
    }
  });
};
```

These are just a few of the powerful features introduced in ES6. Learning and using ES6 features can significantly improve your JavaScript code's readability and maintainability.

By incorporating these ES6 features into your JavaScript projects, you'll write cleaner and more efficient code. Take advantage of them in your next coding adventure, and watch your development process become smoother and more enjoyable.
My side project is costing me too much
Tags: webdev, devops, aws, ec2
Published: 2023-10-26 18:56:27


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jf4aankvct9m0xep1clo.png)

I run a side project https://freecodecompiler.com. As the domain states, it is an online code compiler for multiple programming languages. Recently it has completed it’s month anniversary and so did the AWS billing. To be honest, while setting up the infra, I was expecting a cost like this. Though it’s not too high but for a side project of this scale, where there is no business value attached, it is a bit high.

Majority of this cost is coming from the API server that runs on t2 micro instance and has a load balancer associated with it. Also the load balancer was costing more than the ec2 instance cost. Last month the load balancer costed around $16 alone where as the instance cost was around $9.

I hate to acknowledge that the load balancer was only being used to route the https traffic to a specific port. Since ACM certificates do not support EC2 instances so I had to use LB to enable SSL on ec2 instance.

But there was always a “what if” in my mind. And I took a shot last weekend. The load balancer was enforcing SSL on the EC2 instance from outside but since it (LB) accounted for majority of the billing amount so I thought of cutting it off completely.

I chose the traditional way of installing SSL instead of enforcing it. Installed letsencrypt cert directly on the ec2 instance and bingo! Of course I had to install the apache proxy and a few tweaks but overall it did the job. Now I am expecting it should reduce the cost by one third of what it was previously. And I will look forward to reduce it more.

Also I have to periodically update the cert on server, not sure how I can automate it. But I am satisfied with this solution.

Do you guys have similar experience? Please suggest if you have any tips to reduce AWS ec2 billing and how to automate updating of letsencrypt cert expiry date. It will be a big help!

Until then, I will come up with some new update next week!
CELL & PHONE APPEND REI SERVICE
Tags: phoneappend, realestateinvestors, realestatewholesalers, skiptracerealestate
Published: 2023-10-26 18:54:10

**What is OUR REI SKIP TRACE SERVICE
** 

Datazapp only costs you for the phone numbers it provides you with, matching landline and cell numbers to your property data. It can take days to receive your results from some real estate skip-trace services, which can cost between $.80 and $3.00 per record. Since Datazapp recognizes that speed and cost-effectiveness are crucial for real estate investors, its [phone append service](https://www.datazapp.com/phone-append/) is available for just $0.03 per phone number and can be completed in a matter of minutes.

**PRICING & PAYMENT OPTIONS
**

Our standard Pay-as-you-Go pricing plan is perfect for those who run large batches of records to append (skiptrace) phone numbers or emails to those lists, or those who build bulk lists of property and homeowner records. But if you need smaller quantities of records and [Email appends](https://www.datazapp.com/email-append/) at a higher frequency one of our pre-payment plans below will save you time and money!

Check out more plans on [datazapp.com](https://www.datazapp.com/skip-tracing-real-estate-marketing)

**HOMEOWNER & PROPERTY SELLER SCORES
**
We examine and track nearly 25 distinct family and property-related data factors that influence the choice to sell a home, using the most latest BigData & Data prediction algorithms, and we assign a seller score. The Seller Score on Datazapp shows how likely it is for homeowners to sell in the upcoming six to twelve months.

With the assurance that you have the best leads, use the Seller Scores to build your prospects and marketing campaigns and target those likely home sellers well in advance.

Check out more details on [datazapp.com](https://www.datazapp.com/skip-tracing-real-estate-marketing)
Unusual Billing Discrepancies
Published: 2023-10-26 18:47:01

Hello Dev Forum community,

I have been encountering a puzzling issue on my medical billing services website that I could use some expert advice on. Our billing system has been generating occasional discrepancies in billing statements, leading to minor inconsistencies in the charges for our services. While these discrepancies are not frequent, they have raised concerns among some of our clients.

I have reviewed our billing processes and haven't identified any apparent issues. We use industry-standard software for our billing and coding. Still, I want to ensure that our billing statements are accurate and that there are no hidden issues within our system that might lead to these discrepancies[.](https://www.cloudrcmsolutions.com/) This situation has been impacting our reputation, and I want to resolve it as swiftly as possible.

Has anyone else experienced a similar issue on their medical billing services website or a related platform? What steps did you take to troubleshoot and resolve it? I would greatly appreciate any insights, advice, or best practices from the community. Feel free to ask me for additional information about my website if needed. Thank.