Code Monkey home page Code Monkey logo

nimbus's People

Contributors

weberc2 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

nimbus's Issues

Improve attribute ergonomics

Intro

Ideally attributes are accessed as properties (e.g., Bucket.Arn). Today they are accessed via accessor methods (e.g., Bucket.GetArn()). The Get prefix is necessary because frequently a Resource will have properties and attributes with the same name, and the Get allows us to disambiguate. In cases where there is an attribute and a property with the same name, it would be easy to accidentally access the property when you were intending to access the attribute (the static type checker will save those who use it, but even they might have a bit of confusion trying to debug the type checker error message).

Proposal

To address this, I propose making resources with this template:

class MyResource:
    def __init__(self, {prop_0}, {prop_1}, ... {prop_n}) -> None:
        self._{prop_0} = {prop_0}
        self._{prop_1} = {prop_1}
        ...
        self._{prop_n} = {prop_n}

    @property
    def {Attr0}(self) -> {attribute_python_type(Attr0)}:
        return {attribute_python_type(Attr0)}(self, {Attr0})

Scenario: Mutating properties

Since mutating properties isn't supported today, this is no worse in that regard. Further, if we wanted to support mutating properties, we could still provide SetProperty() methods (this is less natural in Python, but it feels more natural for this application to leave the getattr syntax for attributes.

Scenario: Accessing properties

Similarly, accessing properties via the __getattr__ syntax doesn't feel like a very natural use pattern; if someone needs a handle for a property, they can use whatever was passed into the constructor--if that thing was a literal of some sort, they can put the literal in a variable before passing it into the constructor. If we really want to support this case, we could support it with a GetProperty() method.

Alternative proposals

  • Namespacing attributes and properties to be explicit / disambiguate?
    • e.g., properties are PropBucketName instead of BucketName and attributes are AttrArn instead of Arn (possibly even .AttrArn() # method instead of `.AttrArn # @Property)?

missing license ?

i don't see a license file in the repo, in the setup, or a header in the files, please provide one else now can really look at or contribute.

on a separate note, also out of curiosity, why bazel?

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.