Class Design

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jumbojs
    New Member
    • May 2009
    • 20

    Class Design

    Hello,

    Maybe someone can help me. I am having trouble with designing this system I decided to it just stuck all the code into one class.

    The system takes products out of one database and moves them to another database.

    The clients pick settings on how they want the data from the outgoing database formatted to go into the incoming database. So, for example the outgoing database can have a product SKU(a unique number) which can be 12345 XL and the client can choose to slice up that sku and return two skus. Stuff like that.

    All my database code is separated but the main code that uses client settings to return things like SKU, Name, Description. These are all in one class but that class is going on 4000 lines and I want to break it up but I'm not sure how.
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    4000 lines of code in a single class is way too much.
    Try to re-use code. (No copy-and-paste programming style ! Use methods and pass parameters))
    Use a DatabaseManager class and a Settings class to separate code from the Product Class code.
    Different products should have an abstract base class and each of them their own class derived from it.

    Just list some code here and we might see how to split it up furthermore.

    Comment

    • jumbojs
      New Member
      • May 2009
      • 20

      #3
      Code

      Unfortunately, I can't really paste code. My boss wouldn't be happy about that.

      Is there another way to show you bits off code?

      Comment

      • chaarmann
        Recognized Expert Contributor
        • Nov 2007
        • 785

        #4
        Originally posted by jumbojs
        Unfortunately, I can't really paste code. My boss wouldn't be happy about that.

        Is there another way to show you bits off code?
        No, there is no other way. (Except telepathie, but that never worked for me)
        Why don't you just grab a small piece of your code, change the variable names and function names in your editor with find-replace command and then paste it here? You could even change the "secret" parts like hardcoded passwords before posting. (although having hardcoded passwords is a very bad idea!)

        Comment

        • jumbojs
          New Member
          • May 2009
          • 20

          #5
          I'm sending you a mental image of my code right now. Let me know if you get it.

          I'll try to get something up in the next couple of days.

          Thanks

          Comment

          Working...