comment 0

TL;DL – .NET Rocks! 1375 (Mobile Development using F# with Scott Nimrod)

Show link.NET Rocks! 1375 (Mobile Development using F# with Scott Nimrod)

GuestsScott Nimrod

Show Notes

  • Regarding the listener e-mail comment
    • It’s often a losing battle to convince management who have an incomplete understanding of software quality to adopt new techniques (e.g., test-driven development).
    • If you don’t have the set of skills to persuade your company, perhaps you could bring in an evangelist like Uncle Bob.
    • It’s a catch-22: You need to show results to get people on board, yet you can’t get the results unless you have a chance to do the work in the right way.
    • An option is to bring in a team short-term to demonstrate how to use the new techniques; at the end, the company chooses whether to model themselves on that team. This eliminates the need for learning those techniques from scratch — possibly poorly — and then having the process fail.
    • Find out what actually matters to the decision makers in your organization (e.g., money, prestige, cost of failure) and press those buttons.
  • Why use functional programming for mobile development?
    • Scott picked up several books on F#, and bought Lego Mindstorms to make F# talk to it.
    • He later was trying to get a contract to build an app; he wasn’t sure if he’d get the contract but wanted to do it using Xamarin and F# for the experience.
  • How does F# work with Xamarin for Android?
    • Any .NET language (F#, C#, VB.NET) compiles down to MSIL.
    • The Visual Studio tooling isn’t all there like it is for C# (e.g., code maps, code coverage on System.Object is misleading).
  • Did you use a test-driven perspective?
    • The wireframes for the project were already in place, so buttons became commands on the view models, and the data comes from repositories (interfaces).
    • Railway oriented programming was used for handling validation.
  • Why did you choose F# for this particular app?
    • Scott wanted to break the stigma that F# is only for statistics or financial applications.
    • F# is functional-first, and has lots of object-oriented programming support.
    • F# has other benefits, such as its type system, discriminated unions to represent a distinct number of choices, and the option type (e.g., having no data is different from null, especially where repositories are concerned).
  • What are the functional ways to deal with plumbing?
    • The view model is just a mediator that sits between presentation (pages) and the domain logic (model). The view models and repositories are classes and are object-oriented.
    • In the end there’s less code. Note that the Visual Studio tooling does not support measuring this at this time (November 2016).
    • The tests are also implemented in F#. Because the repositories are built to an interface, you can run the tests in isolation.
    • F# supports abstract classes and interfaces, just like object-oriented languages.
    • There are namespaces to harbor the classes (i.e., view models, repositories) and modules to leverage the types declared and the pure functions implemented.
  • What were you particularly happy with?
  • If you’re accustomed to object-oriented programming and try something that’s a paradigm shift, it opens you up to new ways of thinking.
  • Maybe JavaScript, C#, C++, and/or Java are setting new developers up for failure because they require discipline. Functional languages can set people up with defaults. Scott suggested teaching software development/design using a functional-first language to take advantage of immutability by default and not having to deal as much with nulls.
  • There’s a trade-off between functional and object-oriented. Many of the libraries (e.g,. Xamarin.Forms) are object-oriented.
    • There are times when you would like classes to behave in a functional way. For example, SQLite classes have setters; sometimes you don’t want setters so that you have immutability. You end up having to work around (i.e., ceremony) the fact that the setter should not be used.
    • Perhaps the object-oriented classes would be okay for boundaries of the system (e.g., user interface); you want to keep the domain logic as pure as possible.

Better Know a Framework

Yarn – “Fast, Reliable, and Secure Dependency Management”

Listener E-mail

From show #1214 (Testing and Craftsmanship with Scott Nimrod); the listener appreciated Scott’s insights on craftsmanship, and tried to get shops he’s worked for to embrace TDD and automated testing. It can be an uphill battle to convince your team/company to adopt these practices. It comes down to insisting on an intentional culture: We value quality, but how do we demonstrate that?

Technology Giveaway Ideas

Scott recently purchased a Can-Am Spyder. He’d like to alter the vehicle to get 15-20 more horsepower, and use the remaining money to buy a Batman suit.

Leave a Reply

Your email address will not be published. Required fields are marked *