Should I go tightly coupled, with singleton, or loosely coupled, without a singleton? Azure Services

JohnButlerJohnButler ✭✭USMember ✭✭

I have been trying to figure out how to go about getting my ap to integrate with the Azure Backend.
I have ran into a problem. In classes it was drilled into me to try to build your programs as loosely coupled as possible. But then I have been told to create my AzureServices class as a singleton to stop multiple creations and mucking up the backend connection

Since I cant use Interfaces with a singleton to make my app loosely coupled. I have to pick. I think I should go with interfaces, for loose coupling. But I dont know much about Backend development.

Thanks for any help.

Answers

  • MdNaushadMdNaushad ✭✭✭ INMember ✭✭✭

    The Xamarin Evolve app uses the azure backend.
    The source code is also up on git, it will help you get the structure right
    https://github.com/xamarinhq/app-evolve

  • JohnButlerJohnButler ✭✭ USMember ✭✭

    @MdNaushad said:
    The Xamarin Evolve app uses the azure backend.
    The source code is also up on git, it will help you get the structure right
    https://github.com/xamarinhq/app-evolve

    MOSH!?!?! Oh man! Is it really you?!?! LOL. I have gone through all your C# classes on Udemy. You have been by far my favorite instructor. That part of my post "In classes it was drilled into me to try to build your programs as loosely coupled as possible." That was because of you hehehe. Sorry I feel like a weird fan boy now. But I just wanted to express my appreciation for you and your teaching. I keep checking Udemy for more of your classes. I know you have said they don't make you much money and you still have a day job but I hope you can get to the point where you can put more time into teaching as you are really good and it seems like you enjoy it.

    Okay enough flattery. I will check out the Evolve app. Thanks for the suggestion.

  • JohnButlerJohnButler ✭✭ USMember ✭✭

    @MdNaushad said:
    The Xamarin Evolve app uses the azure backend.
    The source code is also up on git, it will help you get the structure right
    https://github.com/xamarinhq/app-evolve

    Mosh, So I studied the Evolve app for the last few days and then copied the structure into my own app. But it does not seem to be creating a singleton of my Azure Service.
    To test in the constructor I create a Random number and then display it. Then everytime I do a DependencyService.Get<>() I follow it with a display of that random number. And it always displays a different number, thus it is running the constructor everytime, thus it is not a singleton. Or am I not understanding what a Singleton is.... I am starting to think that is the case....

Sign In or Register to comment.