I’ve recently got interested in writing more functional and function-oriented code in general.
I’m just getting started but I constantly feel like I were reinventing the wheel when thinking on some problems. Right now my biggest concern is code organization. I have A LOT of small functions that do some simple processing (as a motivating example: String validation - suppose I’ve build hundreds of small functions checking whether string is uppercased, lowercased etc.). I use descriptive object names to group them together in some subcategories.
Now, I want to use my small functions to solve real problems. Consider validating a form (
case class Form). I’ve heard that it is generally discouraged to use classes with methods - thus I create another object that holds separate functions for each field - and these smaller functions are combined in yet another function that validates object as a whole. All this code is this case class specific and I won’t be able to reuse it anywhere else. For every other class I’d like to validate I have to prepare analogous object. The codebase grows - this logic is not contained in the class itself, is probably stored in separate file. Yet it to my OOP mind it looks more logical to put this code inside a class. Or at least define some Validator interface and implement instance for this class.
I find it really difficult not to get lost in this approach to coding. What I am asking for are some tips / example projects / books on organizing this kind of code. This question might seem naive but I don’t have any mentor whatsoever to guide me in the right direction.