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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:51:19+00:00 2026-06-11T09:51:19+00:00

This example is trivial just to show the point. Let’s say I use matrix

  • 0

This example is trivial just to show the point.

Let’s say I use matrix library, but is lacks some power, let’s say doubling every element in matrix is so crucial for me, I decide to write a method doubleIt. However, I could write 2 versions of this method

  1. mutable — doubleItInPlace
  2. non mutable — doubleItByCreatingNewOne

This is a bit lengthy, so one could think of naming convention, adding to mutable version _! suffix, or prefixing it with word “mut”.

Is there any establishing naming convention for making such difference?

  • 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-11T09:51:21+00:00Added an answer on June 11, 2026 at 9:51 am

    The convention is to name the mutable (in general, side-effecting) version with a verb in imperative form. Additionally, and more importantly, use the empty parameter list () at the end:

    def double()
    def doubleIt()
    

    The immutable version, i.e. one producing a new object, you should name via verb in the passive form. More importantly, do not use the empty parameter list () at the end:

    def doubled
    def doubledMatrix
    

    Note that naming the non-side-effecting method in the passive form is not always adhered (e.g. the standard collections library), but is a good idea unless it makes the name overly verbose.

    Source: Scala styleguide.

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

Sidebar

Related Questions

I think I may have asked this on Haskell-Cafe at some point, but damned
Consider this contrived, trivial example: var foo = new byte[] {246, 127}; var bar
This example is simplified a bit, but in my ASP.NET web page in my
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
This really should be easy, but I just can't work it out myself, the
This may seem kind of homework-ish and/or trivial, but it is for a real
Take this trivial example and open it: <html> <body style=background-image:url(http://upload.wikimedia.org/wikipedia/commons/2/21/Mandel_zoom_00_mandelbrot_set.jpg);background-repeat: no-repeat; background-position: top center;>
I am new to python, so I apologize if this example is trivial. I
This question is coming from a javascript point of view, but it certainly could
This example uses a StringWriter to hold the serialized data, then calling ToString() gives

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.