We're planting a tree for every job application! Click here to learn more

Scala tip - How to include external or legacy code keeping up your code quality

Carlos Hernandez Navarro

29 Jun 2020

•

0 min read

Scala tip - How to include external or legacy code keeping up your code quality
  • Scala

Today, I would like to share a small code tip with you.

We are working on designing a new discount system for an online shop. To calculate our discount we are going to use an external library provided by an external company. The external function is working with integers but in our system we are using strings. How can we integrate them?

In this case, we can parse our parameters from string to integer. However, this process is dangerous, so we are using Either to identify and catch possible errors. Lastly, we can use a map2 function to map the value onto the external function. See the results below:

either_for_comprehension.png

Did you like this article?

Carlos Hernandez Navarro

Programmer analyst with 3 years of work experience. For the last year, I have been designing a high performance analyst application for an aeronautical company. The main technologies used on this project are: Java Spring boot, kubernete (Openshift), Kafka, Jenkins and Oracle.

See other articles by Carlos

Related jobs

See all

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Related articles

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

WorksHub

CareersCompaniesSitemapFunctional WorksBlockchain WorksJavaScript WorksAI WorksGolang WorksJava WorksPython WorksRemote Works
hello@works-hub.com

Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ

108 E 16th Street, New York, NY 10003

Subscribe to our newsletter

Join over 111,000 others and get access to exclusive content, job opportunities and more!

© 2024 WorksHub

Privacy PolicyDeveloped by WorksHub