News icon indicating copy to clipboard operation
News copied to clipboard

Mobile app: Autofac replaced with TinyIoC

Open davidbritch opened this issue 7 years ago • 2 comments

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.

davidbritch avatar Jan 17 '18 16:01 davidbritch

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" [email protected] 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.

Brosten avatar Jan 17 '18 16:01 Brosten

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.

davidbritch avatar Jan 17 '18 16:01 davidbritch