Best strategy for building complex software?

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

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Best strategy for building complex software?

Post by stam » Mon Sep 28, 2020 5:41 pm

Hi all,

i'm going to be porting a rather complex Filemaker database app to LiveCode and am wondering about strategies to make sure this is efficient and maintainable going forward... The database has several entities and has been refactored/refined over a number of years. During previously development i ended up with real 'spaghetti code' and had to spend a lot of time refactoring everything down the line, and am keen to avoid a similar mess in LC.

I'm considering a more regimented MVC approach - 'view' will obviously be a binary stack. Not sure if the controller can be a script only stack? I'm considering a separate 'model' for each database entity and am tempted to create a separate script-only stack for each model -- is that a common design pattern in LC? or do people tend to do something different?

I read somewhere that some have implemented an observer (publish/subscribe) pattern for LC -- is this something recommended? Not sure it adds that much over the 'standard' message path?

Thanks for your views!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Best strategy for building complex software?

Post by dunbarx » Mon Sep 28, 2020 6:45 pm

No idea of the scope of your project, nor the size(s) of the data. But I am old-fashioned, and generally believe that stacks and/or subStacks can do anything imaginable.

Give us a broad outline of the project. Script-only stacks and dataGrids are (generally) not required for functionality, and it sounds like functionality and maintainability are your primary issues.

Craig
Last edited by dunbarx on Tue Sep 29, 2020 5:09 am, edited 1 time in total.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3990
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Best strategy for building complex software?

Post by bn » Mon Sep 28, 2020 7:06 pm

Hi stam,

I don't know if you are aware of Andre Garzia's book "LiveCode Advanced Application Architecture"

https://andregarzia.com/books.html

I find it very instructive. It advocates a Model View Controller (MVC) scheme with examples. Well written.
If you are familiar with MVC it might be a bit basic.


Kind regards
Bernd

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

Re: Best strategy for building complex software?

Post by FourthWorld » Mon Sep 28, 2020 7:34 pm

Great thread topic.

My take:

- Don't get too hung up on "best practice" purity. There's plenty of argument among advocates of MVC, MVP, and other variants that it's too easy to get swept into analysis paralysis. Just about any reasonable separation of code, data, and UI is enough. Formalities and purism eat time and provide little in return.

- Choose with-the-grain options whenever possible, in any language. Why fight against a language's core design, when the engine can do much of the work for you? LC's message path is useful, robust, and very flexibly extensible. Other mechanisms inspired by solutions in other languages, like creating and managing your own message system with dispatching, can help with specific types of edge cases, but until you run into those edge cases you'll just eat time figuring them out.

- Plan on paper first. Really.

- Get two-way data binding done early. FMP has excellent binding out of the box, and I'm surprised for all the DB work our community does no one has shared a generalized library for that. Behaviors can be useful here.

- Exercise daily. It needn't be strenuous, a brisk walk will do. I prefer bicycling (low impact, and I get to do it sitting down <g>). The enhanced blood flow keeps your brain working well, esp in the second half of the day when the post-lunch lag would otherwise set in. Even just 20 minutes makes a tremendous difference. Exercise outdoors is very stimulating in so many ways, often bringing fresh solutions to the work when you return to your desk.

You'll have fun. Keep us posted as you run into challenges. We can help.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Best strategy for building complex software?

Post by stam » Tue Sep 29, 2020 12:50 am

Hey Guys - thanks for the insightful (and varied!) comments...

@bernd - yes I’m aware of the book which is what led me to ask this question. I do like some of the ideas but can’t help but feel that some proposed practices may be redundant in LC and likely to complicate matters unnecessarily for me.
And before I went down that particular rabbit hole I thought I’d ask the experts for common practices ;)

@Craig - yeh I’m kind of feeling that, but thinking of using script only stacks for “model” components as I have a number of similar projects where I can just re-use these and it’s not too difficult to decouple them from interface structures and business logic... probably harder to do the same for view/controllers, so will probably just use a normal stack for these.

