Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:47:47+00:00 2026-05-27T04:47:47+00:00

The more I dive into functional programming I read the recommendation to favor static

  • 0

The more I dive into functional programming I read the recommendation to favor static methods in favor of non-static ones. You can read about that recommendation in this book for example:

http://www.amazon.de/Functional-Programming-Techniques-Projects-Programmer/dp/0470744588

Of course that makes sense if you think about functional purity. A static function stands there and says: “I do not need any state!”

However, how does that influence testability? I mean, isn’t it that a system with a lot of static methods becomes a pain to test (since static methods are hard to mock)? Or does mocks play a minor role in functional programming and if so: why?

EDIT

Since there are doubts if the book really makes that recommendation. I will quote a little more. I hope thats ok for Oliver Sturm.

Use Static Methods

Static methods is one of the basic ideas worth considering as a general guideline. It is supported by many object oriented programmers, and from a functional point of view, functions can be made static most of the time. Any pure function can be made static.
(…)

Some may argue that the idea of always passing around all parameters means you’re not exploiting the ideas of object orientation as much as you could. That may in fact be true, but then perhaps it is because object orientation concepts don’t give as much consideration to issues of parallel execution as they should.
(…)

Finally, a guideline to recommend: when you have written a method that does not require acces to any field in the class it lives in, make it static!

Btw, there have been good answers so far. Thanks for that!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:47:47+00:00Added an answer on May 27, 2026 at 4:47 am

    One way of looking at this is that for functional programming you only need to mock state (by providing suitable inputs) that is required by the specific function. For OO programming you need to mock all of the state required for the inner working of the class.

    Functional programs also have the side benefit that you can guarantee that repeating the same test with the same input will give the same result. In classic OO you have to guarantee not just the same input, but the same overall state.

    In well architectured OO code, the difference will be minimal (as classes will have well defined responsibility) but the requirements for a functional test are still a strict subset of the equivilent OO test.

    (I realise that functional programming styles can make use of OO via immutable objects – please read mentions of OO above as ‘object oriented programming with mutible state’)

    Edit:

    As pointed out by Fredrik, the important part about functional methods is not that they are static, but that they do not mutate the state of the program. A ‘pure’ function is a mapping from a set of inputs to a set of outputs (same input always gives same result), and has no other effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am about to dive into a rules oriented project (using ILOGs Rules for
I've often heard that functional programming solves a lot of problems that are difficult
Before I dive into the question. Let me state that by Event Loop I
This is a deeper dive into a previous question I had here: Can items
Before I dive into my question, I wanted to point out that I am
More out of interest than anything else, but can you compile a DirectX app
More than about LINQ to [insert your favorite provider here], this question is about
So I'm just going to dive into this issue... I've got a heavily used
I'm just now starting to dive into IF statements in R . From what
Trying to dive into Qt big time but haven't done a large project with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.