Posts

Showing posts from December, 2023

Functional programming concepts that can be used in any language for simplicity and automated tests

I want to share my recent insights after studying a few different functional languages. If you find yourself with some or all of those questions, this is an article for you to read. 1- When should I create a new function? 2- How can I write simple functions that are easily testable? 3- How can my code increase in size without increase in complexity? Now let's see this example "ideal code":     jsonPath = getJsonPath()     now = getDate()     config = getConfig(jsonPath, now)     news = getNews(config)     config = updateConfig(config, now, news)     news = updateNews(news)     errors = postNews(news)     saveConfig(jsonPath, config)     showErrors(errors) Notice that there are a few important points: 1- The emphasis of the code is on WHAT is being done, not how. The how is deferred to the functions, but the "orchestrator" doesn't know about how, just knows about what. 2- There is a separation betwe...