teleren/devto huggingface dataset:
PHP: 10 regras para Programação Orientada a Objetos
Tags: php, oop, webdev, programming
Published: 2021-10-19 00:32:31

Alguns princípios do raciocínio da programação orientada a objetos de forma direta, sem envolver revisão de conceitos.

...

## Regras para programar orientado a objetos
O objetivo é modelar o problema usando abstrações, a implementação é só o "como" e vem depois de entender o problema. A regra de negócio é mais que a soma das implementações.
* Crie classes e interfaces para modelar o problema. Interfaces e classes são a estrutura do problema, criar uma estrutura sólida e flexível é mais importante do que economizar linhas de código.
* Legibilidade é uma prioridade! O código é a regra de negócio escrita, e programar é uma atividade de ler e pensar mais que de escrever
* Classes devem representar entidades do problema!
* Programe para interfaces e não implementações, use inversão de dependência: métodos são comportamentos de entidades não funções! 
* Use interfaces como tipos de parâmetros e passe as entidades, não chame classes diretamente dentro de outras classes
* Classes são mais que métodos! elas representam informação!
* Cuidado com acoplamentos de classes! Limite o acoplamento limitando a responsabilidade das classes e usando interfaces!
* Defina o tipo dos parâmetros dos métodos sempre que possível! Use uma classe pai e sobrescrita de métodos, conceito chamado de polimorfismo, para evitar ter que usar IFs dentro de métodos
* Traits são a forma do PHP lidar com herança múltipla! Só utilize quando fizer sentido como uma característica adicional a um conjunto de classes
* Use interfaces! Interfaces são a chave da orientação a objetos, parte fundamental do SOLID e a estrutura de muitos Padrões de Projeto!

## Conclusão
Uma forma de entender a diferença de raciocínio entre os paradigma estruturado e o orientado a objetos é que enquanto a programação estruturada visa mais resolver o problema implementando os passos, a programação orientada a objetos tem como objetivo modelar o problema.
Assim quando o problema mudar, e ele sempre muda, a POO facilita que o sistema possa ser alterado para refletir as regras de negócio.

Imagem da capa: https://unsplash.com/photos/gAe1pHGc6ms
Refactoring Marathon and Rebasing Torturing
Tags: opensource, csharp, refactorit, git
Published: 2021-10-19 00:23:42

