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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:15:12+00:00 2026-05-15T00:15:12+00:00

Preface: Yes, I’ve read: http://drupal.org/node/547518 I am writing ‘foo’ module for Drupal6, where I

  • 0

Preface: Yes, I’ve read:
http://drupal.org/node/547518

I am writing ‘foo’ module for Drupal6, where I am organizing the code in an OO fashion.

There’s a class called Foo that has a bunch of setters and accessors, and it is working quite well at abstracting some pretty nasty code and SQL.

The question is is it common practice to expose a class for other modules, or is it better to wrap things in the more typical foo_myfnname()?

For example, if I am writing the module’s docs, should I tell people to do this:

$foo = new Foo();
$something = $foo->get_something();

or tell them to call:

foo_get_something();

which under the hood does:

function foo_get_something() {
  $foo = new Foo();
  return $foo->get_something();
}
  • 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-15T00:15:13+00:00Added an answer on May 15, 2026 at 12:15 am

    Difficult to say, and I don’t think there is something like a ‘common practice’ for this. Taking the ubiquitous views module as an example hints on wrapping common API calls in ‘standard’ functions, and leaving the usage of the object(s) for advanced stuff only.

    Personally I’d base the decision on the intended API audience. If you’re addressing the ‘broad’ Drupal user base, forcing them to use Classes is probably (unfortunately/annoyingly) still a bit stretching, as many part time PHP users will have no proper concept of OOP (heck, even ‘professional’ PHP devs often don’t have it).

    If on the other side your intended audience consists of developers only, providing a proper OO layer ‘as is’ should be ok, and probably less confusing than the mixture that results otherwise (using views as an example again, I often started using one of the convenience wrapper functions, and found myself rewriting quite some code later on just because I needed this tiny little change that required direct object usage – better to be consistent and use objects from the beginning).

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

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Please note: this is not an attempt to provide a… May 15, 2026 at 1:18 pm
  • Editorial Team
    Editorial Team added an answer You need to change the line where you build it… May 15, 2026 at 1:18 pm
  • Editorial Team
    Editorial Team added an answer You could use split.screen(): par(bg = "white") # erase.screen() will… May 15, 2026 at 1:18 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.