teleren/devto huggingface dataset:
Why limit function size?
Tags: goodcode, pattern, practice, computationalthinking
Published: 2020-10-20 14:03:12

I've always thought this was stupid. Not that long functions are good, but an arbitrary, artificial limit misses the point of smaller functions and encourages "procedural program page 2" type functions. That is, until I was talked with a developer I really respect about it. He said that in the 80's his limit was 24 lines. Today, it's more. 

He explained that his limit to function size is the number of lines that fit on a screen. The argument being that one developer can only hold one screen's worth of information in their head at one time.

# Line limits as a complimentary philosophy

I realized through our conversation that I was hoping that a line limit would teach problem decomposition. I now believe that decomposition and line limits must be taught in parallel.

Without decomposition techniques, line limits *do* devolve into "page 2" type functions - functions which don't abstract anything, but are simply continued on "page 2." This doesn't mean that line limits are bad. Test driven development is the same way. 

TDD must be paired with understanding about how to support refactoring and how to design from the outside in. Experience with the rigid structure of TDD without true regard for its purpose builds strong resentment for the paradigm.

# As a guide for abstraction

Every line of code adds one point of complexity and every level of abstraction adds 10. It's not that abstraction shouldn't happen, but consider whether you are hiding things you'll care about when you go back and read your code. Line limits give us some idea for how far to abstract things. You don't need to jump to a new method every line, but you should only care about what's happening in your code at a level that fits on one screen. Then if you need to know how a certain portion of your routine works in a more fine grained way, you're free to drill into that area of code.

# Where to go from here
1. Find out what your line limit is. Go to your IDE and check how many lines fit on a screen.
1. Research "computational thinking." I mentioned program decomposition and abstraction in this post. These are two of the four principles of computational thinking.
Free Website Pinger - Aliver
Tags: replit, webdev, node, javascript
Published: 2020-10-20 13:40:38

Free Website Pinger (Monitoring) with 1 min interval | How to keep your repl.it projects alive for free | Website pinger | Aliver


Hi, Do you want to keep your repl.it and others projects alive for free? Use aliver.

**Aliver: https://aliver.ml**
**Forum: https://forum.aliver.ml**


