dotnet-architecture / News

News on .NET Architecture Guidance, eShopOnContainers and all the reference apps in dotnet-architecture
MIT License
1.1k stars 79 forks source link

Mobile app: Autofac replaced with TinyIoC #6

Open davidbritch opened 6 years ago

davidbritch commented 6 years ago

The eShopOnContainers mobile app, which now uses .NET Standard, has recently received some updates. One of the important updates is that the Autofac IoC container has been replaced by TinyIoC.

Dedicated IoC frameworks, such as Autofac, are feature and capability heavy. However, in a typical mobile application it's unlikely that you'll use most of these features and capabilities. Therefore, swapping to a less heavyweight IoC container should offer some benefits.

TinyIoC is an IoC container that's distributed as a CS file that you add to your project, and offers excellent performance for mobile apps. When comparing TinyIoC to Autofac, type registration is typically 35 times quicker, with type resolution typically being 5 times quicker. This results in the eShopOnContainers mobile app being noticeably more performant on all three platforms, but particularly on Android where the app startup time has been reduced by approximately 2 seconds.

As well as performance, replacing Autofac with TinyIoC has resulted in a number of other advantages:

This change is just one of many planned for the eShopOnContainers mobile app in the coming months. Check out the latest source in the DEV branch.

Brosten commented 6 years ago

Hi!

Will the ebook be updated to reflect changes in the app?

Skaffa Outlook för Android

On Wed, Jan 17, 2018 at 5:04 PM +0100, "David Britch" notifications@github.com wrote:

The eShopOnContainers mobile app, which now uses .NET Standard, has recently received some updates. One of the important updates is that the Autofac IoC container has been replaced by TinyIoC.

Dedicated IoC frameworks, such as Autofac, are feature and capability heavy. However, in a typical mobile application it's unlikely that you'll use most of these features and capabilities. Therefore, swapping to a less heavyweight IoC container should offer some benefits.

TinyIoC is an IoC container that's distributed as a CS file that you add to your project, and offers excellent performance for mobile apps. When comparing TinyIoC to Autofac, type registration is typically 35 times quicker, with type resolution typically being 5 times quicker. This results in the eShopOnContainers mobile app being noticeably more performant on all three platforms, but particularly on Android where the app startup time has been reduced by approximately 2 seconds.

As well as performance, replacing Autofac with TinyIoC has resulted in a number of other advantages:

The unit tests run more quickly. The unit tests are more reliable (issues to do with Autofac disposing of objects have been instantly eliminated). There's one less NuGet package distributed with the app, resulting in smaller app package sizes.

This change is just one of many planned for the eShopOnContainers mobile app in the coming months. Check out the latest source in the DEV branch.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

davidbritch commented 6 years ago

Once all the updates are made to the app we'll release a v2 of the eBook, but that'll be a few months away yet.