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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:01:52+00:00 2026-05-17T02:01:52+00:00

I’m looking for help identifying this design pattern and learning the typical vocabulary it

  • 0

I’m looking for help identifying this design pattern and learning the “typical” vocabulary it uses:

I’m working on a project in PHP, and I’ve created a thin ORM layer that saves generic objects to and from the database. There are two classes that do the work:

  • “my_object” is basically a container for various kinds of data. After being created this object can save itself to the db.
  • “my_object_manager” is used to manage a set of objects, for instance if you wanted to retrieve many of them and iterate through them.

As a simplified example, you could do something like:

$post = new my_object('post');
$post->title = 'foo';
$post->body = 'bar';
$post->author = 'baz';

…and you if you wanted to load a bunch of posts you could do something like:

$posts = new my_object_manager('post');
$somePosts = $posts->getBy('author','baz');
foreach( $somePosts as $aPost ) {
    ...loop stuff here...
}

So, my question is this: In the class definition for “my_object_manager” I need to store a property that identifies what kind of object is being managed. It looks something like this:

class my_object_manager {
    protected $theKindOfObjectThatThisManages;

    function __construct($whatToManage) {
        $this->theKindOfObjectThisManages = $whatToManage;
    }
}

Now, forgive me for not knowing this kind of basic stuff, but I’m self-taught and have a pretty limited programming vocabulary. I’m sure this kind of design pattern is common, but for the life of me I haven’t been able to figure out what it’s called.

I’m trying to write code that other programmers can read and understand, SO, my real question is if you were reading this code what would you expect “$theKindOfObjectThatThisManages” to be called? What is this program design pattern called, and what do you call this kind of an object if you want other programmers to know what it’s doing?

Lastly, the question editor popped up and told me that this question looks subjective and is likely to be closed. I hope that this question is, in fact, ok for Stack Overflow – but if not, where could I ask this question and get an answer?

Thank you!

  • 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-17T02:01:52+00:00Added an answer on May 17, 2026 at 2:01 am

    For your code samples, I would use

    class my_object_manager {
        protected $my_object_type;
    
        function __construct($whatToManage) {
            $this->my_object_type = $whatToManage;
        }
    }
    

    Now, you seem to be following closely the Active Record pattern, of which many implementations exist, you can go see how they do it in practice 🙂

    Usually, you don’t provide access to _manager() objects, but make my_object()s inherit from it. So, you’d have something like

    $posts = new Posts(); //Where Posts() extends my_object_manager
    $somePosts = $posts->getBy('author','baz');
    foreach( $somePosts as $aPost ) {
        ...loop stuff here...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.