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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:49:49+00:00 2026-06-11T17:49:49+00:00

I am teaching Scala for the first time and my students are finding the

  • 0

I am teaching Scala for the first time and my students are finding the deliberate “punning” involved in companion objects very confusing. Consider the following example:

class Stack {
  ... methods such as push/pop
}

object Stack {
  ... factory method(s) and possibly others
}

The confusion comes in when I use verbal phrases such as “a stack object” or “stack objects” or especially “the stack object”. My students have difficulty understanding whether I mean the singleton object Stack or objects of the Stack class.

I’m looking for alternative ways to verbalize such things that beginners can understand more easily. I’ve considered always referring to objects of the Stack class as “Stack instances” or “instances of Stack”, but it seems crazy when trying to teach OO not to be able to call these things objects. I’ve been trying to ALWAYS use the phrase “singleton object” or “companion object” when talking about the singleton object Stack, but the syntax of Scala is working against me there because it only uses the word “object”.

In this case, I could rename the singleton object StackFactory instead of Stack, but that’s only an option for my own classes, not for the thousand and one companion objects already built into Scala.

Edit:

Sorry, I wasn’t clear enough in my question. The main confusion happens NOT when referring to the companion object. In that case, as several people have noted, it is easy enough to use to a phrase such as “the companion object”. Instead, the main confusion happens when referring to ordinary instances. Then, if I say “a stack object” (meaning some stack instance) or “the stack object” (meaning this particular instance), some fraction of the students will think I mean the companion object — even though I did not use the word companion or singleton.

And I can see perfectly well where the confusion comes from, because the word “object” appears in the program text only with the companion object.

  • 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-11T17:49:51+00:00Added an answer on June 11, 2026 at 5:49 pm

    This issue in Scala is certainly not without irony, but even in the Java space there can be naming issues regarding java.lang.Object, its instances, its class and instances of its class.

    For Scala I propose the following terminology:

    • Call instantiated objects “instances”
    • Call objects “objects”

    In the end, I would say that the idea of OO includes objects (in the sense of modules and composition) as much as objects (in the sense of instances).

    Regardless of how you decide, consistency is key, especially for teaching.

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

Sidebar

Related Questions

Teaching myself C and finding that when I do an equation for a temp
I'm interested in teaching myself different data structures, something I currently know very little
I'm teaching myself Scala and I have sort of a philosophical question. Is pattern
I am currently teaching myself c# but am confused by the following syntax: new
My professor is teaching us Scala using Horstmann's book Scala for the impatient, and
I'm teaching/helping a student to program. I remember the following process always helped me
I've been teaching OOP and was trying to convey to my students the important
In teaching a first language to someone with no programming background I am having
I've been teaching game programming and I've spent a lot of time talking about
I've been teaching myself C for a few months when I have time, and

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.