Giter VIP home page Giter VIP logo

Comments (4)

devraj avatar devraj commented on September 27, 2024

On initially trying to implement this I created a dto/refs.py and started porting the Ref classes to that package. It feels odd from a design point of view, if we follow that pattern, for consistency we should have summary and response as packages.

The two patterns that seem logical are:

Group them by DTO type
There would be three over arching groups ref, summary, response and they contain packages for each command centre function e.g:

  • ref/alarm
  • summary/alarm
  • response/alarm

Imports would thus look like:

from gallagher.dto.ref.alarm import AlarmRef

Group them by CC function
In this pattern the overarching groups would be the command centre functions (as we have them now by then divide them further) e.g:

  • alarm
  • cardholder

and then divide them further as:

  • alarm/ref
  • alarm/summary
  • alarm/response

Imports would thus look like:

from gallagher.dto.alarm.ref import AlarmRef

from gallagher.

devraj avatar devraj commented on September 27, 2024

We also have various cases where a Summary inherits from a Ref e.g:

class AccessGroupRef(
    AppBaseModel,
    HrefMixin
):
    """ Access Groups is what a user is assigned to to provide access to doors
    """
    name: str


class AccessGroupSummary(
    AccessGroupRef
):
    """ AccessGroup Summary is what the API returns on searches

    This builds on the Ref class to add the summary fields and is
    extended by the Detail class to add the fully remainder of
    the fields
    """
    description: Optional[str]
    parent: Optional[AccessGroupRef]
    division: IdentityMixin
    cardholders: Optional[HrefMixin]
    server_display_name: Optional[str]

while it is efficient to do this, it might not be wise when trying to avoid circular dependencies.

Also logically a Summary is not an extension of a Ref and by inheriting you would imply that it is the case.

from gallagher.

devraj avatar devraj commented on September 27, 2024

Consider importing all the classes to the top level of the package, so the imports look more like the following

from gallagher.dto.ref import AlarmRef

from gallagher.

devraj avatar devraj commented on September 27, 2024

Closed this issue by merging

from gallagher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.