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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:25:11+00:00 2026-05-25T21:25:11+00:00

I’m a beginner but I’ve written my first little project and something about it

  • 0

I’m a beginner but I’ve written my first little project and something about it doesn’t really feel right. I hope I can describe the problem clearly.

My whole program is basically a pile of little functions that call each other, and then one or two lines of code that call the initial function to start off the ‘chain reaction’ and return the desired result.

It looks kind of like this (I’m using PHP):

$result = func_A($args);

function func_A($arg1, $arg2){
    $localvar1 = blah blah;
    $value = func_B($localvar1, $arg2);
    return $value;
}

function func_B($arg1, $arg2){
    $localvar1 = blah;
    $value = func_C($localvar1, $arg2);
    $return value;
}

function func_C($args){
    blah blah blah
}

So when I try to go through my code, I’m hopping around all over the place between functions like crazy.

Is there a better way to do this? Should I just be creating local functions within my other functions? This just doesn’t feel quite right.

  • 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-25T21:25:11+00:00Added an answer on May 25, 2026 at 9:25 pm

    Overall this is fine. We’d need to know more about specific goals and what the code is doing to get into more detail. In general, keeping the nuts and bolts in functions and calling them from a sort of main “command” center is a fine approach to procedural programming.

    However, some general high level rules that work for me:

    • Don’t repeat yourself. If you find you’re doing the same things over
      and over again, make a function of that. If you load a value from a
      file, calculate something with it, and echo that, make a function for
      it.

    • Don’t overspecialize too far. Lots of 2 line functions probably
      isn’t a good thing.

    • If you can, be general. Don’t make 5 different functions to connect
      to 5 different databases. Make one function and pass the name of the
      database to connect to it. See the rule about not repeating
      yourself.

    • If you have one function that calls another that calls another, and
      they are always used that way, consider making a single function of
      them.

    • Objects are great for dealing with a set of values and doing things with them. For a quick script, not so much, but if you’re going to do some substantial work like validating data, storing it, reading it in, making it into a single string, that’s a good opportunity to make a class. Classes will conveniently fit into a file which you can then use in other projects as well, and if you do maintenance to this class often, the scripts that use it may not need to be changed at all if your initial design was solid.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but

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.