This week I was doing some refactoring for my [glazed-donut](https://github.com/dbelokon/glazed-donut) repo. Since its creation, the features kept coming in every week, but there was no refactoring done whatsoever, so... it got pretty messy😅

![Tom cleaning](https://c.tenor.com/IPq-Ep9u10AAAAAC/tom-jerry-cleaning-house-tomjerry.gif)

##Refactoring
It took me a while to come up with a way to refactor glazed-donut, because all the code was written in one file from the beginning😵. From this, I decided that I would focus on refactoring it into classes this time. 

First, I decided to create a file handler and a directory handler classes to manage their specific cases (i.e when the file path name is a single file or when it is a directory). This way, I separated two main functionalities of my ssg into separate files, so it is more clear and organized. 

I also thought that creating a common parser class would be a great addition, since it would help to differentiate between different ways to parse from a text file to an HTML file.

Next thing I did was adding another class to manage the parsing class dependency, such as opening the file, and outputting the HTML string from the file.

Lastly, I implemented a common interface across file and directory inputs. 

I am still not fully satisfied with the refactoring, but as my professor always says - code is never finished🙂 So I will still keep improving it over time. I also realized that OOP approach is very handy when it comes to refactoring. It helps us to have a better organized code base. 

##Git process: Commiting, Rebasing, Pushing, Merging
After each refactoring stage, I would make a commit so I had a chance to revert a specific commit back if anything went wrong.

Rebasing has given me a couple of heart attacks last week, not gonna lie🤯 But after some torturing and a dozen of fallen hair, I decided to ask my classmates for help, so luckily, it all worked out😋 So after I finished all the refactoring I wanted, I decided to make an interactive rebase on master branch, and squashed all of the commits into a single one. 

After that, I pushed the changes to my origin repo, creating the refactor branch

Then, I create a PR to merge everything into the master branch. [Here](https://github.com/dbelokon/glazed-donut/commit/2c658385ca6005aad439f8475058e66a690ba3e3) is how it is looking now.

## Byeeee

It was nice to get to know another Git feature - rebasing, that helps to organize commit history. I was also really happy to finally get some time to refactor my repo.
Youtube Channel || Web Dev - Django - HTML - CSS - JS 
Tags: django, programming, python, webdev
Published: 2021-10-19 00:20:49

Hello my fellow developers,

I have decided to start my journey on YouTube by creating a channel covering web development content. I will focus mostly on Django and Python. However, to make websites using Django, one uses HTML, CSS, and JS code, so the channel would really be about web development in general.

I have started my channel by putting out a video series of my book called Django Takeoff! which I have written many posts about. The series is totally free. 

I might occasionally write blog posts about the tutorials and videos I make, but I will mainly focus on making videos for now. 

If you have read my content here and on other platforms and believe that it's helpful, please subscribe and help me grow.

I appreciate everyone checking out my channel and leaving any feedback. Any suggestions for what you would like to see in the videos is also welcomed.

[Youtube Channel](https://youtu.be/B0rG2SQOBFo) 


Thanks in advance!!

See you there fellow programmers!!
HCRIS Field Labels
Published: 2021-10-23 08:43:13

---
title: HCRIS Field Labels
published: true
date: 2021-10-19 00:00:00 UTC
tags: 
canonical_url: https://datawookie.dev/blog/2021/10/hcris-field-labels/
---

![HCRIS Field Labels](https://datawookie.dev/blog/2021/10/hcris-field-labels/featured.jpg)

[Fathom Data](https://www.fathomdata.dev) has been doing a lot of work with the [HCRIS (Healthcare Cost Report Information System) data](https://www.nber.org/research/data/healthcare-cost-report-information-system-hcris). The underlying reports are submitted as a spreadsheet with multiple sheets. The data are then extracted and recorded in a simple tabular format, with each field linked to a worksheet code (`wksht_cd`), column number (`clmn_num`) and line number (`clmn_num`). These three keys are then mapped to a single compound key. The resulting data look something like this:

```
       key value
---------------------
   a_c1_30 8960498
   a_c2_30 2559809
   a_c6_30 -1581948
  a_c1_200 45448537
  a_c2_200 100473288
  a_c6_200 -23947062
 a7_1_c1_1 2696198
 a7_1_c1_6 87655935
 a7_1_c2_6 4190056
 a7_1_c1_8 168428817
 a7_1_c2_8 4391574
a7_1_c1_10 168428817
a7_1_c2_10 4391574
```

Of course, for these data to make any sense at all it’s necessary to map backwards from the compound key to the location within the original spreadsheet. And once you know _where_ the data belong, you’ll also want to know _what_ the data mean.

Fortunately this relationship is documented and available as a [PDF file](HOSP2010_SAS_FILE_RECORD_LAYOUT.pdf).

![](https://datawookie.dev/blog/2021/10/hcris-field-labels/record-layout.png)

This is useful, but for analytical purposes a PDF is not ideal. We used the [`{pdftools}`](https://cran.r-project.org/package=pdftools) package to scrape the text from the PDF and, after a significant bit of wrangling ended up with a nice clean CSV file.

```
head(hcris_fields)

# A tibble: 6 × 6
  key type wksht_cd clmn_num line_num label                 
  <chr> <chr> <chr> <chr> <chr> <chr>                 
1 a7_1_c1_1 NUMERIC A700001 00100 00100 Land                  
2 a7_1_c1_10 NUMERIC A700001 00100 01000 Total                 
3 a7_1_c1_2 NUMERIC A700001 00100 00200 Land Improvements     
4 a7_1_c1_3 NUMERIC A700001 00100 00300 Buildings and Fixtures
5 a7_1_c1_4 NUMERIC A700001 00100 00400 Building Improvements 
6 a7_1_c1_5 NUMERIC A700001 00100 00500 Fixed Equipment       
```

## Resources

Here are the artefacts of this analysis:

- HCRIS record layout [(CSV)](record-layout.csv) and [(XLSX)](record-layout.xlsx)
- [PostgreSQL table definition](hcris-record-layout-postgresql.sql) and
- [MySQL table definition](hcris-record-layout-mysql.sql).
Agility is relative
Tags: agile, softwaredevelopment
Published: 2021-10-20 13:45:29

---
title: Agility is relative
published: true
date: 2021-10-19 00:00:00 UTC
tags: agile,softwaredevelopment
canonical_url: https://jhall.io/archive/2021/10/19/agility-is-relative/
---

I hear a lot of people talking about whether a company, a team, a practice, or an idea “is agile.”

“Spotify is agile.” “The database team is not agile.” Is trunk-based development agile?”

This is a lot like talking about whether a team, company, practice, or idea “is big.”

Agility only exists in relation to another thing.

Spotify, the database team, and pull requests cannot be agile in isolation.

They can only be agile in relation to something else.

Is Spotify more agile than Google? Could it become more agile than it is today?

Is the database team more or less agile than the frontend team? Can either team become more agile than they are now?

Would [trunk-based development](https://jhall.io/archive/2021/03/10/a-case-for-trunk-based-development/) be more agile than what we’re doing today? Could we do something else that’s more agile than trunk-based development?

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Automatically setting empty arrays instead of undefined on typeorm entities
Tags: webdev, javascript, database
Published: 2021-10-26 06:43:49

---
title: Automatically setting empty arrays instead of undefined on typeorm entities
published: true
date: 19/10/2021
tags: #webdev #javascript #database
canonical_url: https://darraghoriordan.com/2021/10/19/populating-empty-arrays-type-orm/
---

If you have an array on an entity model in typeorm you will have to handle the response when there are no items available to put in the array.

In my application I return the entity model directly for GET requests and I like having arrays as empty instead of undefined properties.

By default typeorm will not set the property to `[]` so it will be undefined.

Here is how to set an array property to have an empty array instead of undefined.

<!-- end excerpt -->
## Using type ORM After hooks

Type ORM has a number of hooks available that let us modify the model after certain actions.

The actions we care about are `@AfterLoad(), @AfterInsert(), @AfterUpdate()`.

To use them you decorate an async method with the action you want run when typeorm has completed the hook.

e.g.

```
@Entity()
export class CustomBot {
  @PrimaryGeneratedColumn()
  @ApiProperty()
  public id!: number

  @Type(() => Trigger)
  @OneToMany(() => Trigger, (trigger) => trigger.customBot, {
    onDelete: 'CASCADE',
  })
  @ApiProperty({ isArray: true, type: () => Trigger })
  @ValidateNested({ each: true })
  triggers!: Trigger[]

  // eslint-disable-next-line @typescript-eslint/require-await
  @AfterLoad()
  @AfterInsert()
  @AfterUpdate()
  async nullChecks() {
    if (!this.triggers) {
      this.triggers = []
    }
  }
}
```
Befunge GUI by Glimmer (2 for 1: LibUI & SWT)
Tags: ruby, gui, desktop, dsl
Published: 2021-10-18 23:29:54

In light of the recent [Beta release of Glimmer DSL for LibUI](https://dev.to/andyobtiva/glimmer-dsl-for-libui-beta-release-45j6), I have been looking for applications that could take advantage of its productivity and speed in building desktop GUI with its Ruby DSL. One such application has been [Befunge98 GUI](https://github.com/AndyObtiva/befunge98/tree/gui), built for a Ruby implementation of the [Befunge98](https://en.wikipedia.org/wiki/Befunge) programming language done by Victor Maslov (GitHub username: [Nakilon](https://github.com/Nakilon)).

According to Wikipedia, [Befunge](https://en.wikipedia.org/wiki/Befunge) is a two-dimensional stack-based, reflective, esoteric programming language. It differs from conventional languages in that programs are arranged on a two-dimensional grid. "Arrow" instructions direct the control flow to the left, right, up or down, and loops are constructed by sending the control flow in a cycle. It has been described as "a cross between Forth and Lemmings".

In fact, I built its GUI twice with two different approaches, one using the up and coming [Glimmer DSL for LibUI](https://github.com/AndyObtiva/glimmer-dsl-libui) on [CRuby](https://www.ruby-lang.org/en/) relying on a multi-canvas-grid ([LibUI area](https://github.com/AndyObtiva/glimmer-dsl-libui#area-api)) approach, and one using the very mature [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) on [JRuby](https://www.jruby.org/) by relying on a button-grid approach.

Thanks to [Glimmer's highly productive GUI DSLs](https://github.com/AndyObtiva/glimmer), both implementations took me no more than a few hours. In fact, they both took 5 minutes for the initial simplest version that received [Befunge](https://en.wikipedia.org/wiki/Befunge) input from GUI and rendered output to terminal. Afterwards, the simplest version was upgraded with bidirectional synchronization between the input grid and input multiline-entry/text field in addition to auto-saving/loading of the last program entered and a window-based output terminal or a read-only multiline-entry output control.

[Befunge98 GUI (Glimmer DSL for LibUI)](https://github.com/AndyObtiva/befunge98/tree/gui/gui/glimmer-dsl-libui/befunge98_gui_glimmer_dsl_libui)

![screenshot 1 libui](https://raw.githubusercontent.com/AndyObtiva/befunge98/gui/gui/glimmer-dsl-libui/befunge98_gui_glimmer_dsl_libui/screenshots/befunge98_gui_glimmer_dsl_libui_example.png)

[Befunge98 GUI (Glimmer DSL for SWT)](https://github.com/AndyObtiva/befunge98/tree/gui/gui/glimmer-dsl-swt/befunge98_gui_glimmer_dsl_swt)

![screenshot 1 swt](https://raw.githubusercontent.com/AndyObtiva/befunge98/gui/gui/glimmer-dsl-swt/befunge98_gui_glimmer_dsl_swt/screenshots/befunge98_gui_glimmer_dsl_swt_example.png)

![screenshot 2 swt](https://raw.githubusercontent.com/AndyObtiva/befunge98/gui/gui/glimmer-dsl-swt/befunge98_gui_glimmer_dsl_swt/screenshots/befunge98_gui_glimmer_dsl_swt_example_output.png)

Happy [Glimmering](https://github.com/AndyObtiva/glimmer)!
Where could I find some C++ that could help me?/Code critique.
Tags: cpp, gamedev, help, watercooler
Published: 2021-10-18 23:18:13

(Yes. C++ is my final destination programming language for RuntDeale. - It took forever, but I can say I really love C++, it's an amazing language.)

I'm just a(n almost) 15-year-old boy, so I don't really have money (I'm trying to get a job), and no one at my school really programs (the only class that I have some mates in is a "Beginner's JavaScript class" (which uses a specific dialect of JS).

So, is there anywhere I could find people who could help contribute to my game? It's open-source on GitHub: [RuntDeale Repository](https://github.com/CalinZBaenen/RuntDeale).

<hr/>

Also, if you'd like to go there, and talk about how I've sorted my code, particularly if you disagree, or have suggestions, or if I'm doing something wrong, let my know!

<hr/>

<h1><b>
Thanks!<br/>
Cheers!
</b></h1>
How much will it cost to hire a Flutter app developer?
Published: 2021-10-18 22:19:52

The fact that cross-platform applications are progressively displacing native applications has increased the market's demand for cross-platform app developers.
However, the primary question remains: "<a href="https://cerfy.net/flutter-developer/">How much does it cost to hire a professional flutter developer</a>?"

But first, there's this!

Why are cross-platform applications forging a new trend in the mobile app development market and causing a boom?

The following are some of the possible causes for the increased need for cross-platform applications:

Greater Market Reach: Cross-platform applications allow you to reach a larger audience.
Tired of bored buttons? Here you might have a solution...
Tags: vue, css, javascript, webdev
Published: 2021-10-18 22:19:22

I don´t know what you think about this, but at least I think that web buttons could be much more real than they actually are and this is why I decided to create [this vue component](https://real-button.elc0mpa.me/), which is a wrapper of Josh Comeau's 3d button. I hope you like it and if you think it could be improved please let me know. Remember to give it a star if you find it useful.... Regards
Vote: What should the behavior of `WeaponItem`s with a negative damage value do?
Tags: gamedev, cpp, watercooler, runtdeale
Published: 2021-10-18 22:02:24

I'm back!
I've been working on RuntDeale, and doing some personal things, I've also had some issues recently, but I hope to re-enter the DEV community!

I've set a vote, What should the behavior of `WeaponItem`s with a negative (attack) damage value do?
[You can vote on Twitter](https://twitter.com/BaenenCalin/status/1449960631050936321).
[And on Reddit](https://www.reddit.com/r/gamedesign/comments/qag3i3/what_should_the_behavior_of_weaponitems_with_a/)!

<h3>See you all in the next post, coming soon!</h3>
Setting up a webserver with php and async operations in docker
Published: 2021-10-18 21:55:51

---
title: Setting up a webserver with php and async operations in docker
published: true
description: I had to setup a docker image that could handle request in an API using async jobs to do the actual workload. This means that I had to have something running in the background async while also having a docker image with web server and php.
tags:
cover_image: https://i.ytimg.com/vi/mGF2KaeuFwk/maxresdefault.jpg
---

{% youtube mGF2KaeuFwk %}

I had to setup a docker image that could handle request in an API using async jobs to do the actual workload. This means that I had to have something running in the background async while also having a docker image with web server and php.
Day 474 : Get It Right
Tags: hiphop, code, coding, lifelongdev
Published: 2021-10-18 21:49:12

_liner notes_:
- Saturday : Had a pretty good day. Got the radio show ready and worked on my side project. Ended the night watching a Super Cat concert that was live streamed. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a photo of a throwback Atlanta Hawks basketball jersey customized for the group OutKast with 'kast on the front with the number 94 with the words Oct 16th 2021 2 is a coincidence, 3 is a streak](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwejlutakmvdcxc3uyvz.jpg)

- Sunday : Did my online study group thing. Everything worked well and got to work on my side project. Making some good progress. Then I watched the Big Daddy Kane and KRS ONE concert that was streamed online. Then I watch "The Walking Dead: World Beyond" and "The Talking Dead".

- Professional : Today I had a couple of meetings. My latest blog post was published. I did a couple of promo tweets. Spent the rest of the day looking over some API documents. Want to make sure I get it right.

- Personal : Been working on the settings page of my side project. Got it hooked up to a switch and local storage to set whether it is activated or not. That way, when the switch is loaded on a page it can be either set to active or inactive based on the value in local storage. Now I need to get it to where it will send the message to the service worker to whether or not send a notification.

![A log sticking out of the water with a small tree growing at the top in Fairy Lake, BC, Canada](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hn65zvy4cc24t8e92q9c.jpg)

Going to do some more work on my side project. Want to get the settings page sending messages to the service worker. Also want to get some other features added. Looking to end the night by watching an episode of "Squid Game".

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube BkZNbNkwCQs %}
Tuesday’s Tip – Level up your coding skills using code challenges
Tags: tuesdaystip, challenges
Published: 2021-10-20 13:40:37

---
title: Tuesday’s Tip – Level up your coding skills using code challenges
published: true
date: 2021-10-18 21:42:11 UTC
tags: TuesdaysTip,challenges
canonical_url: https://www.30minuteproject.com/2021/10/18/tuesdays-tip-level-up-your-coding-skills-using-code-challenges/?utm_source=rss&utm_medium=rss&utm_campaign=tuesdays-tip-level-up-your-coding-skills-using-code-challenges
---

Coding challenge sites are a great way for you to sharpen your skills or measure against your past progress. There are a variety of coding challenges, from simple puzzlers that force you to think outside the box to timed challenges that force you to get the correct answer within a specified amount of time.

 

The timed challenges can also be used by sites like TopCoders or Toptal when vetting potential freelancers.

Here are some of my favorites in no particular order:

- [Exercism](https://exercism.org/) - unique blend of exercises mixed with code reviews and mentoring
- [CodeWars](https://www.codewars.com/) - coding katas with other developers
- [Project Euler](https://projecteuler.net/) - a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve
- [CodinGame](https://www.codingame.com/start) - an actual game that forces you to write code to move troops, etc.
- [TopCoder](https://www.topcoder.com/challenges/?tracks%5BDS%5D=true&tracks%5BDev%5D=true&types%5B%5D=CH&types%5B%5D=F2F&types%5B%5D=TSK) - challenge site with recruiting
- [CoderByte](https://www.coderbyte.com/) - challenge site, language courses and interview help as well
- [HackerRank (30 Days of Code)](https://www.hackerrank.com/domains/tutorials/30-days-of-code) - 30 Day coding challenge, unlocking new challenges as you finish previous day
- [CodeChef](https://www.codechef.com/) - Challenge site with leaderboards and other courses
- [LeetCode](https://leetcode.com/) - Practice questions, challenges and interview help
- [SPOJ](http://www.spoj.com/) - Sphere Online Judge (got me ![😉](https://s.w.org/images/core/emoji/13.1.0/72x72/1f609.png) ), seems more focused on algorithm improvement
- [25 Puzzles and Brain Teasers](https://medium.com/techie-delight/top-25-programming-puzzles-and-brain-teasers-dac17b41e94a) - Great list of puzzles and brain teasers

**Cryptography challenges**

- [CryptoPals](https://cryptopals.com/) - good hands-on intro to crypto
- [id0-RSA](https://id0-rsa.pub/) - another good hands-on intro to crypto
- [Micro Corruption](https://www.microcorruption.com/login) - in order to learn more you need to break their security (I've heard this is very challenging)

Get your free ebook

"The 30-Minute Project: How to improve Your Side Project Game to Become a Better Developer"
at [30-Minute Project](https://www.30minuteproject.com/contact/)
Snake game
Tags: python, oop, gamedev, beginners
Published: 2021-10-18 21:38:40

Snake has been the game of my childhood, I still remeber playing it on my first mobile phone, a nokia 1100. I always missed palying that original choppy version of it so I wanted to reacreate it. 
Taking the cs101 course on codecademy helped me start my career as a junior developer, and one of the first few project I wanted to make was a simple game. That's when I found a couple of turorial online on how to create games using pygame, which is the module that I decided to use. To my shame it took me much longer than expected to actually create it, even with following a tutorial as it took me a while to understand OOP, what classes and objects are and how they actually work. Now I think I have a decent understading of it. 
If anyone would like to have a look, please see the link below 

https://github.com/andrei-paicu/Snake