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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:50:41+00:00 2026-05-14T23:50:41+00:00

/is n00b Through the gift of knowledge and expertise encoded here, I am doing

  • 0

/is n00b

Through the gift of knowledge and expertise encoded here, I am doing my best to avoid n00b mistakes as I learn the basics of programming.

I use functions when I (think I) can in PHP, and keep them somewhat sorted in different includes.

The n00b problem I’m running into now is situations where perhaps 4/5th of an existing function is relevant to a new need. Maybe there are a slightly different set of inputs, or an additional calculation or two in the series, or output needs a different format/structure… but the core of the function is still applicable.

Is there a good rule of thumb regarding when one should bolt-on crap to an original function and when one should (literally) copy & paste most of it into a new function and tweak to fit the situation?

On the one hand I feel bad duping code, on the other I feel bad cluttering up an existing function with stuff not always needed…

  • 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-14T23:50:41+00:00Added an answer on May 14, 2026 at 11:50 pm

    A good rule of thumb is: never copy & paste.

    If 4/5ths of functions A and B are identical, split them up. Have both of them call a new function C that implements the common part.

    If you show the code where you’re having this problem, we can suggest how to best split it up.

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

Sidebar

Related Questions

OK n00b here with SOAP, Would like some clarification on how to use SOAP.
python n00b here doing the pythonchallenge, stuck on middle of a level right now.
N00b programmer here... Trying to store something into a string to use it in
Emacs n00b here, I've fiddled a bit with it in graphical mode and so
Excel n00b here. I am able to do simple stuff with Excel (simple, meaning
Total n00b to C# and events although I have been programming for a while.
Serious n00b warning here; please take mercy! So I finished the Nerd Dinner MVC
I am a rails n00b. I want to use tinyMCE instead of a textarea
I am a N00b here . I print my currency like this : -(IBAction)buttonPressed1:(id)sender
N00b here, having problems escaping strings. I used the QuotedStr() function - shouldn't that

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.