+ All Categories
Home > Technology > Possible FSharp Refactorings could be...

Possible FSharp Refactorings could be...

Date post: 18-Dec-2014
Category:
Upload: tuomas-hietanen
View: 164 times
Download: 0 times
Share this document with a friend
Description:
 
13
F# refactoring possibilities BASIC REFACTORINGS THAT I WOULD LIKE TO HAVE IN VISUAL STUDIO IDE
Transcript
Page 1: Possible FSharp Refactorings could be...

F# refactoring possibilitiesBASIC REFACTORINGS THAT I WOULD LIKE TO HAVE IN VISUAL STUDIO IDE

Page 2: Possible FSharp Refactorings could be...

Purge tuples

Which is cleaner? It depends.

This is just a matter of clean code.

Also needed: Rename a variable/function/parameter

Page 3: Possible FSharp Refactorings could be...

Move discriminated union to subtype

Usually coder starts with the first one…

But the data (string*int) is so much easier to access in the later one!

Even later, it may not be clear that what sub-types belongs to where in the type hierarchy

Page 4: Possible FSharp Refactorings could be...

Convert to immutable

Usually you need either all or just one property to be changed to immutable/mutable

Page 5: Possible FSharp Refactorings could be...

Pattern match to If-else

Usually in case of booleans (or when-patterns)

Back-conversion not possible, if left-hand-side compare condition is not the same

Page 6: Possible FSharp Refactorings could be...

Move function parameters

Page 7: Possible FSharp Refactorings could be...

Move List, Seq or Array conversion in composition

Page 8: Possible FSharp Refactorings could be...

Extract Function-Composition

Page 9: Possible FSharp Refactorings could be...

Extract to active pattern

Longer code but sometimes better visibility of business logic intentions.

Page 10: Possible FSharp Refactorings could be...

Convert to Option-module

Option-module (bind, map, etc.) could be used more…

One step more would be List-module to recursion, or recursion to fold

Page 11: Possible FSharp Refactorings could be...

Strip un-used computation expression wrapping

Just minor cleanup if Async (or other monads) are not really used to bind any data to computation

Page 12: Possible FSharp Refactorings could be...

Basic object-oriented features

Generate a base class (and move some methods to there)

Create and/or Implement interface So that user doesn’t have to remember interface-syntax

Page 13: Possible FSharp Refactorings could be...

Simple pattern/snippet to make a simple MailboxProcessor

So that user doesn’t have to remember the whole syntax

Or a way to convert existing list/dictionary to a MailboxProcessor…


Recommended