Skip to content

A set of problems to improve your skills with TyDD, Type Driven Development with Java and some additional Functional libraries

License

Notifications You must be signed in to change notification settings

jabrena/type-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Type problems

A set of problems to improve your skills with TyDD, Type Driven Development with Java and some additional Functional libraries.

Motivation

Using Java, the developers implements the solutions, transforming data with different nature. We will consider that data as Values. That values will be encapsulated into Objects. For the design of your values, you will use Java primitives or Java wrapper classes:

From Java 8, you can use Monads, a parameterized Types to wrap values into a context and apply functions on it. What Monads are available in Java 8+?

Using third party libraries like VAVR, you could add new Monads like:

Or you could use new ones from Reactor to model your Reactive problems:

The following problems was designed to improve your skills modeling solutions.

Null safety

Java accept null values when you assign to a Type although it is harmful. Using JSR-305 meta-annotations like @NonNull or using JSR 303 & JSR 380 Bean validations, you could indicate that your programs only accept Non null values. Another alternative to mitigate the usage of null values in your programs is with the usage of the Monad Optional<T> to handle the optionality effect.

Enjoy the journey!

Juan Antonio Breña Moral

Problems

Try to solve the problems using Value Types & Monads

Problem 1

Feature: Insurance names

Background: Not everyone has a house in the Beach or acquire an Insurance for the house.

Scenario: Consume the solution in a Happy path scenario
    Given a TypeProblem1
    When  call the method: getInsuranceName()
    Then  return the name of the insurance

Scenario: Consume the solution when a Person without any Beachhosue
    Given a TypeProblem1
    When  call the method: getInsuranceName()
    Then  return the name of the default result

Scenario: Consume the solution when a Person without a Insurance
    Given a TypeProblem1
    When  call the method: getInsuranceName()
    Then  return the name of the default result

Notes:

  • Review the timeout for Every connection.
  • If the Person doesn´t have a house in the beach or if he didn´t acquire an Insurance, return a default message: Not available

About

A set of problems to improve your skills with TyDD, Type Driven Development with Java and some additional Functional libraries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published