Duplicate code


I had a strange behavior in a project and I wanted to remove that. Invisible file names that appears in a List under Windows.

While searching where I load a folder contents and I found that I have two times (nearly) the same code.

The duplicated code was 5 lines long (and do not do excatly what the othe code do) and I will remove it and call the whole and more correct method.

The question is:

do you search for duplicate code in the project development time area ?

Not specifically, but when we find that we’re copying code we seriously look at why. Sometimes code gets copied and tweaked and other times we create a global function. It really depends on what we’re copying.

Hi Bob,

Thank you for sharing your experience on the matter. 99% of the time when I copy a piece of code from a project to another, I put it in Method or Function and I have nearly no change to do it. (that is what my memory recalls).

In that case, I certainly added the Popup ToolItem far after I set the First, Previous, Next, Last (and friends) Buttons. I suppose that after using the software a bit of time, I was thinking that a Popup with direct access to the image - by name - IS a good idea (and so I falled into traps !). I certainly code it as a prototype (put code there to see if it works, and when it worked…)

And one bad never comes alone, the PopupMenu code displayed invisible items (from disk, even if I only wanted some images types), and setting location at top/left of screen was wrong too !

I’ve had controls and code duplicating, one occasion I cut the controls from a Window I decided wasn’t really needed and pasted them into the main form and ended up with them multiplied by 3… maybe I double clicked but 3 times?
Also Right click and paste, a new action method to appear in methods, I’ve had this a few times, no idea why, its really random

It seems to be something with right click and paste ctrl v seems ok
Its more prone to happen if Xojo has been open a long time… it seems to use a lot more memory than any other IDE I’ve used, when the project loads its using 300meg then shoots up to 1.gb when the project runs and doesn’t drop back… on Linux and Mac it goes back to the original value… as a beta tester for some other company this screams memory leak
this is on Win7 64