Script only would also allow me to parcel out scripts as logical entities into separate files, rather then have one huge script (and actually edit them in Atom, which I prefer). Is there a downside I should be aware of?

I’m thinking of using LiveCloud for the backend which means I can I easily play to LCs strengths with multidimensional arrays - so I see the model scripts as handling the connection with this and getting/setting data that will either be used directly in the interface or fed into business logic.

@Richard - thanks for the very sensible tips... will probably lean a bit towards an MVC-like pattern simply because the app and data lend themselves well to this in my case - but as I’ve not done this in LC yet, and haven’t really seen much discussion about it (so I guess not so important!)

Re: exercise - my day job is hospital physician which usually means I walk between 8 and 12 Km daily just doing my job, so I’m covered on that front ;)
Actually finding time to code is the challenge, so I’m hoping that setting up a more rigid framework to work in will provide an easier way to jump in and out of coding.

Unusually for me, I’ve e actually followed some of Andre’s advice and am in the process of defining public APIs which is turning into a significant exercise (I usually just dive in!) and I’m hoping this structure will make it easier to jump into coding whenever time allows.
But it does kinda feel like a battle plan that probably won’t survive first contact with the enemy lol...

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

Re: Best strategy for building complex software?

Post by FourthWorld » Tue Sep 29, 2020 4:27 am

The battle may seem daunting, but you face no foe alone as long as you can log in here.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Best strategy for building complex software?

Post by dunbarx » Tue Sep 29, 2020 5:08 am

Right. Good stuff, good advice, and others are likely glued to their sets.

One thing I might have glossed over in my puritanical (blinkered?) outlook is that external files may be required as adjuncts to "pure" LC if the dataSets are large.

Craig

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Best strategy for building complex software?

Post by SWEdeAndy » Tue Sep 29, 2020 8:27 am

stam wrote:
Tue Sep 29, 2020 12:50 am
Actually finding time to code is the challenge, so I’m hoping that setting up a more rigid framework to work in will provide an easier way to jump in and out of coding.
One thing I’ve found very useful, when it comes to jumping in and out of coding, is to write notes to myself after a coding session, listing (very concrete) things I need to start with next time. This can shorten the startup time you need to get ”into it” again, picking up the thread, at the next session.

It’s amazing how fast I otherwise tend to forget how my own code was supposed to work and the great solutions I thought I could just store in my head until next time… :)
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9579
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Best strategy for building complex software?

Post by dunbarx » Tue Sep 29, 2020 2:41 pm

It’s amazing how fast I otherwise tend to forget how my own code was supposed to work and the great solutions I thought I could just store in my head until next time
You and I must be related.

Craig

jiml
Posts: 336
Joined: Sat Dec 09, 2006 1:27 am
Location: Los Angeles

Re: Best strategy for building complex software?

Post by jiml » Tue Sep 29, 2020 8:26 pm

- Plan on paper first.
Bingo!

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

Re: Best strategy for building complex software?

Post by richmond62 » Tue Sep 29, 2020 8:41 pm

