Hi All.
I create a accounting Program, and have so many module like sales, purchasing etc.
I want to break my program to some program that linked each other. How i can make this happens?
For exampled i build main application that have user management, and friends of mine build sales module, purchasing module. And in the future may be some people i don'y know will build some module that support my application (just like CMS in Web Application).
How shared Public Variable and may be database connection?

Thanks for sharing.

Or may be i divide program to some dll file that contain form and function?

Or may be i divide program to some dll file that contain form and function?

Brief answer is take a look at using interfaces. In case you are not familiar with the concept

  1. An interface is used to declare an intent to provide certain services
  2. By services I mean methods and properties
  3. Having defined your interface(s) you must create classes that implement the interface(s)
  4. You have a choice of starting with TInterfacedObject or TCOMObject - an oversimplification but enough to get you started
  5. Delphi does not support multiple inheritance - fortunately - but you can get a classs to implement more than one interface

Just how easy or hard this is depends on how you see your project growing. If you merely want flexibility for your own future needs it can be quite simple. If on the other hand you want to provide a well documented API that others will be able to plug into and extend you will need to do more work.

It sounds like you are getting into some of the more advanced concepts in programming and how you proceed depends upon your level of experience. Before doing anything, make certain you understand some of your options. For instance, check out items in ExplainThat's post above. Also read up on using DLLs. Multiple Modules certainly suggests using them. All modules would benefit from some basic units such as accessing the data structure through the use of a DataModule and one of the many Data Access Component Libraries included in Delphi. If you are not familiar with the details in these concepts, your accounting problem could be an excellent model for exploring their use and application. To start, check out about.com or Marccantu.com for some good information on using Delphi & database components.

You have 2(+1) ways to design:

- Function oriented (easyer): DLLs contain functions you can access, but any object (like a form) created inside a DLL can't be accessed from outside the DLL (without writing "wrapper functions"), and of course you can't pass objects inside te dll as parameters.
So example: You have a simple dialog asking a string. You compile it inside a DLL, and you can use it as an object from inside, so you write a function of the dll exposed through GetProcAddress (in delphi you don't call it directly though) that you can call from inside your program to get the string. If you have more forms, you can export the pointer of them and use that as a handle of the function, but you still can't access them directly.
Of course you can also have object in your program that uses functions from a DLL, but that's usually not usefull.
To understand this better, think about it that a DLL could be written under Delphi or MSVC (Microsofts Visual C), and those two allocates memory to objects differently, and on this level you only have standards to access functions inside the DLL.

- Object Oriented (harder): You use COM Objects. Those are objects that apply a standard, so everything can use them. You still will have to write an interface, but now a much more complicated one. This is perfect to write an explorer extension or a codec, but in private use, don't even talk about it. Still an in proccess COM object that doesn't support threading is not so complicated, but I don't see any point using it here.

- Composite:
I hope you have asked before: Delphi knows the memory allocation of delphi objects, so why can't it use them?! Well it can, just DLLs ain't designed to do this with delphi. Use BPLs instead:
http://delphi.about.com/library/weekly/aa020805a.htm
Still why I've wrote the 1st part, if you want to allow others to write new moduls to use with your application without the complicated COM, then that's your way.

Thanks for all replies.
The goal of what i need in that application are:
1. Flexibilities : others or my team mate can create new function or using other function.
2. Easy managed for update and modifications.
3. Fast : using tiny application, i hope that will make application faster than a huge, complex application.
4. About Datasource. I don't about that, how make datasource can accesses by other app? if all tiny app have each data source and connect it to database for each app, so many memories using for that.
I think will be nice if one dll/plugin or app have Huge Data Module for using others app to lookup table, data master table and frequent using table.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.