Hello, today I’m giving a little update on what I’ve implemented in my Youtube Queuer project. The changeset isn’t very huge and consists mostly of improvements for easier future development.
First and most important, I’ve setup a dependency injection container, namely Autofac. I’ve decided to use it as this is the container I am the most familiar with. I was using it in my previous job, so I wanted to keep up to date with usage of this library.
I have also refined classes structure and their visibility. All of the service class in the YoutubeQueuer.Lib are now internal and only the interfaces are public. This way, I’ve enforced dependency injection, because the web component can’t just instantiate the classes themselves, as it was the case before. The code is now cleaner.
In the previous post about my project, I’ve talked about Google authorization. It was a simple, but working solution. At that point, the controller had to call the authorization method by itself:
Using such a workflow in just one place isn’t problematic, but I’ve started to create also other views, such as playlists and subscriptions views. Repeating this code in these places would be no good. So, following Ploeh’s advice, I’ve implemented the passive attribute pattern for the authorization process. The solution consists of two parts: an attribute applied to a method or controller and an action filter, which handles the authorization itself. With that, I just decorate the controller method with an attribute, like this:
And the authorization is handled in a declarative way, without controller explicitly knowing how to do the authorization. It has to know where to store the credential (for now it’s in session state), but it seems to me a better solution than having a service dependency in the controller.
If you are interested in the implementation details, the last commit with relevent changes is right there. I couldn’t make the GitHub see tag created by me in Git, so I added at least this.
Most of the changes right now were technical ones, but needed in order to keep my project tidy (and me sane dealing with in the long term).
That’s it for now, see you next time!