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

The Archive Base Latest Questions

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

How do people design their service layer interfaces? I’m programming a large web application

  • 0

How do people design their service layer interfaces?

I’m programming a large web application (in PHP) and we’re using MVC, and programming thin controllers e.g. (pseudo code follows)

public savePersonAction() {
    $input = filter($_GET);
    ... input validation ...

    $result = $this->_service->savePerson( ? );

    ... etc
}

Should savePerson in the service take an argument of the entire $input structure or context (in PHP, an associative array)?

E.g. this –

public function savePerson(array $input) {

or should one separate out all the input fields and provide a “hard” interface e.g.

public function savePerson($title, $firstName, $lastName, $dateOfBirth, ... etc.. for many more) {

Thanks.

Paul

  • 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-17T23:01:42+00:00Added an answer on May 17, 2026 at 11:01 pm

    If you’re going to follow the MVC spirit your savePerson method should not accept the raw input. It shouldn’t be directly coupled with the format of the data coming from the ui. Instead it should accept input defined in the terms of your service domain, like a “person” object. (This could just be an associative array like Cobby suggested). It would be the job of the controller’s action method to map the raw input to the format required by the service.

    The benefit of this extra translation step is that it isolates your service (model) from the ui. If you implement a different ui, you don’t need to change the service interface. You just need to write new controllers (and views, of course).

    While your example like savePerson($title, $firstName, $lastName...) is the right idea, it’s usually a bad sign when you have methods with more than 2 or 3 arguments. You should be able to group related arguments into some kind of higher-level object.

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

Sidebar

Related Questions

I'm trying to design a model for a application allowing 2 people to bet
I am running into a design disagreement with a co-worker and would like people's
From discussions I've had about language design, it seems like a lot of people
People always advised me that if I am doing some application that should use
In MVC/MVP style applications that have Controller/Presenter classes within the Client Application assembly and
I'm looking for feedback on what other people use on their ASP.NET projects to
I am setting up a web service and i'm unsure about the most efficient
People have been developing own solutions to the following problems: Consistent messaging frameworks for
People keep giving me examples with carp instead of warn. Why? What makes carp
People use frequently something like: <ListBox ItemsSource={Binding ElementName=thisControl, Path=ListIndexes}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Label Content={Binding

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.