Some coding practice advice

For everything that's not in any way related to PureBasic. General chat etc...
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Some coding practice advice

Post by Num3 »

Hello fellow Pures, I need some advice about building a programming layout that can be easily maintained.

I want to build a management software that is connected to a database.
It will have a main window and a sub-window for inputting data.

Here's my dilemma, i want to be able to easily update each of those sub-windows without recompiling
the entire program.

My initial thoughts where to build each sub-window and control code inside a DLL, that can be easly replaced in case
of an update.

But I would like some advice.
jesperbrannmark
Enthusiast
Enthusiast
Posts: 536
Joined: Mon Feb 16, 2009 10:42 am
Location: sweden
Contact:

Re: Some coding practice advice

Post by jesperbrannmark »

Webgadgets and server side scripting with either Purebasic or PHP and not so much emphasis on the client side?
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Some coding practice advice

Post by Foz »

It sounds like you need a plug-in based system.
This app uses a dll plugin based system: http://www.purebasic.fr/english/viewtop ... 27&t=35184

Alternatively, you can create lots of mini exe's, and have a database to launch those exe's. To keep the apps in your window, check out this thread and the linked threads: http://www.purebasic.fr/english/viewtop ... 13&t=42802
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Re: Some coding practice advice

Post by Num3 »

I do all my prototyping in PHP+Mysql, so the project already works that way.
But i do not want to deploy it in PHP, because the server is on the client headquarters, so all code will be available.
I want to build an executable, so no one can easily steal my 3 years of work.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Re: Some coding practice advice

Post by Num3 »

Foz wrote:It sounds like you need a plug-in based system.
This app uses a dll plugin based system: http://www.purebasic.fr/english/viewtop ... 27&t=35184

Alternatively, you can create lots of mini exe's, and have a database to launch those exe's. To keep the apps in your window, check out this thread and the linked threads: http://www.purebasic.fr/english/viewtop ... 13&t=42802
Great, this is more inline with what i want to do, gonna take a look!

Thanks.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Some coding practice advice

Post by Foz »

To take the system we use at work for an example, we went down the route of using DLLs, but have bundled two exe's, App.exe & Launcher.exe

The App.exe starts with a login window, and upon a successful log in, it then checks the db against it's file manifest for a list of updated files to then download. After downloading in the "updates" folder, the App then calls the Launcher, with the App's process id and an automatic login code (for later).

The Launcher then waits for the App's process id to exit, and then moves the downloaded files to the correct location, and then carries on calling the App again where it then automatically logs in using the special code passed between the App and the Launcher.

Golden Rule : ensure your updater works and is 100% solid before moving on to anything else. If the updater fails when you have 500 installs...
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Re: Some coding practice advice

Post by Inf0Byt3 »

Speaking of extendable programs, indeed, the approach of having the updatable parts in DLLs is a good one. In the program you mentioned earlier, I created a set of functions that are common for each plugin type. One set for importers, one set for exporters, etc. The program first loads the DLL and checks it's type and version. Then when it needs to import data for example, the main program sends pointers to callback functions that the plugin will call with the data it has. The main program will then add the data in memory. So basically the DLL calls functions in the main program each time it needs to pass some data. The data exchange itself is based on sending structure pointers between the DLL and the main program.

Another idea would be to code / use an existing scripting language (there was a pretty advanced one made in PB, iirc it was called DracScript), but this could prove to be a bit hard since you'll have to extend the script language to support gadgets, windows, etc.

Please let me know if you need any details, i'll be glad to help.
Golden Rule : ensure your updater works and is 100% solid before moving on to anything else. If the updater fails when you have 500 installs...
Very true :D.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: Some coding practice advice

Post by Rook Zimbabwe »

PLUS if you use updatable DLL idea you can amybe license the software for trials to other companies and make some extra bucks! :mrgreen:

Sell it brotherman!!! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Post Reply