teleren/devto huggingface dataset:
Why you need to see your test fail
Tags: programming, coding, learning, testing
Published: 2019-04-09 16:18:05

---
title: Why you need to see your test fail
published: true
description: 
tags: programming, coding, learning, testing
---

> Original post:
> 
> [www.koffeinfrei.org/2019/04/07/why-you-need-to-see-your-test-fail](https://www.koffeinfrei.org/2019/04/07/why-you-need-to-see-your-test-fail/)

## Red / green (/ refactor)

When developing using TDD or test-first the first step is to write a test. This test will initially fail, because there isn’t an implementation yet.

A test-first workflow implicitly ensures that a test is failing before turning green. Read up on the [The Cycles of TDD](https://blog.cleancoder.com/uncle-bob/2014/12/17/TheCyclesOfTDD.html) if you’re not familiar with it.

When writing a test after writing the production code you’ll never see the test fail, because the correct implementation is already there.

## So? What’s the problem with this?

The problem is that if you never see your test fail **you don’t know if your test is actually testing the right thing**, or testing anything at all.

The main purpose of a test is to make sure that your code is working properly. (If you’re doing TDD, driving the design of your production code actually is the main purpose of writing a test.)

If you don’t know if your code is actually testing the right thing, you can’t have confidence in your test, and you can’t have confidence in your production code.

If you ever write a test after, you need to temporarily change the implementation to see your test fail. Don’t change the test, **change the production code**.

## Real life example

Say we want to fix a bug. Before fixing it, we create a test that asserts that the bug exists in the first place. This means that the test needs to fail. We are at an equivalent as the first step in the TDD cycle.

Only after writing the test we fix the bug. After fixing the bug, the test goes green.

Imagine we write the test after fixing the bug. How do we know that the test actually tests that the bug does not exist anymore? Worst case is that we haven’t actually fixed the bug.

To make sure that we actually have, we need to undo the fix, run the test and make sure that the test fails. By doing that we verify that the bug has an effect on our test that represents the expected behaviour of our production code.

When re-applying the fix and the test goes green we can be pretty confident that we are testing the bug fix, and thus that the bug does not exist anymore (at least not in the form that our test case covers).


## The bottom line

If you want to trust your code you need to be able to trust your tests. You can’t do that unless you’ve seen your tests fail.

So don’t get lazy. Don’t just assume that your test is fine. **See**. **it**. **fail**.
Why You Should Get Azure Certified by May 1st
Tags: azure, certification, career
Published: 2019-04-09 15:55:32

---
title: Why You Should Get Azure Certified by May 1st
published: true
description: Microsoft's deprecation of AZ100 and AZ101 poses an exciting opportunity to become Associate Certified
tags: Azure, Certification, Career
cover_image: https://www.corenttech.com/images/azure_stack_animation.gif
---

*Why Microsoft's deprecation of AZ-100 and AZ-101 poses an exciting opportunity to become Associate Certified in Azure*

On May 1st, Microsoft will be deprecating the AZ-100 (Infrastructure and Deployment) and AZ-101 (Integration and Security) certifications for Azure. Currently, to become an Associate Certified Azure Engineer, one must have sat and passed both of these exams. 

The deprecation of these certifications is to allow for a new combined certification; __AZ-103__. This new exam will loosely match the AZ-100, but will incorporate some elements from the outgoing AZ-101. As of May 1st, to become Associate Certified, one is only required to sit and pass AZ-103. 

##Why is this good news?##

Well, if you have the time to study and sit the AZ-100 exam **before** the 1st May, then you will automatically receive the new AZ-103 when it becomes active. This means that by sitting the current AZ-100, you will automatically be fully associated certified from May onwards. 

Conversely, if you sit only the AZ-101 before 1st May, then you will merely receive an AZ-101 badge, nothing more... 

![Sad Panda](https://media.giphy.com/media/7p3e2WCM0VEnm/giphy.gif)

With the [current growth in Azure](https://www.canalys.com/newsroom/cloud-market-share-q4-2018-and-full-year-2018), now is as good a time as any to be taking some time to learn about the second largest Cloud Platform by market share. 

I have my exam booked for Thursday. :-) 

Cameron

*cover image: [corenttech](https://www.corenttech.com/azure_stack_private_solution.html)*
Using VS Code to work with Cosmos DB
Tags: azureapril, azure, webdev, tutorial
Published: 2019-04-09 15:43:14

---
title: Using VS Code to work with Cosmos DB
published: true
description: You can easily work with Cosmos DB directly from VS Code
tags: azureapril, azure, webdev, tutorial
series: azureapril
cover_image: https://thepracticaldev.s3.amazonaws.com/i/pblyvmtj4y8bdqisyzey.jpeg
---

*We've selected our favorite tips and tricks created by [Michael Crump](https://twitter.com/mbcrump) and are delivering fresh technical content on Azure all April! Miss a day (or more)? [Catch up with the series](https://dev.to/t/azureapril).*

**Don't have Azure?** [Grab a free subscription](https://azure.microsoft.com/en-us/free?&WT.mc_id=azureapril_devto-blog-cxa). 

What is [Cosmos DB](https://azure.microsoft.com/services/cosmos-db/?WT.mc_id=azureapril_devto-blog-cxa)? Azure Cosmos DB is Microsoft's globally distributed, multi-model database. 

You can easily view, create and delete databases, collections, graphs, and documents, along with other things detailed in their marketplace submission.

[Download the Cosmos DB Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb&WT.mc_id=azureapril_devto-blog-cxa)

![](https://thepracticaldev.s3.amazonaws.com/i/5xzdap8q47wm3vgtnhsh.png)

After installing it via the extension above, here is what it looks like to set up our Cosmos DB resource and type from within Visual Studio Code.

![](https://thepracticaldev.s3.amazonaws.com/i/p8shw4p2e5f7wgdgr0f1.gif)

Now we'll set up our database and collection.

![](https://thepracticaldev.s3.amazonaws.com/i/y10opnb4lp2fwglc4l7n.gif)

Finally, we'll create a document and add the following data to it.

```
{
    "name": "learn cosmos db",
}
```

![](https://thepracticaldev.s3.amazonaws.com/i/6qmcl1fqfelvq4afwdku.gif)

Want more VS Code? Check out our [quickstarts and tutorials](https://code.visualstudio.com/?WT.mc_id=azureapril_devto-blog-cxa)!

---
We'll be posting articles every day in April, so stay tuned or jump ahead and check out more tips and tricks [now](http://azuredev.tips).
Let's discuss coding workshops and why is it priced very high?
Tags: discuss, workshops
Published: 2019-04-09 15:41:23

---
title: Let's discuss coding workshops and why is it priced very high?
published: true
description: Pricing for workshops are quite high, want to understand the cost involved.
tags: ['discuss', 'workshops']
---

This question is a genuine attempt to understand the costs involved in a coding workshop.
If one has to organize a programming workshop, what will be the cost involved?
- physical location (not remote webinars)
Q1 2019 Dapp Market Report
Tags: reportblockchaindapp
Published: 2019-04-09 15:18:31

---
title: Q1 2019 Dapp Market Report
published: true
description: Q1 2019 dapp market report with the most comprehensive data and insights of 4 mainstream blockchains — Ethereum, EOS, Steem, and TRON.
tags: report blockchain dapp
---

<h3>Summary:</h3>

Q1 2019 dapp market report summarizes the most comprehensive data and provides insights into 4 mainstream blockchains — Ethereum, EOS, Steem, and TRON—they represent the whole blockchain ecosystem with the most active users in the market.
 

<h3>Highlights:</h3>

<h4>Dapp Growth and Activity</h4>

In the first quarter in 2019, a total of 504 dapps were added to Dapp.com, with Ethereum-based dapps dominated and accounted for more than half of the newly listed dapps. It shows that Ethereum is still the No.1 choice for developers to build their dapp on. At the same time, we also have seen a trend in multi-chain developing, as many Ethereum dapps expand on multiple chains, such as Ethereum + EOS or Ethereum + Tron.

In terms of the dapp activeness, 95% of the EOS dapps remained active—with 326 out of the 341 dapps had transactions in the first quarter. More than 80% of dapps that were built on the Steem and TRON networks had active users, too. On the other hand, although beating other chains in terms of dapp amount, nearly 600 Ethereum dapps were in “inactive” status without a single transaction record over the past 3 months.

 

<h4>Dapp Volume</h4>
The 4 mainstream blockchains remained strong in Q1 and hit a total transaction volume of $3.2 billion. EOS and TRON are the largest blockchains in dapp ecosystem—both of them processed over $1 billion transaction volume. As for Ethererum, the debate between PoS (or DPoS) and PoW will continue to center around the efficiency and suspected bot trading issue due to zero transaction fee.

 

<h4>User Growth and Activity</h4>
TRON dapps had more than 300,000 active users, followed by EOS dapps with around 260,000 active users. By the end of Q1 2019, the number of the wallets created on TRON mainnet has exceeded $2.3 million, among them, 15.46% were dapp users, raised nearly 1.5 fold since the beginning of 2019. Moreover, more than 80% of the TRON dapp users have used and made at least one transaction in dapps over the last 3 months.

The growth of new users was mainly driven by gambling dapps—which brought nearly 350,000 users to the dapp ecosystem. The increases of new users in games and exchanges were neck to neck, both sectors attracted around 90,000 new users in Q1.


Read the full report here >> [Dapp.com Q1 Dapp Market Report](https://www.dapp.com/article/dapp-com-q1-2019-dapp-market-report)
Tools for writing cross-platform Node.js
Tags: node, javascript, windows, macos
Published: 2019-04-09 14:25:37

---
title: Tools for writing cross-platform Node.js
published: true
description: Tools for writing cross-platform Node.js
tags: [nodejs, javascript, windows, macos]
---


Cross-platform Node.js is important: according to the [2018 Node.js user survey](https://nodejs.org/en/user-survey-report/#Primary-OS-Distro), 24% of Node.js developers use Windows locally and 41% use Mac. In production 85% use Linux and 1% use BSD.

If you'd like to make your code more cross-platform, check out the following list of resources!

https://github.com/bcoe/awesome-cross-platform-nodejs
Why do you use jQuery in 2019?
Tags: jquery, javascript, discuss
Published: 2019-04-09 14:23:29

JavaScript has matured a lot in the last years, and IMHO, jQuery has become irrelevant for me. 

But that's not a reality for every developer, as the [Stack Overflow Developer Survey Results 2019](https://insights.stackoverflow.com/survey/2019#technology-_-web-frameworks) has shown that 48.7% of the developers still use jQuery.

With a much easier and mature JavaScript, why do you use jQuery? What are the uses that vanilla JS can't do easily?
You are the perfect interviewee. How would you design an events booking system in five minutes?
Tags: discuss
Published: 2019-04-09 13:33:15

---
title: You are the perfect interviewee. How would you design an events booking system in five minutes?
published: true
tags: discuss
---
You are the perfect interviewee. You are presented with a pen and a whiteboard and asked to design an events booking system. What do you do?

I was given this task in an interview this morning. A fart would have been a better answer to the one I gave. I scribbled and waffled on about controllers and models and didn't come anywhere near describing a concrete system.

I could talk through the steps required to create an app in Rails but have no idea where to start as far as designing one on a whiteboard.

What would the perfect interviewee do? Would they talk about the user? Would they sketch out a UML diagram? Should the design mention classes at all or should the interviewee talk about the app at a higher level of abstraction?

What would the perfect interviewee do in five minutes to satisfy their interviewers? (That is, what do I need to learn to be able to communicate my ideas clearly via a whiteboard?)
What do you think about the future of e-commerce?
Tags: discuss
Published: 2019-04-09 13:19:37

---
title: What do you think about the future of e-commerce?
published: true
tags: discuss
---

I know that a lot of people think if there are no new trends in this sphere,so it's gonna die soon.And I'm really interested in your opinion about that.
Thank you in advance :)
Day 10 - Generate Dev.to post for 100 days challenge - 100 days 100 python scripts
Tags: python, productivity, beginners, career
Published: 2019-04-09 11:52:39

---
title: Day 10 - Generate Dev.to post for 100 days challenge - 100 days 100 python scripts
published: true
description: Day 10 - Generate Dev.to post for 100 days challenge
tags: python, productivity, beginners, career
cover_image: https://cdn-images-1.medium.com/max/1600/0*GEsDQGQ1BucUNW1g
series: 100 days 100 python scripts
---

##Day 10: dev_to_post_generate 

This script uses a template and generates my 100 days python scripts posts for dev.to by checking the last updated file in Readme. This is helpful for me to quickly update dev.to post without manually copy pasting things again and again

```python
import constants,os
import pyperclip
with open('README.md') as f:
    data=f.readlines()
last_updated_date=None

desc=""
for c in reversed(data):
    if "## Day " in c:
        last_updated_date=c.strip()
        break
    desc=c+desc

day,file_name=last_updated_date=last_updated_date[3:].split(":")

user_title=input("Please enter title for "+file_name.strip()+"\n")

title=day.title()+" - "+user_title
desc=desc[2:]

print(desc)
with open(os.path.join(constants.WORKING_DIR,file_name.strip())) as f:
    code= f.read()

with open("data/devto_post_template") as f:
    template=f.read()

template=template.replace("###code###", code)
template=template.replace("This script uses a template and generates my 100 days python scripts posts for dev.to by checking the last updated file in Readme. This is helpful for me to quickly update dev.to post without manually copy pasting things again and again", desc)
template=template.replace("Day 10 - Generate Dev.to post for 100 days challenge", title)
template=template.replace("Day 10", day.title())
template=template.replace("dev_to_post_generate", file_name.strip().replace(".py", ""))

pyperclip.copy(template)
```

Please Visit my Git Repo to check out all the previous day challenges.

[https://github.com/ganeshraja10/automated-python-scripts](https://github.com/ganeshraja10/automated-python-scripts)
Day 9 - Check a site is up or not - 100 days 100 python scripts
Tags: python, productivity, beginners, career
Published: 2019-04-09 11:48:38

---
title: Day 9 - Check a site is up or not - 100 days 100 python scripts
published: true
description: Day 9 - Check a site is up or not
tags: python, productivity, beginners, career
cover_image: https://cdn-images-1.medium.com/max/1600/0*GEsDQGQ1BucUNW1g
series: 100 days 100 python scripts
---

##Day 9: check_site_live 

This script checks if a site is active or not in the given intervals. if it's down it sends a notification.

```python
import requests,os,time

SITE_URL=""
SLEEP_SEC=300 #5 mins
while True:
    response=requests.get(SITE_URL)
    print(response)
    if response.status_code!=200:
          os.system('notify-send "Website Down" "'+SITE_URL+'is down"')
          break
    time.sleep(SLEEP_SEC)
```

Please Visit my Git Repo to check out all the previous day challenges.

[https://github.com/ganeshraja10/automated-python-scripts](https://github.com/ganeshraja10/automated-python-scripts)
What I learned my first week on the Job.
Tags: beginners, webdev
Published: 2019-04-09 11:01:40

---
title: What I learned my first week on the Job.
published: true
description: Some takeaways from my first week on the job.
tags: beginners, webdev
---

## Some things I Learned on my first week as a Dev

I recently started my first job as a web developer and I would like to share a few things I've learned. I'll format this as a list, so here we go!

### You belong
It doesn't matter if it's your first job or your latest role. You were hired because your employers believed in you. So do yourself a favor and believe in yourself too.

### Ask clarifying questions

If you don't understand something, your senior devs are not there to **judge** you, they are there to do their **job**. Part of which is to give and receive critique and help where they can. A gap in your knowledge base is not as embarrassing as not telling your lead when there is a problem.

### Volunteer but don't overreach

I suffer from a chronic need to prove myself. When things get too heavy on someone else's plate, you can help but don't overextend yourself if you know you've been given other directives to achieve. Your work takes priority!

### Google stuff first!

Yeah, this may feel like a bit of a no-brainer but some ask questions not about a codebase but about something that can be referenced easily. For example, if you don't know the name of an array method, you probably should look it up first.

### Function over perfection

We often talk about ideal conditions, greenfield projects, professional coding practices. However, nobody can write the cleanest code to begin with. Just focus on writing small, effective functions and remember to name your variables reasonably. New and old devs alike, have to rewrite things. Writing imperfect code, to begin with, is not a cardinal sin.

### You will fail but you're not your mistakes
I'm not trying to be disparaging but it happens. Things fall apart. Even senior devs make mistakes and there are always things you may miss or were not told because specifications were not available. It just happens. And I want to tell you that it's okay. We learn far more from our mistakes than our successes.

### Don't lose yourself in work
Ride a bike, play a video game, go on dates. You're a human before you're a developer and I know it's an exacting job. But that's the thing, it's a job. I do side projects but I also spend time with friends, do person stuff.

### Have fun!
I mean it. Enjoy the journey. Focusing on growth is fine but not at the cost of your personal relationships or health. We work to live not the reverse. And don't forget it!

### In closing

Sorry that this wasn't a technical blog but I feel that we tend to understate the importance of soft skills and emotional health. As always I welcome any comments, critiques, and feedback. Thanks for reading.
What makes you interested in taking part in an open-source project? 
Tags: discuss
Published: 2019-04-09 10:24:24

---
title: What makes you interested in taking part in an open-source project? 
published: true
tags: discuss
---

I am wondering what is the deciding factor for devs to decide to contribute nowadays. The value is the key, but how and when do you get aware of the value?
Software refactoring
Tags: software
Published: 2019-04-10 14:08:07

---
title: Software refactoring
published: true
tags: Software
canonical_url: https://perfectial.com/blog/code-refactoring/
---

Software [decays over time](https://www.techopedia.com/definition/22202/software-rot). Not like a piece of fruit, rotting from inside, but due to lack of updates implemented to it; the updates IT environment imposes on all its residents. Such a phenomenon, also known as software aging, is preventable by numerous measures, one of which is code refactoring – the topic of today’s article.

_ **They say don’t fix it unless it’s broken. We say update it before it’s old.** _

And here’s how:

![what is code refactoring?](http://perfectial.com/wp-content/uploads/2017/03/What-is-code-refactoring.jpg)

## What is code refactoring?

[Code refactoring](https://en.wikipedia.org/wiki/Code_refactoring) means restructuring your existing code, in a way that improves the internal structure but doesn’t change its external behavior. This complex procedure is aimed at modernizing software. It is typically used to increase the system’s maintainability, enhance performance, scalability, security and so on. If performed well, it can help developers discover some hidden bugs or vulnerabilities in the system.

Typically, refactoring is done in small steps, called micro-refactorings. Each of these steps is usually a tiny change to a source code that leaves the functionality of the system unchanged, it just makes the code cleaner and simpler. And if you do want to change some functionality of your code, it’s much easier to do with a clean, refactored code.

It should be pointed out that code refactoring doesn’t mean rewriting the code. The two notions are often confused but the difference between them is pretty simple: as we have mentioned above, the code refactoring doesn’t the behavior of software, while rewriting the code does.

The purpose of code refactoring is pretty clear — to keep your code clean, neat, and in order. You might not always see an immediate benefit from it but in the long run it is a worthwhile investment in your product.

The post [Software refactoring](https://perfectial.com/blog/code-refactoring/) appeared first on [Software Development Company Perfectial](https://perfectial.com).
LeetCode 20. Valid Parentheses
Tags: java, stack
Published: 2019-04-09 09:36:10

---
title: LeetCode 20. Valid Parentheses
published: true
description: Solution + explanation for LeetCode problem 20
tags: java, stack
series: LeetCode in Java
---

# Stack (Optimized)

```java
public boolean isValid(String s) {
    if (s == null || s.length() == 0) {
        return true;
    }

    int ptr = 0;
    char[] map = new char[s.length()];

    for (char ch : s.toCharArray()) {
        switch (ch) {
            case '(':
            case '{':
            case '[':
                map[ptr++] = ch;
                break;
            case ')':
                if (ptr == 0 || map[--ptr] != '(')
                    return false;
                break;
            case '}':
                if (ptr == 0 || map[--ptr] != '{')
                    return false;
                break;
            case ']':
                if (ptr == 0 || map[--ptr] != '[')
                    return false;
                break;
        }
    }

    return ptr == 0;
}
```

This problem can be solved by using a stack. The solution provided by LeetCode uses the `Stack` class. However, it can be simulated by an array. First, we create an empty array `map` that has the same size as the string `s`. Then we iterate through each character of `s` and when we encounter a left parenthesis, we store the parenthesis in `map` at the `ptr` index. Also, we increment `ptr` by one. (similar to `push` in `Stack`). If we encounter a right parentesis, we check if the right parenthesis has a corresponding left parenthesis stored at `ptr -1` in `map`. If not, return `false`. Finally, we check if the `ptr` equals 0 (similar to an empty `Stack`).


_Time Complexity_: `O(n)`

_Extra Space_: `O(n)`