When comparing the performance of Fluent Bindings to Swiss/Tibet binding expressions in MvvmCross, several factors come into play. Here's a detailed breakdown:
Overview of Binding Types
- Fluent Bindings: These are type-safe binding expressions created in C# code. They are particularly useful on platforms like iOS and UWP where XML layout files are not easily editable. Fluent bindings provide a clear, strongly-typed way to bind view properties to view model properties, which can help reduce runtime errors by catching type mismatches at compile time[1][4].
- Swiss/Tibet Binding Expressions: These are string-based binding expressions typically used in XML layout files (e.g., Android's AXML). Swiss bindings are more flexible and allow for complex expressions like concatenation and conditional logic. Tibet binding extends this by supporting more advanced syntax similar to a mini-language for binding expressions[1][6].
Performance Comparison
Compile-Time vs. Runtime Evaluation
- Fluent Bindings: Since Fluent bindings are defined in C#, they are evaluated at compile-time. This means any type errors or binding issues are caught early, potentially improving development efficiency. However, the actual performance at runtime is generally similar to other binding methods because the binding setup is still executed at runtime.
- Swiss/Tibet Bindings: These bindings are evaluated at runtime because they are defined as strings in XML files. This means any errors in the binding expressions are only discovered when the app runs, which can lead to slower development cycles if not properly tested. However, the runtime evaluation does not inherently make them slower than Fluent bindings once the bindings are set up.
Runtime Overhead
- Fluent Bindings: The overhead of Fluent bindings is minimal because they directly create the necessary binding objects in code. This direct approach can be slightly more efficient than parsing string expressions at runtime.
- Swiss/Tibet Bindings: These require parsing the binding expressions from XML at runtime, which introduces some overhead compared to Fluent bindings. However, this overhead is typically small unless dealing with very complex or numerous bindings.
Development Efficiency and Error Handling
- Fluent Bindings: Provide better development efficiency due to compile-time checks, which can indirectly improve performance by reducing the time spent debugging runtime binding issues.
- Swiss/Tibet Bindings: While more flexible for complex expressions, they require more runtime checks and can lead to slower development if not properly tested.
Conclusion
In terms of raw performance, both Fluent and Swiss/Tibet bindings are generally comparable once set up. However, Fluent bindings offer advantages in development efficiency and compile-time error detection, which can indirectly improve overall application performance by reducing debugging time. Swiss/Tibet bindings provide more flexibility in complex scenarios but require more runtime checks. The choice between them often depends on the specific needs of the project and the developer's preference for code-based versus XML-based binding definitions.
Citations:[1] https://blog.ostebaronen.dk/2018/01/mvvmcross-binding-target.html
[2] https://stackoverflow.com/questions/46522577/mvvmcross-issues-with-fluent-binding
[3] https://stackoverflow.com/questions/48422489/mvvmcross-tibet-binding-to-viewmodel-itself
[4] https://www.mvvmcross.com/documentation/fundamentals/data-binding
[5] https://www.youtube.com/watch?v=3-cT97sBmxM
[6] https://stackoverflow.com/questions/48824612
[7] https://github.com/MvvmCross/MvvmCross/issues/1342
[8] https://github.com/MvvmCross/MvvmCross
[9] https://www.mvvmcross.com/documentation/fundamentals/value-converters
[10] https://stackoverflow.com/questions/48066268/xamarin-mvvmcross-fluent-binding-on-uwp
[11] https://crosscuttingconcerns.com/MvvmCross-Fluent-Databinding