Personally I tend to ignore how the original software has been written and concentrate on its functionality
(that's a fancy way of saying what the software does), and write that down, or even make a paper model.

Then, starting from the original software's functionality, work out how to implement that in LiveCode.

This will stop you getting badly bogged down in trying to emulate the underlying code.
Last edited by richmond62 on Tue Sep 29, 2020 9:07 pm, edited 2 times in total.

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Best strategy for building complex software?

Post by stam » Tue Sep 29, 2020 8:59 pm

Thanks @richmond62 - sound advice.

That’s how I ended up refactoring the original app - it had become such a code mess it was very difficult to keep updating; I went to the drawing board and used pen and paper then re-wrote the whole thing. It’s been working pretty well for a couple of years now, but I want to get away from using FMP because the the cost and effort required has increased significantly.

So, in a way the hard but is already done - just a matter of making it take shape in LC.

Really the question was a bit more pragmatic - do people use observer pattern? Do people tend to use a bunch of script only stacks, put everything in to just 1 or keep everything in the main stack etc.

I think by default because of how the app will work and the way I previously implemented it, there will be a strong odour of MVC pattern but I won’t fret too much about keeping it pure MVC.

So it was also a question about MVC in livecode and how people tackle that.

But to clarify the functionality has been mapped out in detail already!
Trying to generate an API before I actually start coding it is a new approach for me - but a very interesting exercise. I’ve actually spent quite a few hours in this already and have yet to type a line in LC!

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Best strategy for building complex software?

Post by ghettocottage » Wed Sep 30, 2020 12:26 am

Out of curiosity: did you use Filemaker Server with your app, or did you just keep it all together on the same computer? Did you get into separating data from the user-interface? I remember Filemaker did have that ability and it made designing databases much easier.

Are you moving to a MySQL database?

I started out using Filemaker, then FM Server with interfaces, then I started dinkering with Livecode as a replacement and that led me to setting up a MySQL/Livecode server (and all the things involved with that). It was a steep learning curve, but well worth the time, eventually.

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Best strategy for building complex software?

Post by stam » Wed Sep 30, 2020 10:32 am

ghettocottage wrote:
Wed Sep 30, 2020 12:26 am
Out of curiosity: did you use Filemaker Server with your app, or did you just keep it all together on the same computer? Did you get into separating data from the user-interface? I remember Filemaker did have that ability and it made designing databases much easier.

Are you moving to a MySQL database?

I started out using Filemaker, then FM Server with interfaces, then I started dinkering with Livecode as a replacement and that led me to setting up a MySQL/Livecode server (and all the things involved with that). It was a steep learning curve, but well worth the time, eventually.
Hi GC
The app had to be distributed to any random number of PCs - Ideally at other hospitals as well, but we weren't able to do the latter with FMP.
We had limited (because of budget) seats on server so a large part of this was stand alone apps with plugins... but Claris has now removed the stand alone option and server prices are skyrocketing; and while i found it easy and pleasant to use, it's not really something i can deploy in my workplace because it won't get budgeted (the NHS is not known for spending money upfront for long term savings sadly!).

I had moved to a data separation model after a major re-write of the FileMaker app, more for my convenience when upgrading the software - without this i had to import existing software manually into each new version whereas theoretically you could just drop in a replacement 'interface' file. In reality of course, you end up making some small changes to the database model at times, so half the time i had to keep importing anyway.
It's actually very hard to achieve true data separation in FMP in the sense that ongoing development requires often changes to the 'data' file(s) as well.

I considered MySQL and similar but hosting again became a challenge (there are strict criteria for hosting external databases in the UK healthcare system). I'm likely going to go with LiveCloud as Mark Talluto who runs this is quite responsive and will likely help me get through the information governance hurdles; they have a London based data centre which is a prerequisite for us. It's very reasonably priced and perhaps more importantly it's a service specifically for LiveCode data is LC array-based. And equally importantly after testing the free tier with LiveCloud hosting it does work through the corporate firewall and should allow us not only to use disseminate to any number of PCs/platforms within our hospital but to other hospitals as well... so i'm excited at this prospect!

hope that helps,
Stam

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 366
Joined: Tue Apr 10, 2012 9:18 am

Re: Best strategy for building complex software?

Post by ghettocottage » Wed Sep 30, 2020 2:33 pm

Thanks for the description. I am always curious to hear from people who are immigrating from FM.

As a side note: you might be interested in a feature Richard Gaskin showed me a while back. Basically, if you have a webserver (I think LiveCloud has webhosting built in) with Livecode you can create a launcher file that you distribute to everyone, and have your main stack live on the server. When someone opens the launcher file it downloads the main stack and that is what they use. It lives in each persons computer memory, so there is no bandwidth cost except for the momentary download.

By using this launcher method you only have to keep one stack updated (the one on the webserver).

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”