Page 1 of 1

Advantages of refactoring

Posted: Wed Mar 13, 2019 10:42 am
by richmond62
However crude my method of refactoring with my Devawriter Pro might be

[it largely consists] of shunting shared socking great Switch statements out of individual buttons
into a function in a cardScript]

having only completed about 2% of my projected refactor my stack has shrunk from 120MB to 118MB.

At the risk of sounding incredibly naive, I had no idea that even that small amount of work
could result in a quite significant gain.

I envisage reducing the stack size to less than 50MB.
----
An added advantage of this refactor is that I get to look at some code that is as old as 9 years,
see how goofy it is, and redo it in a less goofy way.

Re: Advantages of refactoring

Posted: Wed Mar 13, 2019 1:12 pm
by bogs
Certainly sounds like your heading in the right direction and cleaning out the cruft as it were.

Re: Advantages of refactoring

Posted: Wed Mar 13, 2019 3:45 pm
by richmond62
I'm not sure if 'cruft' is the right term,

after all, my code worked . . . albeit rather inefficiently,

but, certainly, I am having to face some of my past sins, insofar as what looked good in 2010
looks like a load of clunky stuff in 2019 . . .

How much of that is due to the fact that I have learnt a bit more about LiveCode in those 9 years,
and how much is just that, after 9 years, I can look at old code rather more critically, I don't know.

Re: Advantages of refactoring

Posted: Wed Mar 13, 2019 3:57 pm
by FourthWorld
I hoard code. Storage is cheap - why not? But I have to admit, I find very little I've written five years ago that can't benefit from rewrite, and almost nothing from ten years ago. Technology changes all the time, and our minds along with it.

Re: Advantages of refactoring

Posted: Wed Mar 13, 2019 4:40 pm
by bogs
richmond62 wrote:
Wed Mar 13, 2019 3:45 pm
I'm not sure if 'cruft' is the right term,
after all, my code worked . . . albeit rather inefficiently,
As far as I can tell, that is the exact definition of 'cruft'
cruft
n. Anything old or of inferior quality. (Your new code is superior to the old code.)
n. Redundant, old or improperly written code, especially that which accumulates over time; clutter. (Your new code is less clunky, and you have found ways of optimizing it that you either didn't know previously or have thought out more efficient ways to write it to achieve the same objective.)

Re: Advantages of refactoring

Posted: Fri Mar 15, 2019 8:24 pm
by richmond62
As I am "refactoring": and those quotation marks are there because by that I find that I actually
mean refactoring, tweaking some 'dicky' code and ironing out bugs that pop out at inconvenient
moments during the process: I save each significant 'move' in a new folder:
-
Screenshot 2019-03-15 at 21.20.19.png
-
This means if I get something wrong along the way I can move back a single step rather
than have to re-do 5-6 hours work.

Re: Advantages of refactoring

Posted: Fri Mar 15, 2019 8:28 pm
by richmond62
I have got in the habit of labelling changes and/or additions to code so I can have a vague idea
of what I was playing at in the future:
-
Screenshot 2019-03-15 at 21.25.20.png