I looked into the lemmy src, and what is supposed to be a CRUD API has several layers of abstraction. Same at work, where we have hexagonally structured apps where following any sort of logic is literally impossible. What are your thoughts?

  • r_mode@feddit.de
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    mind if i ask what ‘hexagonally structured’ means? i have never heard of this and cant imagine what it could be :D

    • Cinnamon@beehaw.orgOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      adapter-core domain logic- port

      basically you make an onion, where the core domain logic handles well, your actual logic the adapter handles requests and makes them understandable for your core part the port part is your db or anything like that, it’s usually an implementation of an interface

    • ZeroNationality@lemmy.one
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      The hexagonal architecture or onion architecture is oversimplified as having everything bolt onto a core of business logic via designed and designated interfaces to abstract away implementation details on either side.

      Say you have a web app which takes requests from the outside world and based on those requests it performs some business logic (tracking accounts, orders, etc).

      In hexagonal architecture you’d maybe implement such a thing like:

      Web app handler -> command interface -> message bus -> command handler (business logic) -> repository interface -> repository (Postgres, mongo, memory, email)

      What this lets you do is split apart the app at the interfaces into separate modules which can be reasoned about and tested separately.

      End of the day you don’t care what is happening on the other side of the interface as long as whatever it is follows the interface specification.

      Building applications like this meants that if we wanted to extend our app with an API and a Real-time Websocket service, we can (usually) just write a handler to turn that request into a command for the command interface and be done with it.

      • r_mode@feddit.de
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        cool, thanks for the explanation :) i am familiar with onion architecture, i just never heard of hexagonal arch. i assumed there would be some difference

  • Stumblinbear@pawb.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I just had a look at the Lemmy source and it seems pretty straightforward, what exactly are you having issues with?

      • key@lemmy.keychat.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        I don’t see the problem with modularizing code. Any proper IDE will make following through the crates as transparent as if it were all in the main src folder. It’s not like there’s some complicated indirection at play or anything, it’s direct references and invocations.

          • recursed@lemmy.recursed.net
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            Given this project has been around for many years, (looking at their releases), I wouldn’t say it’s “early” to modularize their code. It’s very common practice to abstract out / move commonly executed code into their own packages and modules to allow ease of reuse across the app. This way if an entire subpackage needs to be moved or deleted, all related code could be affected at once and code which references it, simply needs to be edited. Typically these places to edit are much easier to handle since most of “calling code” wouldn’t touch the modularized / abstracted code, only their callables.

  • Jamie@jamie.moe
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    I’ve coded most of my applications in that structure. It makes changing and testing things sane. Plus, if I need to make a large backend change, I can keep the abstractions compatible and have the rest of the app not notice.

    • Cinnamon@beehaw.orgOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I don’t know every time I’ve tried to change a beast like that, it was hard and frustrating.