Skip to content
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

Code cleanup #6

Open
das7pad opened this issue Feb 2, 2018 · 4 comments
Open

Code cleanup #6

das7pad opened this issue Feb 2, 2018 · 4 comments

Comments

@das7pad
Copy link
Contributor

das7pad commented Feb 2, 2018

These lines / instance attributes remain unused in the code:

And one more thing:

What were your thoughts to allow an actual derived BaseShortener (let's call it Demo) as the engine argument for a Shortener? One could simply create an instance of Demo and use the api of it?

@blikenoother
Copy link
Owner

@das7pad
Copy link
Contributor Author

das7pad commented Feb 4, 2018

await asyncio.gather(shortener.short('https://github.com/'),
                     shortener.short('https://github.com/blikenoother/aiourlshortener/'),
                     return_exceptions=True)

shortener.shorten can now store a short-url for 'https://github.com/' or one for 'https://github.com/blikenoother/aiourlshortener/'. It may also be None in case both short calls failed.

The point is that shortener.shorten does not store a predictable content.


self.engine = engine.__name__
It is a calculated value and the user knows the content of it as he used it for the init. This one can be refactored in a property decorated function.


What were your thoughts to allow an actual derived BaseShortener (let's call it Demo) as the engine argument for a Shortener? One could simply create an instance of Demo and use the api of it?

We could refactor Shortener into a function which returns a derived BaseShortener instance.
There is no need to copy the public api of BaseShortener.

@blikenoother
Copy link
Owner

  • agreed when it will be used in gather there will be issue, we don't need to set self.expanded and self.shorten

  • yes user will know since he is initializing it with engine name

We could refactor Shortener into a function which returns a derived BaseShortener instance.
There is no need to copy the public api of BaseShortener.

can you pls explain this with sample code?

@das7pad
Copy link
Contributor Author

das7pad commented Feb 5, 2018

can you pls explain this with sample code?

https://github.com/das7pad/aiourlshortener/tree/refactor-shortener-class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants