Skip to main content
8 events
when toggle format what by license comment
Aug 11, 2015 at 4:51 vote accept koenmetsu
Aug 7, 2015 at 22:06 comment added Mark Seemann Perhaps it'll help with an exercise: try to write the final move function first, and then write all the 'dependency functions' below that function, so that you start with the most high-level function first, and then functions become more and more specific the lower on the page they are.
Aug 7, 2015 at 21:49 comment added koenmetsu I've seen that one, so either I'm still missing something, or I need to take this a bit further than I have been. Thanks for the comments!
Aug 7, 2015 at 21:20 comment added Mark Seemann I'm suggesting injecting some moveFile function into move. Once you've done that, you can look at its inferred type to figure out what you need to do next. Then you can repeat the process in a recursive fashion. It's an outside-in process that I describe (among much else) in my Type-Driven Development course.
Aug 7, 2015 at 19:32 comment added koenmetsu Are you suggesting to inject the moveFile function into move? In that case, it seems there's not much reason for move to exist anymore. And if not, then move needs to be injected with the functions upon which moveFile depends, and it gets bloated. It's probably my currently limited understanding, but could you clarify this? Thanks a lot.
Aug 7, 2015 at 19:15 comment added Mark Seemann As far as I can tell, move depends on one other function: moveFile (although I can't tell where getMoveRequests comes from, so it may depend on two functions...). It's a simple repetition of the exercise done above. Instead of ending with the public function, start by defining the public function and see what it needs in order to work.
Aug 7, 2015 at 19:07 comment added koenmetsu Thanks for your answer, Mark. I like the thinking behind making these more generic, but won't using these separate functions instead of the IFileSystemOperations bloat the public move function with the injection of all five functions in IFileSystemOperations? ie: let move directoryExists createDirectory readBytes delete copy targetPath pictures = //...
Aug 7, 2015 at 18:19 history answered Mark Seemann CC BY-SA 3.0