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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:31:50+00:00 2026-05-13T13:31:50+00:00

I’m developing a CMS largely based on Zend Framework components. Some of the database

  • 0

I’m developing a CMS largely based on Zend Framework components. Some of the database tables for this CMS are as followed:

site
| id | name |
-------------

locale
| languageCode | regionCode |
-----------------------------

site_locale // link sites with locales
| siteId | languageCode | regionCode | isActive | isDefault |
-------------------------------------------------------------

I have a model named Site which consists, amongst others, of the following methods:

getId()
getName()
listLocales() // list all locales for this site

I’m kind of on the fence on how granularized I should define models:

One option would be to return SiteLocale objects/models (in other words a DB table representation) from the listLocales() method, where these SiteLocale objects contain the following methods:

getSite() // returns the Site model
getLocale() // returns a Zend_Locale
isActive() // is this locale active for the site this model represents?
isDefault() // is this the default locale for the site this model represents()

The other option would be to simply create the following methods in the Site model, and be done with it:

getDefaultLocale() // simply return the default site locale as Zend_Locale
listActiveLocales() // simply return all active site locales as Zend_Locales
listAllLocales() // simply return all site locales as Zend_Locales

What do you feel is the right way to go? And why?

Furthermore, would the first option (or perhaps even both options) violate the Law of Demeter?

EDIT (22 jan)
Although I like Jeff’s answer, Im still open for new/other perspectives.

  • 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-13T13:31:50+00:00Added an answer on May 13, 2026 at 1:31 pm

    First, regarding the database tables: You could probably normalize the database further. There’s duplication between the locale and site_locale tables. Of course, I’m not seeing the big picture here so there might be something behind the way you’ve done it.

    Frankly, either option is fine. I would choose the design that makes your code more readable and maintainable. For instance, if you chose the first option, would you end up with loops like this all over the place?

    site_locales = site.listLocales()
    foreach (site_locale in site_locales) {
        if site_locale.isDefault() {
            do_something(site_locale.getLocale())
        }
    }
    

    If so, then I’d avoid it and go with the second option and end up with:

    do_something(site.getDefaultLocale())
    

    This is much more understandable with a quick glance. Maybe it’d even improve your site’s performance.

    However, if you think you’re going to do a lot of work that utilizes lists of SiteLocales in the future, but you don’t know exactly what you’re going to do beyond getDefaultLocale(), listActiveLocales(), and listAllLocales(), then perhaps the first option might be ideal. Or you could even use a combination of the two.

    As for the Law of Demeter, it’s more like the Guideline of Demeter. It’s OK to break any rule as long as you do it consciously, understand why you’re doing it, and understand the consequences, if any. For instance, if breaking the law leads to more maintainable and readable code, yet you still preserve a high-level separation of concerns in your application, it’s generally OK. So I wouldn’t worry about whether or not either option breaks the law.

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • 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 On MySQL forge: RandomDataGenerator: The Random Data Generator allows the… May 13, 2026 at 11:04 pm
  • Editorial Team
    Editorial Team added an answer If in doubt then you can do something like this:… May 13, 2026 at 11:04 pm
  • Editorial Team
    Editorial Team added an answer According to www.w3.org/TR/xhtml1/#h-4.8 the CDATA section can be defined as:… May 13, 2026 at 11:04 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

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.