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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:24:16+00:00 2026-05-28T03:24:16+00:00

I have some functionality related to currency conversions in my Zend project. I’d like

  • 0

I have some functionality related to currency conversions in my Zend project. I’d like to make use of the functionality in Controllers as well as Models. Is there a best practice for where to put this code? Or is the fact that the functionality’s used in both places an indicator that perhaps I should rethink the structure of the project so it’s not needed in both places?

  • 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-28T03:24:17+00:00Added an answer on May 28, 2026 at 3:24 am

    I think the purists would argue that if you’re doing currency conversions in your controller code then you’re probably doing something wrong, as there shouldn’t really be any business logic in there. However, sometimes practical considerations outweigh purist concerns. Let’s assume that this is one such case. 🙂

    If your currency class is a fairly simple utility-type class, then I’d lean towards creating a new directory under “application” called “utils” and then adding that directory to the resource loader in the application bootstrap:

    protected function _initResourceLoader()
    {
        $this->_resourceLoader->addResourceType( 'utility', 'utils', 'Utility' );
    }
    

    Then you can create a class called Application_Utility_Currency stored in the file named Currency.php in that directory and call static methods such as:

    Application_Utilility_Currency::convert( $from_currency, $to_currency, $amount );
    

    This approach would be especially useful if you had other utility classes that were also looking for a home.

    However, if your currency class contains richer functionality (such as connecting to external services to obtain exchange rate data, etc), then it would, IMO, be better to treat it as a “Service” rather than a “Utility”. My definition of “model” is fairly loose and includes all data-related services, whether that data is located in the application database or elsewhere, so if the class is of the more complex variety, then I would just stick it in with the other models.

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

Sidebar

Related Questions

I have a project that involves OpenCV among some other media related functionality and
I would like to have some functionality by which if I write <textarea maxlength=50></textarea>
I have some functionality that I need in all my classes which derive from
I have some functionality that needs to be async in my C# app. It's
I have some useful wpf buttons to test some functionality. It would be good
Many mobile web browsers have some default functionality on image hold. For example, user
In my WPF application I have some drawing functionality. I have solved this using
Here's what i'm trying to do: I what to have some FTP functionality in
In C#, I am developing several Windows Services which have some standard functionality so
I have some drag and drop functionality I am using in an xceed grid.

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.