Architecting cross-platform applications

585 views
441 views

Published on

The mobile device offers great potential for enhancing customer service, reducing risk or improving productivity. To be effective, however, any application or mobile interface must accommodate the wide range of differing manufacturers and diverse operating systems.

Mobile Development Specialist, Ross Dargan covers how to write a cross platform application using c#. He demonstrates how easily you can target iOS, Android and Windows phone 8 using tools you will already be familiar with as a c# developer. Ross explains how to use good coding techniques to ensure a high amount of code reuse for both the back end core logic, and the front end user interface.


Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
585
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Ask questions whenever
  • Show how it connects to the MacShow the android emulatorShow break points
  • compiler directive
  • What does any good dev do
  • Mention who wrote it!!!
  • Could use MVP
  • Architecting cross-platform applications

    1. 1. Cross Platform Mobile Development in C# Ross Dargan @rossdargan
    2. 2. What I’m going to cover Target 95% of the UK mobile market in C# With maximum code re-use
    3. 3. What I’m going to cover
    4. 4. What I won’t cover The other cross platform options (http://propertycross.com/) A full walkthrough of the tooling Blackberry
    5. 5. UK Smartphone Landscape iOS 27% Windows 12% Other 1% Other 5% Blackberry 4% Android 56% Source: http://bit.ly/19d2thf
    6. 6. Native Development Android Java Eclipse IntelliJ Windows Phone C#/Visual Basic/F# Visual Studio iOS Objective C Xcode
    7. 7. Xamarin • C# and .NET for Android, iOS and Mac • Full native APIs
    8. 8. The bad… • • • • Price $2000 per dev per year Still need a mac Write once, run (and test!) everywhere Tooling is still a bit immature (but the support is great!) • Need to write each UI separately
    9. 9. UI Considerations
    10. 10. Hello World DEMO
    11. 11. So… Sharing
    12. 12. File Linking SHARING CODE
    13. 13. File Linking
    14. 14. File Linking DEMO
    15. 15. File Linking Pros • Quick Cons • Messy code • Progressively more difficult to maintain as you add implementations • Very hard to test • File linking is a PITA to remember as you add files
    16. 16. Portable Class Libraries SHARING CODE
    17. 17. Adding a PCL
    18. 18. Great… but Still need platform specific code somehow…
    19. 19. Abstract Classes SHARING CODE
    20. 20. Multiple Concrete Classes
    21. 21. Abstract Classes DEMO
    22. 22. Abstract Classes Pros • Quick • Easier to maintain • Follows Open/Closed principal Cons • Difficult to test • Pretty inflexible
    23. 23. Dependency Injection SHARING CODE
    24. 24. Dependency Injection • Helps separate code (Single responsibility) • Allows you to unit test’s discrete parts of the implementation – no God classes • You can inject in platform specific implementations • Inversion of Control allows you to swap implementations easily
    25. 25. PCL & DI demo DEMO
    26. 26. Dependency Injection Pros • Very loosely coupled code (reuse) • Unit tests are easy • Single Responsibility • Open/Closed Cons • • •
    27. 27. What are the downsides to using Dependency Injection? It can be dangerous for your career because it may increase your overall knowledge of good API design. Once you learn how proper loosely coupled code can look like, it may turn out that you will have to decline lots of job offers because you would otherwise have to work with tightly coupled legacy apps. Happens to me a lot :) Source: http://bit.ly/com6aD
    28. 28. Dependency Injection Pros • Very loosely coupled code (reuse) • Unit tests are easy • Single Responsibility • Open/Closed Cons • More code • Bloated constructors
    29. 29. Can we squeeze any more reuse out?
    30. 30. MVVM MAXIMIZE UI CODE REUSE
    31. 31. MVVM Platform Specific Code Shared Code
    32. 32. Demo
    33. 33. Improving Code Reuse in 3 easy ways • Heavy use of dependency injection – Allows different implementations for different platforms • Use PCLs (and file linking for the time being) • Use View Models to reuse presentation code
    34. 34. 3 layers of win MVVMCross Xamarin Visual Studio
    35. 35. Links • • • • • http://xamarin.com/ http://mvvmcross.wordpress.com/ http://propertycross.com/ https://github.com/rossdargan/Talks Dependency Injection in .Net by Mark Seemann (ISBN: 1-935182-50-1) • http://www.icndb.com/api/
    36. 36. Questions

    ×