Thread: A clever way to increasing productivity

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    106

    A clever way to increasing productivity

    I need a program that will replace a word, lets call it "joe" with any word I tell it to, say "mike". The reason is because I've just creative a massive function that I need to have duplicated about 5 times, with very minor changes. I need a program that will scan the file and make theses changes accordingly. Is such a program available? I could justs make this program myself but perhaps it is not worth it (time wise). These functions in question are ~500 lines long.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > The reason is because I've just creative a massive function that I need to have duplicated about 5 times, with very minor changes.
    That sounds like the change should become a parameter to the function, so you only have ONE copy of it to maintain in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I wonder what kind of editor you are using that doesn't have search and replace.

    Anyway, if somehow in your circumstances this turns out to be a good idea to have five functions (I can't imagine what those circumstances could be) and you don't have search and replace (I mean, even vi has search and replace) then I guess you want sed. I guess.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    106
    one function compares two files for max values, the other compares for minimum values, so the ">" change, also some var names.

    Cool, SciTE has it.

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    you can pass the comparison function to the function as well as the other parameters. Having to copy and paste code is a sign of poor design.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Dynamically Increasing Array of Integers
    By laserlight in forum C++ Programming
    Replies: 30
    Last Post: 07-04-2008, 07:27 AM
  2. increasing series
    By ronenk in forum C Programming
    Replies: 3
    Last Post: 07-21-2004, 02:45 AM
  3. C# and productivity.
    By incognito in forum C# Programming
    Replies: 4
    Last Post: 06-23-2004, 07:08 AM
  4. increasing chance.
    By davee in forum C++ Programming
    Replies: 5
    Last Post: 10-23-2002, 12:32 AM
  5. Replies: 2
    Last Post: 03-07-2002, 10:14 AM