-
Notifications
You must be signed in to change notification settings - Fork 0
API Optimization #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API Optimization #19
Conversation
Lets maybe also discuss how to use this. If I'd like to override the signature of a repository function e.g. the def create(self, event_id: int, customer_id: int, event_location_selection: EventLocation, is_confirmed: bool = False) -> BookingModel:
logger.info("Booking creation", event_id=event_id)
booking = BookingModel(event_id=event_id, customer_id=customer_id, event_location_selection=event_location_selection, is_confirmed=is_confirmed)
return super(BookingRepository, self).create(booking) Any objections? Improvement suggestions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... 😂 LGTM😄
calling ’create’ of the super class makes sense 👍 however, it is violating the LSP because the signature is changing... To be really clean you'd have to create another method or another independant class that uses the repository from the lib. But I'm still uncertain what makes sense here |
Is it really violating the LSP? My interpretation of the principle is, that anything is allowed as long as the signature is extended but not narrowed. You can put an object of the structure |
maybe I missed something there, but the signature of def create(self, entity: GenericEntity) -> GenericEntity: and the one of the subclass could be something like this: def create(self, event_id: int, customer_id: int, event_location_selection: EventLocation, is_confirmed: bool = False) -> BookingModel: That doesn't extend the signature, it's different |
Fair point 😅 so what's the (pythonic) approach to go? Generic *args and **kwargs signature? 😅 |
Where do you want to use them? In the base implementation we need the |
Factory seems reasonable to me. I (as a user) don't want to reimplement everything via facades to use this. Are you with that? |
yep, sounds good 👍 |
Well. I noticed that I duplicate a lot of shit and had the find method in the Repository, even though it should be a base repository method. In the companyService for example, I didn't use the Repository at all but just the BaseRepository, as our update and create methods are very explicit. That said, we can straight increment to v2 😂👋