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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:14:47+00:00 2026-05-14T19:14:47+00:00

I want to implement the concept of a Workspace. This is a global concept

  • 0

I want to implement the concept of a Workspace. This is a global concept – all other code will interact with one instance of this Workspace. The Workspace will be responsible for maintaining the current system state (i.e. interacting with the system model, persisting the system state etc)

So what’s the best design strategy for my Workspace, bearing in mind this will have to be testable (using RSpec now, but happy to look at alternatives).

Having read thru some open source projects out there and I’ve seen 3 strategies. None of which I can identify as “the best practice”.

They are:

  1. Include the singleton class. But how testable is this? Will the global state of Workspace change between tests?
  2. Implemented all behaviour as class methods. Again how do you test this?
  3. Implemented all behaviour as module methods. Not sure about this one at all!

Which is best? Or is there another way?

Thanks,
Gordon

Edit

As I started including the ‘singleton’ module in all my code and I realised just how tightly coupled I had made my code, with references to these global instances all over the place.

So I’ve started to remove them entirely and pass references to the global instances instead. But now I’m heading down the route of IOC – passing dependencies down through my constructers.

Is this a good idea in Ruby? Or am I missing something?

BTW you may have gathered I’m new to Ruby!

  • 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-14T19:14:48+00:00Added an answer on May 14, 2026 at 7:14 pm

    Maybe the Singleton module from the standard library would be useful? If you include this module in your class, only one instance of it can be created. You then can use instance variables for managing the state of your workspace etc.

    If this was what you meant by “Include the singleton class”, then I’m sorry, but the term “singleton” gets thrown around quite a bit in Ruby land, usually in this context.

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

Sidebar

Related Questions

I want to implement one-to-many concept in my application. This is the scenario: I
I am getting really confused with this concept: If I want to implement a
i starter in jqgrid, i want implement inline edit in jqgrid i have this
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
I want to implement an application which will work as a parser. User will
Well there is concept Association in UML So I want to implement it using
I am making an app in which I want to implement the concept of
I want to implement the concept of Slide to open concept in my application.
I want to implement and understand the concept of marshalling over my own rpc
I want to implement the concept of a Port of the CCR Framework in

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.