Advantages of refactoring

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Advantages of refactoring

Post by richmond62 » Wed Mar 13, 2019 10:42 am

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.

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Advantages of refactoring

Post by bogs » Wed Mar 13, 2019 1:12 pm

Certainly sounds like your heading in the right direction and cleaning out the cruft as it were.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Advantages of refactoring

Post by richmond62 » 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,

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Advantages of refactoring

Post by FourthWorld » Wed Mar 13, 2019 3:57 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Advantages of refactoring

Post by bogs » Wed Mar 13, 2019 4:40 pm

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.)
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Advantages of refactoring

Post by richmond62 » Fri Mar 15, 2019 8:24 pm

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Advantages of refactoring

Post by richmond62 » Fri Mar 15, 2019 8:28 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”