You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2023/01/18 18:32:09 UTC

[GitHub] [superset] craig-rueda commented on issue #20630: [SIP-92] Proposal for restructuring the Python code base

craig-rueda commented on issue #20630:
URL: https://github.com/apache/superset/issues/20630#issuecomment-1387532458

   Thanks for this, @john-bodley! I +1 to @ktmud 's structure. I have noticed recently that models are mixed all around the code and should be considered top-level. Ideally they would be somewhat isolated and should not depend directly on layers above, so this change would be great. I'd be glad to help out with the refactor :)
   
   **My view of what each layer "does" (open to discussion):**
   
   ```
   MVC Views / API
   ...
   ...
   Commands
   ...
   ...
   DAO
   ...
   ...
   Models
   ```
   
   ### MVC Views / API
   * Responsible for handling interactions with external actors (REST, views, etc)
   * Should perform validation from an API point of view
   * Translates errors emitted from mid-tier
   
   ### Commands
   * Where the business logic lives!
   * Performs its own validations and potentially raises when things don't look right
   * Might chain to other commands
   * Interfaces with DAO's in order to query the DB
   
   ### DAOs
   * Interfaces with the DB (via SQLA in our case)
   * Exposes low-level methods like `get_by_id()`, etc.
   * SHOULD NOT CONTAIN BUSINESS LOGIC (keeps things reusable and non-crosscutting)
   * Centralizes query logic, making mid-tier easy to test
   
   ### Models
   * Basically `py` dataclasses :)
   * Utilized by upper tiers to represent persisted data
   * **Note that quite a lot of "business" logic has crept into this layer (see: https://github.com/apache/superset/blob/master/superset/models/core.py#L379)**
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org