possible fsharp refactorings could be

Post on 18-Dec-2014

169 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

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

Purge tuples

Which is cleaner? It depends.

This is just a matter of clean code.

Also needed: Rename a variable/function/parameter

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

Convert to immutable

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

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

Move function parameters

Move List, Seq or Array conversion in composition

Extract Function-Composition

Extract to active pattern

Longer code but sometimes better visibility of business logic intentions.

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

Strip un-used computation expression wrapping

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

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

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…

top related