Java: Minimizing code duplication

Discussion in 'Mac Programming' started by wrldwzrd89, Sep 23, 2011.

  1. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #1
    Right, so I have a family of applications written in Java, under the name "Katie". There are 6 components: KatiePlayer, KatieEditor, KatieRoller, KatieTester, KatieDumper (used only during the development process) and KatieCommon (common code all other components use). The two components I'm interested in are Player and Tester, for the purposes of this discussion: Tester has some debugging functionality not in Player, but other than that the two are pretty much identical. What I'd like to do is put the code that's exactly the same into some sort of 7th component, and have the two reference it. However... this is complicated by the fact that direct callbacks from common code to the application engine aren't allowed - instead, whenever such a callback is required a script is generated and sent back to the caller, who is then responsible to run it using the script runner. Just to make things even more interesting, there are actually 3 such scripting systems: Internal (used for callbacks to the game engine internally), Editor (used for callbacks to the editor engine internally), and Game (users can interactively write these with the script editor). I'd post some sample code but the project is WAY too big to attach, even as a ZIP file - it's around 20 MB uncompressed, after stripping out the binaries and various metadata.
     
  2. wolfenkraft macrumors regular

    Joined:
    Mar 6, 2008
    #2
    Hey,

    Putting them into a common component is one way, however, have you thought about using AOP? Testing/debugging are 2 things that AOP is actually pretty good at. AspectJ is definitely usable.

    side note: wife went to solon high, I grew up 10-15 mins away. Small world, nice place.
     
  3. wrldwzrd89 thread starter macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #3
    Hey, thanks! I'm afraid I don't know about AOP or AspectJ.
     

Share This Page