What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi Please let me know when we should use reader and writer classes as per spryker standards.

Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet
edited October 2022 in Help

Hi
Please let me know when we should use reader and writer classes as per spryker standards.

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    Hey, can you maybe elaborate more on what exactly you need to know?

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    In Some vendor modules, reader and writer classes are written when we are fetching data and saving data.
    So I just need to know if there is formatting required while saving or fetching then whether we should use reader or writer classes.
    or is there any further use cases for these classes.

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    It is mostly about separating different logic

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    Can you please provide some usecase for that with examples

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)
    edited October 2022

    Ideally you should follow some kind of the following structure:

    /Business
        /EntityA
            /Writer
                EntityAWriterInterface
                EntityAWriter
            /Reader
                EntityAReaderInterface
                EntityAReader
            /Expander
                EntityAExpanderInterface
                EntityAExpander
    
        /EntityB
            /Writer
            /Reader
            /Expander
    

    Reader: reads and optionally hydrates the corresponding entity or entities

    Writer: saves and/or creates and/or deletes the corresponding entity or entities

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    Does this help?

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    But please have in mind that you dont need these interfaces on project level in most of the cases

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok, it means if while saving and fetching any business logic is there then reader and writer comes into picture.
    Ok thanks for clearing out the confusion.

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    Yeah, it is in the end just a logical separation between read & write, similar to Repository and Entitymanager

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    so before entering to repository , reader is there and and before entering to entity manager , writer is there for any business logic, Please confirm.

  • Senior Software Engineer & Developer Enablement Advocate Sprykee Posts: 1,117 βš–οΈ - Guardians (admin)

    reader and writer are both there for business logic (since they are in the business layer) - If you would just forward the EntityManager or Repository inside the reader and writer you can also use the EntityManager or Repository directly in the Facade. But as soon as you need to do additional operations you should introduce a reader and/or a writer class to put the logic there.

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok thanks

  • Posts: 64 πŸ§‘πŸ»β€πŸš€ - Cadet

    it helpsπŸ™‚

Welcome!

It looks like you're new here. Sign in or register to get started.