1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

which is better programming practice?

Discussion in 'General Programming Chat' started by Mutikasa, Jan 28, 2012.

  1. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    575
    Likes Received:
    212
    Let's say I have to download 30 files, rename them, then upload them, this is just an example.
    Now, is it better to write 3 functions and repeat them 30 times, so it will be download all files rename them then upload all, OR, one function with all 3 jobs and repeat it 30 times, so it will be download file, rename it then upload, next file?
     
  2. upl8t

    upl8t Regular Member

    Joined:
    Apr 9, 2008
    Messages:
    475
    Likes Received:
    84
    Location:
    New Scotland
    One function for each job. This allows you to use those functions in any combination down the road. At some point you may want to script something using only two of those processes.
     
    • Thanks Thanks x 1
  3. Deusdies

    Deusdies Regular Member

    Joined:
    May 22, 2009
    Messages:
    261
    Likes Received:
    190
    Agreed. One function for each job.
     
    • Thanks Thanks x 1
  4. Mutikasa

    Mutikasa Power Member

    Joined:
    May 23, 2011
    Messages:
    575
    Likes Received:
    212
    Just like I thought so. Programming is all about control and flexibility of the process