Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

What now?#

Sumit Rawal answered on May 24, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • what can i do now
  • time now
  • date time now
  • what can I do now
  • try now
  • So why now?

  • What now?#

    0

    If we take a closer look at our model descriptions, we might see that we could do better in some cases. We can make our ID fields simple strings instead of UUIDs and the language code, which is also defined as a simple string. Let’s get going and clean that up!

    Looking at the intermediate model for our API documentation (see the OpenAPI class structure in the tapir library), we realize that modifying such a deeply nested case class structure might result in some really messy code.

    We can do better than this. When confronted with big and nested structures, we should pick a tool from our functional programming toolbox which is called optics.

    Don’t be scared by the name or all that mathematics; there exist some useful libraries for it. In our case, we will pick Monocle, which provides profunctor optics for Scala. The basic idea of optics is to provide pure functional abstractions for the manipulation of immutable objects. Because of their pure nature, they are composable and that results in code that is more flexible and can more easily be reasoned about.

    Outline

    Now that we have that cleared, let’s make a plan for what we actually want to do.

    Steps to perform

    Adjust the URL parameter descriptions of {ID} to mark them as a kind of UUID.

    Adjust the ID attribute of our Product model to mark it as a kind of UUID.

    Adjust the lang attribute of our Translation model to mark it as an ISO-639-1 language code.  

    Popularity 1/10 Helpfulness 1/10 Language whatever
    Source: Grepper
    Tags: whatever
    Link to this answer
    Share Copy Link
    Contributed on May 24 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.