I have a feature that spans across a few frames and few units. And I have CommonProjectDefinitions.pas where all types and common methods are defined.
One of the common types is main data type: TProjectDataType = (dtItems, dtInvoices, dtUsers, dtDocuments, ...);
Now I have a MainForm that ads a few Frames as Project data views and each has it's own TProjectDataType.
If I want for MainForm to know what datatype each Frame is, I need to use CommonProjectDefinitions.pas in MainForm,
Because only the TProjectDataType is used by MainForm (and eventually probably some other units), is this way OK (to expose the whole common unit) or it makes more sense to have CommonProjectDefinitions_Public.pas where all common types that are also used by other forms are defined - so I end up with CommonProjectDefinitions_Public.pas and CommonProjectDefinitions_Internal.pas (which contains everything that doesn't need to be Public).
The main concern is to have neatly enclosed units and not everything exposed.
Any suggestions or experience what to do in such case?
@Mike Torrettinni As rule of thumb, use only what you are comfortable with, factories and interfaces have their merits, and yet have their disadvantage as they hinder you coding speed and might restrain and compicate your ability to update and extend ( may be even add features), but that is the point from using them in the first place, so without going in discussing when and where use any algorithm and why, simply put use the shorter and simpler version always, a version of code that you feel comfortable with.
Now to another suggestion and smaller one than DEB or other approachs, add new class or data module lets call it connector, in this connector you can call from mainform events, frames will register them selves to this connector which will maintain a list per event to be called, they will register for receiving each event they require, with this very simple code your main form will call this connector with many diffrent events like refresh, save, load, resize .. ,
resize for me is a must !, when mainform resize i want the frames to adjust too, VCL not aways adjust/reposition as i want, sometimes i want to hide few elements from frame to make it to more revlevant to the user who like the mainform smaller,
anyway frames who had refreshed and need to notify the mainform can call the connector and the connector will call the mainform or you can stick to your approach with return value, here you can add priority (integer instead of boolean) from each frame and the connector will call the mainform for any adjustment for one frame or more.
Such code has zero dependency between mainform and frames, and any changes introduced to one them will not require changing the other, not even look at its code.