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 8347395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:21:13+00:00 2026-06-09T07:21:13+00:00

I hope I can phrase this question correctly. I have a concern when dealing

  • 0

I hope I can phrase this question correctly. I have a concern when dealing with state and test-ability in classes with static and instance mutable fields.

Do the static fields essentially constitute a different class/responsibility/instance due to the difference in their lifetime/scope?

If so: then shouldn’t the instance fields also be a separate class/data structure?

And then: and if that is so, then shouldn’t all classes be stateless only receiving their dependencies on construction and should all then be immutable?

And finally, would this mean that functional programming is the right way to do object oriented programming as well?

  • 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-06-09T07:21:14+00:00Added an answer on June 9, 2026 at 7:21 am

    You shouldn’t have (really) mutable static fields. That is crappy design. Functional programming makes things a lot easier. I would separate the concerns so:

    • what is data, should only have the necessary code to manipulate it in class. like “string” “Integer” “Person” , these are the entities
    • what manipulates data, depends on data, but should not have internal state (Formatters etc)
    • what drives the execution , must usually have some internal state ,but it is either carried with the call, or is “configuration” like
      database connections, requests etc. This is either from an active
      request , or it is pure configuration (injected)
    • what views results (pure views) should be stateless in itself, and state should be fed to it with a context
    • then there is the glue in between which usually is the hairy exception..minimize that.

    etc..

    For testability

    • data should be mockable to a fake database.
    • “what manipulates data” should be easy to test since it is stateless.
    • State contained in contexts is easy to mock.
    • “what drives the execution” should be easy to test since dependencies are injectable and you can test it piece by piece.
    • views are easy to test since mocked state can be fed to it. the difficulty comes from actually verifying “what it looks like” , but that is up to either gui automation or human testers.

    In essence ALL of this could be done in a functional way if database (disk) and the request layer (web, ui, whatever) would comply. In practise you try to do the “pure” part in between pretty and functionalish , and use design patterns to shield it from the outside dirt.

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

Sidebar

Related Questions

Hmmm...crappy question, but I didn't know how to phrase this: I have a sweet
hope you can help me. I have html markup like this: <a href=error.htm class=button
Alright, I hope I can phrase this in a way that makes sense. If
hope someone can answer this. Here is some sample code. namespace std { #ifdef
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
Hope someone can help i cant seem to get my head around this, i
Hope someone can help me out with this problem I am having. I just
I hope I can explain this problem right, it's a bit confusing for me.
I hope you can give me a hand on this. It's been bothering me
I hope someone can help me here. I'm having trouble loading this variable. Right

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.