« Better brick| Main | Agile Ruined My Life »

Structuring Larger F# Functional Projects

| | Comments (0)

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.

Leave a comment


Comment Policy: I really, really, really enjoy comments, but if all you have to offer is general platitudes like how happy you are to have found my site and what a wonderful place it is, I will delete your comment and report your comment as spam. Please try to either tell me I am wrong, sympathize with my point, expand on what I'm saying, or offer your own experiences or opinions. If you just want a link your best bet is to just ask for one. Probably won't work, but at least be honest about it. No name-calling and please keep the profanity as low as possible. If your grandma can't read it or you wouldn't say it in person, don't write it here. Thanks.

About this Entry

This page contains a single entry by DanielBMarkham published on September 2, 2010 10:40 AM.

Better brick was the previous entry in this blog.

Agile Ruined My Life is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.





Share Bookmark this on Delicious

Information you might find handy
(other sites I have worked on)





Recently I created a list of books that hackers recommend to each other -- what are the books super hackers use to help guide them form their own startups and make millions? hn-books might be a site you'd like to check out.
On the low-end of the spectrum, I realized that a lot of people have problems logging into Facebook, of all things. So I created a micro-site to help folks learn how to log-in correctly, and to share various funny pictures and such that folks might like to share with their friends. It's called (appropriately enough) facebook login help