{"id":16169366,"url":"https://github.com/jabrena/type-problems","last_synced_at":"2026-02-04T07:08:47.727Z","repository":{"id":73644049,"uuid":"216241321","full_name":"jabrena/type-problems","owner":"jabrena","description":"A set of problems to improve your skills with TyDD, Type Driven Development with Java and some additional Functional libraries","archived":false,"fork":false,"pushed_at":"2019-10-27T18:35:47.000Z","size":137,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T06:41:42.439Z","etag":null,"topics":["effects","monads","optional","tydd","type-driven-development"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jabrena.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-19T17:04:02.000Z","updated_at":"2019-10-27T18:35:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"c37e1d71-5a60-45f7-a0dc-9c5b48d9fdcb","html_url":"https://github.com/jabrena/type-problems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jabrena/type-problems","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Ftype-problems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Ftype-problems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Ftype-problems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Ftype-problems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jabrena","download_url":"https://codeload.github.com/jabrena/type-problems/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jabrena%2Ftype-problems/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264887488,"owners_count":23678689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["effects","monads","optional","tydd","type-driven-development"],"created_at":"2024-10-10T03:14:46.283Z","updated_at":"2026-02-04T07:08:47.663Z","avatar_url":"https://github.com/jabrena.png","language":null,"readme":"# Type problems\nA set of problems to improve your skills with `TyDD, Type Driven Development` \nwith Java and some additional Functional libraries.\n\n## Motivation\n\nUsing Java, the developers implements the solutions, transforming data \nwith different nature. We will consider that data as `Values`. That values will be encapsulated into Objects. \nFor the design of your values, you will use [Java primitives](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)\nor [Java wrapper classes](https://en.wikipedia.org/wiki/Primitive_wrapper_class):\n\n![](docs/images/javaTypes.png) \n\nFrom Java 8, you can use `Monads`, a parameterized Types to wrap values into a context and apply functions on it. \nWhat Monads are available in Java 8+?\n\n- [Stream\u003c T \u003e](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html)\n- [Optional\u003c T \u003e](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)\n- [CompletableFuture\u003c T \u003e](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html)\n\nUsing third party libraries like VAVR, you could add new `Monads` like:\n\n- [Try\u003c T \u003e](https://static.javadoc.io/io.vavr/vavr/0.9.2/io/vavr/control/Try.html)\n- [Either\u003c L ,R \u003e](https://static.javadoc.io/io.vavr/vavr/0.9.2/io/vavr/control/Either.html)\n\nOr you could use new ones from Reactor to model your Reactive problems:\n\n- [Mono\u003c T \u003e](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html)\n- [Flux\u003c T \u003e](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html)\n\nThe following problems was designed to improve your skills modeling solutions.\n\n### Null safety\n\nJava accept `null` values when you assign to a Type although it is harmful. \nUsing `JSR-305` meta-annotations like `@NonNull` or using `JSR 303` \u0026 `JSR 380` Bean validations,\nyou could indicate that your programs only accept Non null values. \nAnother alternative to mitigate the usage of `null` values in your programs is with the \nusage of the Monad `Optional\u003cT\u003e` to handle the optionality effect.\n\nEnjoy the journey!\n\nJuan Antonio Breña Moral\n\n\n## Problems\n\nTry to solve the problems using `Value Types` \u0026 `Monads`\n\n### Problem 1\n\n``` gherkin \nFeature: Insurance names\n\nBackground: Not everyone has a house in the Beach or acquire an Insurance for the house.\n\nScenario: Consume the solution in a Happy path scenario\n    Given a TypeProblem1\n    When  call the method: getInsuranceName()\n    Then  return the name of the insurance\n\nScenario: Consume the solution when a Person without any Beachhosue\n    Given a TypeProblem1\n    When  call the method: getInsuranceName()\n    Then  return the name of the default result\n\nScenario: Consume the solution when a Person without a Insurance\n    Given a TypeProblem1\n    When  call the method: getInsuranceName()\n    Then  return the name of the default result\n\n``` \n\n![](./docs/class-diagram-type-problem1.svg)\n\n**Notes:** \n\n- Review the timeout for Every connection.\n- 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`\n\n## [References](./REFERENCES.md)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Ftype-problems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjabrena%2Ftype-problems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjabrena%2Ftype-problems/lists"}