6 Replies Latest reply on Aug 25, 2006 1:25 PM by rudodoo619

    How to clean a code toilet

      I work for a company whose Human Resources Intranet Site was created by about 10 to 15 people. My job is to fix any errors that come across someone who is using the web-site. To describe how crappy this web application is, there are about 5 or 6 folders in the Web-Root each containing anywhere for 15 to 30 files.

      Some of these files have thousands of lines of code in it., and a lot of it is redundant code. Also there are cases of the same files in multiple folders.

      Even though this crappy web structuire allows me to keep my job. I wouldn't mind cleanning it up and having some type of organization in it.

      I notice we rarely have been using CF Components or custom tags. In this particular web-app. So I think that should be a good place to start.

      Can anyone give me some good advice on how I should approach this. I downloaded the Web-site to my computer and turned off the remote server. So I currently am just using local host as my testing server.
        • 1. Re: How to clean a code toilet
          jdeline Level 1
          Sounds like the Web site could use a strong dose of TidyFlush. :-) There are a few things that could have a bearing on the approach you take. What percentage of time do you spend chasing errors for users? Do you have blocks of quality time to devote to a stealth rewrite? How mission critical is this app? How many users does the app have? How well do you understand how the code(not the app) work? Tell us more.
          • 2. Re: How to clean a code toilet
            rudodoo619 Level 1
            Well, the question is more difficult than you think. For the next two weeks I will have some extra time to at least get started.. The Application itself is the what we use to hire new employees but its not our biggest concern. I am mostly doing this for just practice more than anything.

            The code issue is what is the problem. There are identical .cfm files all throught the apps sub folders in the index.

            I guess the number of users depend on how many people are trying to find a position with us both external and internal

            I think the best way to start would be to make CFC and Custom Tags. However, I have never done that before and I was wondering if someone could point me in the right direction
            • 3. Re: How to clean a code toilet
              Level 7
              CFC's would be good for most functions on the site (CRUD) if you are going
              to need the same items on multiple pages and want to have reusable code. All
              the functions of my site are in CFC's (plus they migrate well to Flex, if
              that is of interest to you in the future).

              • 4. Re: How to clean a code toilet
                ranger Level 1
                just throwing in my 2c worth but the simplest fix would be to get rid of duplicate cfm pages. point all to one "master" cfm page and see what breaks. this of course will allow for easy editing.

                rather than cfc's, might just do cfincludes of code blocks that are reused alot.
                • 5. Re: How to clean a code toilet
                  bah1234ir Level 1
                  I did this once before (funnily enough for a HR site) and there were a lot more than 5 or 6 folders X 15-30 files, but that's another story.
                  My approach was:
                  1) configure the web and cf server to capture everything going on, such as errors, 404s, slow running threads etc so at least you can manage the basics first - be ready for a flood of emails first up!
                  2) identify the core functions of the site (are there many or 1 with many sub parts) once you do that, think of how you would make a skeleton of each part; make a list look for repetitive bits, look for process bits and refactor into CFCs or some other logic ! If it is just spagetti code and you want to keep it that way at least ensure there is at least some sort of logic to the way you want pages to flow.

                  Lastly, if there are 10-15 people still working on it (that is a lot for the scope btw, hope there is some control going on for your sake) - make sure you put together a list of development practices and get your big stick out if they aren't followed.

                  I'm not a fan of the master thing (no offence ranger) ever since someone told me about a project they worked on with regards to "assessments" which got abbrievated to ***, and so to access the application, ppl had to go to the ***/master :)
                  • 6. Re: How to clean a code toilet
                    rudodoo619 Level 1
                    I was wondering how long a project like this took you bah1234ir