CodeForWar

Path to being a Software Craftsman

Pure Functions

March 19, 2025 | Categories: programming

I love working with Pure Functions and find their readability and testing is such a breath of fresh air. Maybe it comes from working so much in the C programming language, but looking at a function's type signature and getting a pretty good clue of what the function does goes far behind my original idea of "Source Code doesn't lie". In OOP design you often have to go to the function to get a better idea of what's going on with that function, but with a promise of Pure functional programming you get most of that purely from it's Type System.

For example:
I can get a good idea of what this function does simply by it's Type System. Meaning what parameter type it takes and what parameter it returns.


One thing to notice about pure functions is that they _always_ have input parameters, and they never return Unit.


If you want more of a deep dive I highly recommend checking out Alvin Alexander and his content at Learn Scala. What he's been doing for the Scala community in general has been amazing. Please make sure to check him out.



Leave a comment:

Comments: