Everybody that’s interested in F# has played around with some code, and it’s amazing how much stuff you can put into a small space with the language, but at some point, you’re probably going to get into a situation where you have more than one source file, yet you’d still like to stay functional.
So here’s a suggested structure outline for those larger functional projects
- TypeUtils.fs – All those wondrous and cool type extension snippets you’ve gathered. Type stuff has to go before anything else
- Sink.fs – Multi-threading, workflow, distributed processing stuff
- Utils.fs – General-purpose stuff that doesn’t go anywhere else. Interop calls, weird bits of system functions, custom string manipulation, whatever
- IOUtils.fs – Persistence helper functions
- ProgTypes.fs – If the project gets larger, you can’t get around some types
- ProgData.fs – Static data
- ProgIO.fs – Custom persistence functions. If you don’t have too many persisting types, put the code here. If you get a lot of custom persistence for your types, well, time to start thinking about a DAL (and time to start thinking you’re using the wrong paradigm)
- Face.fs – Any kind of GUI helper code you might have. If it’s a GUI-heavy app, lots of stuff here, but at the very least you’d want some functions to display various structures in a form so that you can do some REPL-like work
- Program.fs – The place that used to be the center of everything now has very little stuff. Command-line reading, initial run loop, maybe some help for the user
This isn’t a definitive text, and good grief, don’t use something like this unless you need it! But you should know that scripting/functional code does scale out, even in .NET, and having a good plan for putting things in different places is a good thing. Also this is F# functional projects, not F# OOP projects. Completely different thing. But this does scale into a mixed-mode setting where you have a couple/few simple POFOs and don’t want to bite the big OOP bullet.If you've read this far and you're interested in Agile, you should take my No-frills Agile Tune-up Email Course, and follow me on Twitter.