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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:43:28+00:00 2026-05-26T15:43:28+00:00

The problem is whether an instance method should in anyway alter the object that

  • 0

The problem is whether an instance method should in anyway alter the object that contains the method or should it return a new instance? I’m new to F# and the concept of full mmutability that is suggested for F#.

Just using psuedo code for now unless I need to be more specific.

First thought is just add the message to the message list on the object:

class Something
  ctr(messages)
     _messages.Add(messages)

  AddMessage(message)
   _messages.Add(message)

Second is to construct a new list that joins the old list and the new message. Then I would create a new instance altogther and send back.

class Something
  ctr(messages)
     _messages.Add(messages)

  AddMessage(message)
    newMessageList = _messages.Join(message)
      return new Something(newMessageList)

Am I overthinking immutability?

  • 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-26T15:43:29+00:00Added an answer on May 26, 2026 at 3:43 pm

    As you are doing “class based” programming which is one of the way (rather unfortunate) to do object oriented programming, you would be doing in place state modification rather than returning a new state (as that’s what would be expected when you are doing OO).

    In case you really want to go towards immutability then I would suggest you need to use more FP concepts like Modules, Functions (not methods which have you have in class based programming), recursive data types etc.

    My answer is way too general and the appropriate answer lies in the fact that how this class of your will fit in the big picture of your application design.

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

Sidebar

Related Questions

The problem is that search results overlap and make it hard to see whether
I recall that one should always avoid using recursive method calls in Java .
I have hit upon this problem about whether to use bignums in my language
I'm having the following problem and wondered whether anyone could see why this is
we're having this toshiba barcode printer. I'm not sure whether this problem is hardware
A recent problem* left me wondering whether there is a text editor out there
Problem statement: It is necessary for me to write a code, whether which before
if given a graph problem how do we know whether we need to use
I'm trying to get a handle on whether we have a problem in our
Problem: I have two spreadsheets that each serve different purposes but contain one particular

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.