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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:03:07+00:00 2026-05-12T17:03:07+00:00

When I was programming a Form Validator in PHP, when creating new methods, I

  • 0

When I was programming a Form Validator in PHP, when creating new methods, I needed to increase the number of arguments in old methods.

When I was learning Java, when I read that extends is to not touch previously tested, working code, I thought I shouldn’t have increased the number of arguments in the old methods, but overridden the old methods with the new methods.

Imagine if you are to verify if a field is empty in one part of the form, in an other and in yet an other.

If the arguments are different, you’ll overload isEmpty, but, if the arguments are equal, is it right to use isEmpty, isEmpty2, isEmpty3, three classes and one isEmpty per class or, if both are wrong, what should I have done?

  • 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-12T17:03:08+00:00Added an answer on May 12, 2026 at 5:03 pm

    So the question is:

    If I need different behaviors for a method isEmpty which receives the same number arguments, what should I do?

    1. Use different names? ( isEmpty, isEmpty2, isEmpty3 )
    2. Have three classes with a single isEmpty method?
    3. Other?

    If that’s the question then I think you should use:

    1. When they belong to the same logical unit ( they are of the same sort of validation ) but don’t use numbers as version, better is to name them after what they do: isEmptyUser, isEmptyAddress, isEmptyWhatever

    2. When the validator object could be computed in one place and passed around during the program lifecycle. Let’s say: Validator v = Validator.getInstance( ... ); and then use it as : validator.isEmpty() and let polymorphism to it’s job.

    3. Alternatively you could pack the arguments in one class and pass it to the isEmpty method, although you’ll end up with pretty much the same problem of the name. Still it’s easier to refactor from there and have the new class doing the validation for you.

      isEmpty( new Arguments(a,b,c ) );  => arguments.isEmpty();
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 313k
  • Answers 313k
  • 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 Using reinterpret_cast is acceptable if you know that the pointer… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer Until the time you feel you are ready to mess… May 13, 2026 at 10:45 pm
  • Editorial Team
    Editorial Team added an answer Using only DateTime class: require 'date' d1, d2 = 'Mar… May 13, 2026 at 10:45 pm

Related Questions

I was wondering whether using a Belt and Braces (Suspenders) approach to programming -
Being used to the standard way of sorting strings, I was surprised when I
I am working on a VB.NET WinForms app that was upgraded by Visual Studio
I was wondering how you guys actually develop large applications when you are your

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.