**Features:**
- Login & register system (passwords are encoded, so i don't see it)
- Nice Dashboard
- Actual url status
- Api with check and badge endpoint (You can check actual status of website and get svg badge)
- More features are coming soon! (If 50 links will be added i will start adding new features)


![Screenshot](https://dev-to-uploads.s3.amazonaws.com/i/0ht8qrks4y78qdjsnr10.png)

![Screenshot2](https://i.ibb.co/9njdPqc/image.png)
How can we apply pseudo-class on a single line without CSS?
Tags: html, css, javascript, pseudo
Published: 2020-10-20 13:39:13

Hello everybody,
I've learned how to apply pseudo-class by using CSS style.
For example,
<style>
a: hover {color: green}
</style>
.
My QUESTION:-
How can we apply pseudo-class like (hover, focus, active, visited, link) on a line WITHOUT CSS?
For example, on the following tag:
<a href="000 .com">
Is there a tag, atribute, value ...! How?
Get More Done Using a Hack Learned from Twitch Streamers
Tags: productivity, sideprojects, startup
Published: 2020-10-20 13:37:26

I've noticed that **reducing any friction** on my side project is a **HUGE** productivity boost.

Reducing the number of steps to get to the actual coding part is critical, especially when tackling small tasks.

I found a simple way to launch my side project with the push of one button. 

Now when I want to work on my side project, all I have to do is **press one button** and my dev environment spins up and my project builds automatically. 

.



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

I learned this trick from Twitch streamers.

Some streamers use a device called a Stream Deck. It's a small hardware device that lets you launch macros with the push of a button.

Streamers use these to display certain graphics, apply sound effects, and more in their streams.

I found that El Gato, the maker of the stream deck, also publishes an app version of the stream deck. 

**I've started using it in my dev workflow and have found it to be great productivity boost for me. **

Here's a link to the [El Gato Stream Deck app](https://www.elgato.com/en/gaming/stream-deck-mobile) for anyone curious.

You can set up different commands, macros, etc, and control your computer through the app. 

I have a variety of shortcuts set up. 
![Imgur](https://i.imgur.com/B9idxLc.png)
- The green staircase opens a folder with various commands for starting my project Deliberate Python. 
- The owl is a folder with commands for my day job project.
- GH is a shortcut that types my github URL.
- LI is a shorcut that types my LinkedIn URL.
- Stack overflow, github, notion, and hacker news are all shortcuts as well. These buttons open a browser and navigates to those URL's 



## How I used to get started on adding features to my project:

1. Open terminal
2. Navigate to my project
3. `code deliberatepython/front-end`
4.  run `npm start` in vs code
5. Switch over to another desktop so I can open the backend code in that workspace
6. Go back to terminal
7. `code my_backend_project`
8.  `pyenv shell deliberatepython`
9. `uvicorn sql_app.main:app --reload`


## Using the Stream Deck app
1. Press the Front-end button on the stream deck app and let it complete all the front-end steps
If I need the backend spun up, then I just:
2. Press back-end button on the stream deck app and let it complete all the back-end steps.

I've noticed that I'm able to work on small features easier when I only have 10-20 minutes here and there using this system. It's been such a big productivity boost.
What's a webring
Published: 2020-10-20 13:36:24

Everyday we can learn new things if we search read and try to do something new.

Today when I'm doing my daily challenge. I found codepen webring challenge in the trending section.

To be honest I didn't understand what's this?! so after search and read some articles and check many pens. I understood. 

I want to write this article to share my knowledge with you.

**What's webring?**

A webring is a group of websites that are linked together and, generally, are all related by a common topic. you can click through the website to another one that is part of the ring. and if you continue clicking through to next website in the ring you'll return to the site at which you started

**Uses of a webring**

- Making research easier

  There's no need to go back and back again to a search engine to find more resources on a topic. you can discover additional sites that may be of interest to them.

- Increasing traffic to your website

  Traffic to your website helps to improve your rank which in turn generates more traffic, but you want to make sure that the increase in traffic is associated with an increase in engagement as well. If your traffic is increasing but your conversion rates are decreasing, you’re not bringing in the right traffic. so you need to add the related site to make the user as long as time on site that'll increase traffic, and if you introduce useful sites.

**Note** This circular structure is where the ring in the webring comes from.

Here's my project. I'm going to add next, previous and random buttom 

{% codepen https://codepen.io/EsraaNasr/pen/mdEELBR %}

More information about [webring](https://en.wikipedia.org/wiki/Webring)
Real Estate Image Editing and HDR Blending Services
Tags: imageeditingservices, photoeditingservice, imageeditingcompany, realestatephotoediting
Published: 2020-10-20 13:34:05

Looking for the best Real Estate Image Editing Services and HDR blending services online?

You can always rely on image editing agency for high-quality professional images with our real estate photo editing services. We have a bunch of professional photo editing artists who are experts in any kind of photo retouching services. Our customer support is quick to respond for any inquiries and other communications. 

Check: https://www.imageeditingagency.com/real-estate-main.html
Popular Online Video Chat Alternative Websites 
Tags: onlinechat, freechat, videochat
Published: 2020-10-20 13:31:42

Video-talk is the best website as an alternative to the Bazoocam site so, try out some features and facilities in video chat like the Bazoocam Chatroulette website via using this video-talk ( https://video-talk.net/ ) website. Here we share also some more examples of alternative chat websites so, you will get a better idea about online random video chatting websites. we recommend you please visit the official website of chat for more information because here we share only a little bit of information. 

Ome tv website is a also Good choice as an Omegle alternative ( https://ome-tv.net/ )website. Here we share talk about only alternative best because Chatroulette and Omegle are very popular website and everyone know that website that's why we share this alternative site so, that may be helpful for you for finding an omegle and bazoocam alternative type website. 


Now the Last one is a Coomeet alternative website that name is a Chatcam ( https://chatcam.site/ ) yes friends if you are a regular user of Coomeet chat then try out something new platform that is the same as a coo-mmet but only platform different. In the chatcam all the features get like gender filter, location filter, language filter, and a lot of features and facilities you will get like coomet chat. 


So, thank you for reading this alternative famous chat website. Start free chat start with stranger people from any time at any location via these popular online dating platform.
LINQ gems: Zip
Tags: csharp, dotnet, linq
Published: 2020-10-20 13:30:34

I'm always fascinated by how simple yet helpful LINQ queries are.

Take for example the [Enumerable.Zip()](https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.zip) method. It's simple, yet very useful in case you need to **combine two sequences of data**. 

Here's a partial example where Zip() is used to combine a sequence of original text resources with their translations (produced for example by the [Google Cloud Translation API](https://cloud.google.com/translate/docs)):

```c#
public IEnumerable<(ResourceText text, string translation)> 
    TranslateResourceTexts(IEnumerable<ResourceText> resourceTexts)
{
    // Grab just the strings to translate
    IEnumerable<string> strings = resourceTexts.Select(t => t.Text);

    // Translate the strings (call Google Translate V3 API)
    IEnumerable<string> translatedStrings = TranslateStrings(strings);

    // Combine the two sequences, producing an enumerable of tuples 
    // containing both the original resource text and its translation
    return resourceTexts.Zip(translatedStrings, (text, translation) 
                             => (text, translation));
}
```
Simple and easily readable. 

As with most of the LINQ functions, I could of course accomplish the same with a *for* or *for each* loop and a few extra lines of code. However, in most cases, I consider the use of LINQ syntax a cleaner alternative.

Final notes:

- The Zip() method can only be called using the [LINQ method syntax](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/query-syntax-and-method-syntax-in-linq), there's no query syntax option for it.
- It is available starting with .NET Framework 4.0.

---
If you find this post interesting, be sure to check out other posts on my blog [mydevtricks.com](https://mydevtricks.com).
🤦‍♂️ Weekly Fail (43/2020)
Tags: networking, server, kentico, xperience
Published: 2020-10-20 13:26:38

There's always a battle between System Admins who want everything locked down, and Devs who want everything open. One fine day (shortly before launch of course) , our client was having their environment set up for Kentico MVC.  We finally had it all going, the database copied and Kentico set up, but we were running into a weird issue.  The Contact form was acting funny and not submitting on the new live environment.  There was no event log errors to go off of, it just didn't work.  After digging through the component source, finally we realized what the issue was: They disabled outbound internet connection, which means ReCaptcha couldn't verify the result with Google, and it was silently blowing up.  The client had mentioned earlier if it was okay to block outbound traffic, it slipped my mind.  Had I thought further on the implications of this, I probably wouldn't have spun my wheels for the couple hours.

*Lesson learned:* **There is a delicate balance of securing a server, and constricting the life out of it.  You should definitely weight out the risks and benefits, and be aware that if they want it locked down, you'll need to be fully aware of what firewall rules, ports, and other things you'll need for things to work properly.**
Native Apps is the Future of Blazor
Tags: dotnet, csharp, javascript
Published: 2020-10-20 13:24:54

Blazor app happens to be new. It is so new that it is just a beta preview in the most recent .NET Core version. The initial release of Blazor has been scheduled for May this year.

However, despite this innovativeness, Microsoft is planning Blazor’s future already. Microsoft, in their latest .NET Conf event, has revealed plans which might bring Blazor to native applications. For a platform that is already taking over the whole JavaScript world, this is an optimistic plot twist. However, it could just work for devoted developers of .NET.

 
The Universal UI Quest

.NET developers are vying for a way of creating a cross-platform user interface for ages. This implies being able to create a single front end in a dream fantasy environment that fits with web, desktop as well as smartphone applications.

The most advanced desktop development toolkit of Microsoft and its solution for Native mobile app development are similar in design. The user interface is specified employing the XAML markup standard. Both rely on linking data and supporting the MVVM pattern. However, there are issues, despite these similarities. WPF has closely related to DirectX as well as the Windows operating system’s other core components. And even though WPF and Xamarin merged, the XAML-based user interface and the HTML markup on the site are unacceptable.

There have been attempts to fix the issues, but the official aspect of the platform funded by Microsoft is nothing. Google’s got its toolkit named Flutter. However, Microsoft has a difference between smartphones, laptops, and online environments.

 
A Blazor Background

Here’s a fast recap in case you’re not up to Blazor app yet: Blazor happens to be the name for a couple of different technologies that allow you to build browser-based apps running .NET code.

The initial – and a little advanced – is Blazor Server technology, which acts like an old-fashioned console. The browser is in continuous touch with the web server, which is running the .NET code.

The server just returns updated HTML bits, so that after every single event the browser is going to refresh the page. Blazor WebAssembly is the second software that smuggles a small .NET runtime into the application and that is used to run code # rather than JavaScript. This happens to be the Blazor app which has generated all the enthusiasm.

Suppose Blazor WebAssembly gets its full release and is doing everything it says on the tin — i.e., offering .NET developers a technique of running C# in their browsers. This is pretty impressive. Where should Blazor go next, however? Microsoft continues to indicate that many of its experimental ventures are no longer just trials. The first instance happens to be Blazor desktop apps.

Learn more here: https://www.rlogical.com/blog/native-apps-is-the-future-of-blazor/
Escape the Loop; Terms and Conditions
Published: 2020-10-20 13:24:05

# Escape the Loop by Mozilla Club of UCSC
-----------------------------------------------

<b>We urge you to carefully read the terms and conditions of this page before entering the contest.</b>

<b>Contest Name: </b> Escape the Loop Hackathon<br>
<b>Entry Period: </b> The Contest begins on October 22, 2020 at 0:00 AM GMT +5.30 and ends on October 26, 2020 at 11:59 PM GMT +5.30 (the "Entry Period") <br>
<b>How to Enter: </b> All entries must be submitted no later than the end of the Entry Period. You may enter the Contest during the Entry Period as follows:
1. Visit the Contest announcement part of the DEV Community Site located <a href="https://dev.to/ucscmozilla/announcing-escape-the-loop-the-hackathon-3o45">here</a>.
2. Follow any instructions on the Contest Page and submit your completed entry (each an "Entry").
3. After publishing the post on Dev Community, the participants must fill the form on <a href="https://go.ucscmozilla.com/escapetheloop">Escape the Loop official website</a> as well.
4. All the teams should participate in the pitching session after the deadline. Any team who fails to participate will be disqualified.  <br>

-----------
* A Team should consist of no more than five (05) members and all the members of the team should be undergraduates of University of Colombo School of Computing.
* Late submissions will not be accepted under <b>any</b> circumstances.
<br>

<b>Required Elements for Entries: </b>Each Entry must include, at a minimum, the following elements: 
1. A published submission post on DEV in the `#escapetheloop2020` tag (we encourage you to use <a href="https://raw.githubusercontent.com/UCSC-Mozilla-Club/Escape-The-Loop-Template/main/Template.md">this</a> template).
2. The post must include links to your demo and code repository.
3. The code repository, the project must include a README and an <a href="https://choosealicense.com/">open source license</a>.

#### The judges' decision is final and no correspondence will be entered into.
-----------------------------

Mozilla Club of UCSC
University of Colombo School of Computing,
Colombo, Sri Lana
Understanding and Solving CORS and CORS Errors (Express Snippets)
Published: 2020-10-20 13:09:47

## Explanation

Watch this video where I explain what CORS errors are and their solution in concept.

[![CORS ERRORS](http://img.youtube.com/vi/fsMKB7PJoFY/0.jpg)](http://www.youtube.com/watch?v=fsMKB7PJoFY "CORS ERRORS")


## CORS IN EXPRESS

Refer to the code below to address CORS issues in Express, although my express template already has cors configured if you want to use it as your starting place.

```npx merced-spinup expressrest projectName```

```js
// +& CONFIGURING CORS IN EXPRESS 
// +* INSTALL CORS MIDDLEWARE - npm install cors 

// +% CREATE YOUR CORS CONFIG OBJECT 
// +! Whitelist are URLS allowed to make requests to API
const whitelist = ['http://example1.com', 'http://example2.com']
const corsOptions = {
  origin: function (origin, callback) {
    if (whitelist.indexOf(origin) !== -1) {
      callback(null, true)
    } else {
      callback(new Error('Not allowed by CORS'))
    }
  }
}

// +% ADD MIDDLEWARE TO EXPRESS
// +! USE TERNARY OPERATOR TO TOGGLE BETWEEN ALLOWING ALL SOURCES AND WHITELIST
app.use(NODE_ENV === production ? cors(corsOptions) : cors())
```
How to pass URL and query parameters in Spring REST template?
Tags: spring
Published: 2020-10-20 13:04:14


Using exchange() method of Spring REST template you can easily pass both URL and query parameters at the same time .

Here is how to do it:

https://fullstackdeveloper.guru/2020/10/20/how-to-pass-url-and-query-parameters-in-spring-rest-client/
Code Smell 01 - Anemic Models
Tags: codenewbie, oop, beginners, computerscience
Published: 2020-10-20 13:03:23

*Your objects have no behavior.*

> TL;DR: Don't use objects as data structures

Protocol is empty (with setters/getters).

If we ask a domain expert to describe an entity he/she would hardly tell it is *'a bunch of attributes'*.

# Problems

- No Encapsulation.

- No [mapping](https://dev.to/mcsee/the-one-and-only-software-design-principle-3086) to real world entities.

- Duplicate Code

- [Coupling](https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7)

- Writer / Reader mismatch.

# Solutions

1) Find Responsibilities.

2) Protect your attributes.

3) Hide implementations. 

4) Delegate

# Examples

- DTOs

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/73f84d80f7c3e89a216dd9e40ab71bcc)
```php
<?

class Window {
    public $height;
    public $width;

    function getHeight() {
        return $this->height;
    }

    function setHeight($height) {
        $this->height = $height;
    }

    function getWidth() {
        return $this->width;
    }

    function setWidth($width) {
        $this->width = $width;
    }

}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/78f2dd78120db843c960ed41839f29cb)
```php
<?

final Class Window{ 
  
  function area(){
    //...
  }
  
  function open(){
    //..
  }
  
  function isOpen(){
    //..
  }
  
}
```

# Detection

Sophisticated linters can automate detection.
They should ignore setters and getters and count real behavior methods.

# Also Known as

- Data Class

# Tags

- Anemic
- OOP as Data
- Encapsulation
- Setters/Getters
- Mutability

# Conclusion

Avoid anemic models. Focus always on protocol instead of data. 
[Behaviour](https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7) is essential, data is accidental.

# Relations

{% post https://dev.to/mcsee/code-smell-28-setters-2hih %}

{% post https://dev.to/mcsee/code-smell-15-missed-preconditions-7c3 %}

# More info

- [Wikipedia](https://en.wikipedia.org/wiki/Anemic_domain_model)
- [Refactoring Guru](https://refactoring.guru/es/smells/data-class)
- [Nude Models — Part I : Setters](https://dev.to/mcsee/nude-models-part-i-setters-5c9i)
- [Nude Models — Part II : Getters](https://dev.to/mcsee/nude-models-part-ii-getters-3f2a)
- [How to Decouple a Legacy System](https://dev.to/mcsee/how-to-decouple-a-legacy-system-30ke)

* * *

> Object-oriented programming increases the value of these metrics by managing this complexity. The most effective tool available for dealing with complexity is abstraction. Many types of abstraction can be used, but encapsulation is the main form of abstraction by which complexity is managed in object-oriented programming.

_Rebecca Wirfs-Brock_

{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

# Credits

Photo by Stacey Vandergriff on Unsplash

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}

*Last update: 2021/05/30*