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

  • Home
  • SEARCH
  • 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 7430873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:12:31+00:00 2026-05-29T09:12:31+00:00

I am currently refactoring an application into multiple classes in an attempt to fulfill

  • 0

I am currently refactoring an application into multiple classes in an attempt to fulfill Single Responsibility Principle; however, many methods in the original mammoth classes use one common “metadata” object (bound as a class property) for their business logic.

For example:

if($this->metadata->applyTracking) {
 // perform tracking logic
}

When I am separating these classes out, I am considering two options:

  1. Passing this object to particular methods of the class, on case by case basis (Can be many occurences).
  2. Adding this object as class properties (Many classes will have this property injected).
  3. Making the object as a Singleton (I am wary of this approach since it may share the same fallbacks as globals)

Any advice on which path to take?

  • 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-29T09:12:32+00:00Added an answer on May 29, 2026 at 9:12 am

    Method #2 seems to be best. I would inject an object repository, in which each member of the repository would be a different object that provides a different service. An example class can be found here: https://github.com/kenaniah/insight/blob/master/classes/registry.php

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

Sidebar

Related Questions

I am currently refactoring an application in which classes can call observers if their
I'm currently refactoring a console application whose main responsibility is to generate a report
I am currently refactoring an application that prints its status to the console window.
I'm currently reviewing/refactoring a multithreaded application which is supposed to be multithreaded in order
I am currently refactoring a large Java application. I have split up one of
I'm in the process of refactoring some logic built into a Rails application into
I am currently refactoring an application which uses exceptions for logic flow. The code
I am currently busy refactoring big parts in my application. The main purpose is
I am currently refactoring my code for a web application developed using ASP.NET MVC3
I'm refactoring an existing (Ajax) Java Web application, which currently holds lots of its

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.