teleren/devto huggingface dataset:
Many classes and many layout files
Tags: java, android
Published: 2019-11-20 00:20:52

What is better to have a main activity class interacting with many other classes and xml files or a main activity class with many xml files?

For example in my case I have username, password,date,email in different classes and xml files and the same for the main activity.ia there a way to manage it better? ( I need the xml files to be like that, I don't know about Java classes much)

Thank everyone
You need to write CSS like that to improve your code quality 🧐
Tags: css, codequality, discuss
Published: 2019-11-20 00:03:14

Hi everyone. This is my first post in DEV 🥳
I'm from Argentina and i'm currently working at [Aerolab.co](https://aerolab.co) ❤️ as a UI dev.

### This post will be about how to write better CSS ([TL;DR](#solution))

## The problem 🙈

- Unorganized properties in a CSS selector
- Sometimes, every developer write code according their own rules and preferences
- Hard to maintain
- Code smells
- Bad code quality

## Approach 👀

- Organize the CSS properties
- Separate CSS properties into categories

```css
/* Concept */
.selector {
  /* layout */
  /* position and dimensions */
  /* margin and padding */
  /* box enhancements */
  /* font enhancements */
  /* others */
}
```

## Advantages 🙌

- Better readability across devs and teams
- Avoid possible redundant code
- Easy refactoring
- Easy to find some property
- Easy to explain
- Better code quality

## Examples

### The wrong way 🤢

The following is a really bad example, it works of course, but you need to avoid this type of code because it is hard to read and maintain. When you write code like this you are dropping the quality of your code and **you are spreading bad practices to your teammates.**

```css
/* Avoid coding like this*/

.myBadClass {
  font-family: sans-serif;
  font-size: 22px;
  background-color: silver;
  border: 1px solid gray;
  box-shadow: 0 0 3px 20px black;
  display: flex;
  margin-right: auto;
  margin-left: auto;
  padding: 20px;
  margin-bottom: 30px;
  overflow: hidden;
  width: 100%;
  height: 50px;
  top: 0;
  border-radius: 7px;
  flex-direction: column;
  justify-content: center;
  cursor: crosshair;
  align-items: center;
  color: black;
  line-height: 1.5;
  position: relative;
}
```

<a name="solution"></a>

### The best way 😎 

The following is a better way to write CSS, because it is better structured and easy to read. **Just start proposing good practices so that your teammates also acquire them.**


```css
/* Do this way */

.myGoodClass {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  
  position: relative;
  top: 0;
  width: 100%;
  height: 50px;

  margin-left: auto;
  margin-right: auto;
  margin-bottom: 30px;
  padding: 20px;

  background-color: silver;
  border: 1px solid gray;
  border-radius: 7px;
  box-shadow: 0 0 3px 20px black;
  
  font-family: sans-serif;
  font-size: 22px;
  color: black;
  line-height: 1.5;
  
  overflow: hidden;
  cursor: crosshair;
}
```

If you have a small set of properties you can following the same pattern. Follow the example below.


```css
.myOtherGoodClass {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  color: black;

  overflow: hidden;
}
```

## Feedback 👂

- What do you think about this practice?
- How do you write better CSS?
- Are you considering apply this on future projects?
- If not agree whit this pattern. Why?
- Any other way to keep writing better CSS?

Have a good week! and Thanks for reading 🙂
Day 37 : Why O Why
Tags: hiphop, code, coding, lifelongdev
Published: 2019-11-20 00:02:27

_liner notes_:
- Professional : Had a meeting with my manager this morning. I think it went well. I'm going to be collaborating with other developers in different fields/languages on the Client SDK. Looking forward to it. Also did some work on my current application. Ran into an issue which I believe stems from the node server not refreshing so changes to the files don't get updated and the information sent is invalid. I asked team members in Slack and got some good leads. Also got some really good suggestions on improving the code. Spent the rest of the day putting together a presentation of the real time poll app I created before.

- Personal : So, I got my Google Stadia code today. I haven't gotten my actual controller yet, but I signed up so I could reserve my username. I'm not really into gaming, but I find the technology behind it interesting. For the rest of the night, looking to go through some tracks for the radio show and maybe hook into some events to show and hide certain elements in the personal project I'm working on.

![coastal city Hallstatt, Austria between the sea and mountains](https://thepracticaldev.s3.amazonaws.com/i/py65zhjbv0sybjg9jpzs.jpg)

Tomorrow, I have an introduction meeting with a team member. There's a Slack bot that randomly pairs up team members so we can get to know each other better. I also want to get this CLI project worked out. Why O why doesn't it just work! haha

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube m04JgA9NGGQ %}
HOC pattern in Vue.js
Tags: vue
Published: 2019-11-19 23:55:58

After doing some research (google) I found it is possible to do HOC pattern in Vue.js. Anyway, I present you here my introduction to it, although you can find it [here](https://pusher.com/tutorials/higher-order-components-vue) too.
So the HOC pattern consists in that you can do `const CompWithThis= withThis(Comp)` and also `const CompWithThisAndThat= withThat(CompWithThis)` and so on. 
In this case `withThis` and `withThat` are HOC's, that is, higher-order components, which are functions that accepts a component as an argument and return another component.
Let's see the definition of `withThis` and `withThat`:
```javascript
import Vue from 'vue'
import s from 'vue-styled-components'
const Div=s.div`
`

export default
C=>
Vue.extend({
  data(){
    return {
      d:1
    }
  },
  render() {
    return (
      <Div>
        <div>this is withThis:{this.d}</div>
        <C/>
      </Div>
    )
  }
})
```
and
```javascript
import Vue from 'vue'
import s from 'vue-styled-components'
const Div=s.div`
`

export default
C=>
Vue.extend({
  data(){
    return {
      d:2
    }
  },
  render() {
    return (
      <Div>
        <div>this is with that:{this.d}</div>
        <C/>
      </Div>
    )
  }
})
```
As you can see they are pretty much the same. They take a component (`C`) as an argument and return a component which renders `C`.
Now let's see a simple component:
```javascript
import Vue from 'vue'
import s from 'vue-styled-components'
const Div=s.div`
`

export default Vue.extend({
  data(){
    return {
      d:0
    }
  },
  render(){
    return (
      <Div>this is ein:{this.d}</Div>
    )
  }
})
```
So we have this component, `Ein`. Now let's apply the higher order components to `Ein` and let's see the output:
```javascript
import Vue from 'vue'
import s from 'vue-styled-components'
const Div=s.div`
font-family:sans-serif;
`
import Ein from './ein'
import withThis from './withThis'
import withThat from './withThat'

const EinWithThisAndThat= withThat(withThis(Ein))

export default Vue.extend({
  render(){
    return (
      <Div>
        <EinWithThisAndThat/>
      </Div>
    )
  }
})
```
Previous was component `App`. Let's see `main.js` file which uses `App`:
```javascript
import App from './components/app'

new App({
  el:'#app'
})
```
The output of this in the browser will be:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9s61nnk8vv5m6471n7cg.png)
Murrett Virus
Tags: codepen, html, css, javascript
Published: 2019-11-19 23:34:30

<p>This is a game based on a story I had wrote a few weeks back. This game is currently being developed by only myself, meaning this game will take a while to complete and is in progress. Let me know what you guys think of it so far!</p>

Check it out here!: https://codepen.io/EternityFound/project/live/DaJWrM

<h1>Update (Alpha V.1.4)</h1>
<p>- Added “Under Construction” pages for Help/Controls and Settings in Main Menu.</p>
<p>- Fixed grammar and spelling errors.</p>
Advice for an Aspiring Web Developer New to Coding?
Tags: beginners, help, webdev, career
Published: 2019-11-19 23:08:21

For the past five years I've been working jobs I could easily get, which have all been in call centers, and I've mostly hated it. After quitting my most recent job, I was talking to my parents and they offered to help me out while I worked to move into a career I'd actually enjoy. So I've been learning web development on my own, and I'm really enjoying it so far. 

But my parents can't afford to support me forever, so I'm trying to find the most direct route to a job that I can while continuing to learn on my own (I don't feel ready to commit to a bootcamp or CS degree right now. I do have a college degree, but in History). 

I assume I can clear the minimum bar for front-end more quickly than back-end, so my plan is to focus on front-end right now and learn back-end stuff once I already have a job. But I'm not sure if that is a correct assumption or a good plan. If I were less concerned about time, I would learn the basics of both front-end and back-end now and pick whichever I enjoy more.

Whether I go for front-end, back-end, or full-stack, I'm pretty sure I don't have the minimum skill set necessary to realistically find a job right now, so I'd like to know what actual web developers think are the minimum qualifications I would need before a job search would even be worth my time.

So, I would be super grateful if anyone could give me their opinions on the following questions: 
1. Is my assumption correct that I can (probably) get into front-end more quickly than back-end, and if so, is it a good plan to focus first on learning the minimum necessary requirements to land a front-end job? If not, what advice do you have for choosing a specialty?
2. What are the minimum hard skills I need to have and how proficient do I need to be in each of them? 
3. What (if any) soft-skills do you consider must-haves for entry-level developers?

Even if you don't answer all of those questions (or even any of them), any feedback, solicited or not, would be greatly appreciated.

Thank you!
Tribute Page
Tags: codepen
Published: 2019-11-19 22:47:03

<p>My Tribute page designed and created only with HTML and CSS as a solution for Tribute page challenge on free codecamp.org challenge.
Princess Diana, is one of the female activist I look up to, her life and the way she lived her life really inspired me .
The Page is still under development and I will continue to update the design the more i get inspiration and creative in web design.
Any good suggestion,idea or advise to make this site more nice will be appreciated.</p>

{% codepen https://codepen.io/kemiey/pen/WNNLPGd %}
Two CSharp idioms
Tags: beginners, csharp, tutorial
Published: 2019-11-19 22:25:55

You have heard about Pythonic code? Languages have an expressive or "native" way of doing things. But, what about C#? Is there C-Sharpic code?

In this series of posts, I wil attempt to present some idioms or "expressions" to write more expressive C# code. I collected these idioms after reviewing code and getting mine reviewed too.

In this first part, you have two useful C# idioms on conditionals and its alternative solutions.

## Instead of lots of or’s, use an array of possible values

Use an array of known or correct values, instead of a bunch of comparison inside an `if` statement. You can find this code when checking preconditions or validating objects.

Before,

```csharp
if (myVar == 2 || myVar == 5 || myVar == 10)
    DoSomeOperation();
```

After,

```csharp
var allowedValues = new int[] { 2, 5, 10 };
if (allowedValues.Any(t => myVar == t))
    DoSomeOperations();
```

If you need to check for a new value, you add it in the array instead of adding a new condition in the `if` statement.

## Instead of lots of `if`'s to find a value, use an array of `Func`

Replace consecutive `if` statements to find a value with an array of `Func` or small choice functions. Then, pick the first result different from a default value or `null`. You can find this code when finding a value among multiple choices.

Before,

```csharp
var someKey = FindKey();
if (someKey == null)
    someKey = FindAlternateKey();
if (someKey == null)
    someKey = FindDefaultKey();
```

After,

```csharp
var fallback = new List<Func<SomeObject>>
{
    FindKey(),
    FindAlternateKey(),
    FindDefaultKey()
};
var someKey = fallback.FirstOrDefault(t => t != null);
```

Also, you could take advantage of the **Null Coleasing Operator** (??) if these choice functions return `null` when a value isn't found.

```csharp
var someKey = FindKey() ?? FindAlternateKey() ?? FindDefaultKey();
```

Similarly, if you need to add a new alternative, either you add it in the array or nest it instead of adding the new alternative in the `if` statement.

Voilà! These are our first two idioms on conditionals. I have found these two idioms more readable in some scenarios. But, don't start to rewrite or refactor your code to follow any convention you find online. Make sure to follow the conventions in your own codebase, first.

_Happy coding!_
Material Expander : Open from code
Tags: angular
Published: 2019-11-19 22:02:12

```<mat-expansion-panel [expanded]="expanded">```

Then in your Typescript code create a variable named expanded. Set it to true when you want the panel to open

 ![expander](https://thepracticaldev.s3.amazonaws.com/i/puko61jnrjtlobd1p6yb.PNG)
Networking is Not Working: Why it's failing you
Tags: watercooler, career
Published: 2019-11-19 21:44:52

What I recall is something like "talk to people because you might need them later".

> **networking**  /*ˈnetwərkiNG*/
> *noun*
> 1.  the action or process of interacting with others to exchange information and develop professional or social contacts.

If I recall correctly, the way networking was explained to me was very similar to the definition above. This is what is so very wrong. It sounds selfish, self-serving, and narcissistic. Other people are not there for your use. 

I realized a while ago, it's best to just build relationships. Ask people about the things that matter to them. (If you see me around, ask about my pets). The point is, networking is good, but you need to care about other people. If you're at a networking event, talk to people. Ask them about what they do for work, what their hobbies are, or maybe about the weirdest thing they know. 

Networking is more than just exchanging business cards and contact info. For example, I've made good friends at [Venture Cafe](http://venturecafewinstonsalem.org/), a weekly networking event. All of the attendees always seem to desire to help each other and learn about each other.

Last month, I read [“Networking is the best insurance policy”](http://entm.ag/8i61) in  Entreprenuer magazine. [Jordan Harbinger](https://twitter.com/jordanharbinger) wrote about how he was pushed out of his own business and how he used his network to get back on his feet. There were two big things that stood out to me in this article. 

> something an old colleague said. He described networking as “digging the well before you’re thirsty” -- that is, constantly cultivating trust and loyalty with the people around you, with no immediate expectation of return.

I'd like to add that building relationships is best done when you have no expectation for return.

>Every day, I text four people from the bottom of my text message inbox to reconnect. “Hey! Been a while,” I’ll write. “What’s the latest with you?” We rekindle our connection, and I try to spot an opportunity to be of service.

I would personally find this to be very draining on my social resources, but I think it has a great foundation.
HOW TO PREVENT ACTIVITY FROM RESTARTING WHEN PHONE IS ROTATED
Tags: android, kotlin, java
Published: 2019-11-19 20:50:50

I was working on android contact application where the add-contact form/context is a fragment on the main activity. 

The features on the application were working fine until I tried it on rotation and found out that while on the add-contact-fragment, the main activity re-creates which causes the fragment to appear on the main activity(i.e activity_main.xml) as seen in the picture below

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/cxov346tze4sqxergzkp.png)

I started searching on the web for possible solutions and was trying out a whole lot of responses to related problem.

I finally stumbled over the succinct and helpful response and I am excited to write my first blog with a little explanation of how to solve this problem.

The details follows below:

Just handle the configuration on your manifest with the code below!
```
<activity
      android:configChanges="orientation|keyboardHidden|screenSize"
</activity>
```

and thats all.

I do not want to bore you with too much details on this, the summary behind the change is that activity is being recreated on rotation, on keyboardhidden or screensize change and to prevent that use the code above in your manifest.xml file

However, if you are more curious you can dive into more details [here](https://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange) 


Thanks.
What do you do to stay productive?
Tags: discuss
Published: 2019-11-19 20:47:16

I'm worried about my mental health, but I'm also worrying - and I feel like I'm not alone - that I am not doing enough. 

We were all sold the idea that we should be productivity machines, working all hours and building the future. However, we forget to take care of our mental health in this process. Hours that should be labeled 'me time' becomes 'learning time' and we find it very hard to make that distinction.

I work 8 hours of my day and I want to make the most of it. So, what do you guys do to stay productive and always on top of your game, without sacrificing 'me time'?
One-line pause function in plain Javascript
Tags: javascript, scheduler, async
Published: 2019-11-19 20:38:01

This is first post in series, explaining how to build a plain javascript code scheduler. Schedulers are mandatory tool to periodically fetch the data from an API. Something needs to control at what point in time the requests are to be made. Purpose of the series is to prove that it can be done in a couple of lines of plain Javascript.


To keep it short, this post only deals with a simple pause function:

```javascript
const pause = time => new Promise(resolve => setTimeout(resolve, time))
```

*pause* function returns a Promise when called. The Promise itself resolves after a specified amount of time, giving us the ability to chain some piece of code and delay it. Sort of a flow control mechanism for code execution.

If we imagine having a working implementation of **fetchData** function we can delay it for 2 seconds like so:

```javascript
pause(2000).then(fetchData)
``` 

Or use it inside an async function to pause the execution between two lines for 1 second:

```javascript
async function fetchAllData() {
  const data1 = await fetchData1(...)
  await pause(1000)
  const data2 = await fetchData2(...)
  return {...data1, ...data2}
}
```

Pretty powerful one-liner, and that's not even covering all the possibilities. In the following posts we'll build on this idea of a pause and make it a crucial part of our scheduler.
A quick and cool CSS real-time editor with HTML & CSS only
Tags: webdev, css, frontend, forfun
Published: 2019-11-19 20:16:27

---
title: A quick and cool CSS real-time editor with HTML & CSS only
published: true
description: A quick and native way to build a CSS editor using style elements and content editor
tags: #webdev #css #frontend #forfun
---

For god sake, don't use this snippet on production. Don't use it at all, maybe (?). But anyway, thats pretty cool!

You can style style tags :no_mouth: You can add contentEditable to style tags also. So, you can build your native & real-time CSS editor with that!

If you paste this code/element at the end of your body tag, you will have your quick native CSS Editor.

```html
<style 
    contenteditable="true"
    style="z-index:1;
    position:fixed;
    top:0;
    right:0;
    width:300px;
    background:#fff;
    min-height:100vh;
    display:block !important;
    overflow: auto;
    padding:14px;
    border-left: solid 1px #cccccc">

    body {min-height: 100vh;}

</style>
```
On thing i personally like on this cool snippet is the meta relation between the style and the body, once the code on the style tag gives the body the right size to show the style tag itself, look at the `body {min-height: 100vh;}`.

Here's a pen if you prefer:

{% codepen https://codepen.io/felipperegazio/pen/dyyaeRg %}

Highlight plugins are welcome ;P
Getting stuck 
Tags: beginners
Published: 2019-11-19 19:55:14

Today I started my venture into the 100 Days of Code challenge and I’ve been trying to come up with projects but I feel like every project I think of is either way out of scope and will take lots of time to finish  and tbh I usually don’t care much about or I’ll think of something that almost feels too simple and I barely learn anything.

So my question is do you guys ever feel this way and if so how do you correct this?
.NET Core Roadmap: Reasons to Use .NET Core Now and in the Future
Tags: dotnet, netcore, csharp, roadmap
Published: 2019-11-19 19:43:53

---
title: .NET Core Roadmap: Reasons to Use .NET Core Now and in the Future
published: true
description: .NET Core is an open-source, free, multi-platform framework from Microsoft; it replaces .NET Framework. .NET Core 3.0 was released in September 2019. In this post, I will present to you a .NET Core roadmap and will discuss why to use it in your projects and what you should know about its future. 
tags: dotnet, netcore, CSharp, roadmap
---

.NET Core is an open-source, free, multi-platform framework from Microsoft; it replaces .NET Framework. .NET Core 3.0 was released in September 2019. In this post, I will present to you a .NET Core roadmap and will discuss why to use it in your projects and what you should know about its future.

.NET Core Performance Speed Stands Out
The open-source philosophy behind .NET Core, combined with its features, makes it increasingly popular with developers. .NET Core is one of the faster frameworks in the market. As far as APIs or Web services, .NET Core is in the top three in performance. Take a look at this performance analysis.

[Full Article](https://gorillalogic.com/blog/net-core-roadmap-reasons-to-use-net-core-now-and-in-the-future/?utm_content=105557502&utm_medium=social&utm_source=linkedin&hss_channel=lcp-68692)
In Theory But Not in Practice
Published: 2019-11-19 19:10:22

We've officially completed our first week at Makers! One down, eleven to go. It's been as rewarding as it has been tiring, but I do get the feeling that we're still in the honeymoon phase. 

Something that I did find I struggled with this week was my learning strategy. I found that, during the pair programming challenge in the afternoons, I would be having trouble using certain aspects of code that I previously thought I understood. This was the case with attr_reader, attr_writer, and attr_accessor. While I was aware of the theory behind these concepts (as I had acknowledged it as a gap in my knowledge and 'learnt' it the week before (and could explain its function to other people)), I had a difficult time with them when actually having to implement and use them within my code. This occurred on more than one occasion during the week, where I struggled using concepts in practice that I technically understood the theory behind. 

To me, the solution in order to resolve this in future was fairly simple. My goal over the next few weeks is, when learning programming principles, to not only begin by reading through documentation and articles, but follow this up with practicals and exercises that include the area/s I'm struggling with. Makers have many online resources so hopefully I should be able to begin by finding help there, but if not, I can try googling or making up my own exercises. 

Onwards and upwards!