Wednesday, 27 June 2018

Xamarin DLL vs Shared project

So which to use Sharedproject vs complied DLL's? well it really depends on your project, your team, and the circumstances.

Shared projects

ProsCons
All Api's AvailableCan lead to spaghetti code
Platform-specific logic can be added directlyDifficult to unit test conditional code
All file types can be sharedMust be shipped in source form
Smaller package sizes/platform-specific optimizations


DLL's

ProsCons
Enforces architectural designLimited APIs available
Can be unit tested separatelyDifficult to share non-code files
Can be shipped in binary form (NuGet)Limited to target platforms or APIs
Requires more work to integrate platform-specific code

So which to choose, well generally if your team is small your project is small and the core of it is the UWP/DROID/IOS project then maybe a shared project is the best approach.

however if your team is large and your Application is part of a greater solution, or you want to leverage unit testing or you are working in an enterprise environment then perhaps you should consider a .net shared library

or you could do some sort of hybrid approach, where models are in a dll and business logic is in the shared project because it's specific to the application, it really depends on your problem domain.