Forum > Suggestions
Lazarus Suggestion: Form Designer Ideas (non visual components)
Tony Stone:
Well, I gave the DataModule solution another go, and for me, it's just not a reasonable solution. Moving all my code to the DataModule unit for associated events then becomes problematic when trying to reference items in the main form. This is because you need to include the main form's unit in your 'uses' section, which obviously causes a circular reference error.
To me, this approach feels like using a component intended for runtime processes to address a shortfall in the IDE's design. Frankly, it's just not a solution for what should be a basic functionality of the IDE. I understand my view might be in the minority, and I'm okay with that. Maybe someday, I'll take another stab at making my own modifications to Lazarus (though most of the code there is way over my head), and implement a more elegant way to organize the clutter of non-visual components. :)
For now, I need to get back to removing this DataModule and putting everything back in place. lol
Joanna from IRC:
I use the data module for my sqlite related stuff. I made the data module from the beginning because I wanted to be able to reuse the code.
Applications evolve over time and don’t always scale well.
I have made many design mistakes because of not knowing any better. I know very well how annoying it is to tear apart and redo a project that works perfectly well. However, If a project is not designed well it will only get more tangled and confusing as it expands with new features.
My suggestion is to not modify your existing project at all but to make a new project and copy code/reuse files from current project into the new one with a better design. Maybe reevaluate the overall design and make changes to it.
I once had my layout manager and factory combined In one unit and that was a lot to Untangle. %)
TRon:
--- Quote from: Tony Stone on December 29, 2023, 09:34:26 pm ---Well, I gave the DataModule solution another go, and for me, it's just not a reasonable solution. Moving all my code to the DataModule unit for associated events then becomes problematic when trying to reference items in the main form. This is because you need to include the main form's unit in your 'uses' section, which obviously causes a circular reference error.
--- End quote ---
Solving circular unit reference is discussed in the reference manual topic unit dependencies.
--- Quote ---To me, this approach feels like using a component intended for runtime processes to address a shortfall in the IDE's design.
Frankly, it's just not a solution for what should be a basic functionality of the IDE.
I understand my view might be in the minority, and I'm okay with that. Maybe someday, I'll take another stab at making my own modifications to Lazarus (though most of the code there is way over my head), and implement a more elegant way to organize the clutter of non-visual components. :)
--- End quote ---
It is imo not a shortfall, rather a friendly nudge to make you think about designing your programs another way. But you are ofc in your right to disagree with that.
Hopefully you are aware that also non-visual components can be created at runtime ? That way you do not have any clutter at all ;)
--- Quote ---For now, I need to get back to removing this DataModule and putting everything back in place. lol
--- End quote ---
If you are working a with databases (yes, there is that reference again) then the only sane way to keep things organized is by using a datamodule (at least when you are using the designer which not everyone does) and it works (without circular reference errors). So while that might not be the perfect solution that you perhaps envision I would urge/suggest to give it a proper try (if only to get better acquainted to datamodules and their use).
Regarding to your initial idea, you could always try and drop that to Lazarus developers (e.g. make a feature request by filing an issue) to see what they think about it (though I realize that was intended with your original post but it does not seem to generate the response you had in mind but that might perhaps be because of the holidays).
Joanna from IRC:
When I use data module I create it and use the variables within it from other units. The code in data module only references the database.
I don’t know how well this setup would work for other types of non visual components but I’ve never had circular reference problems.
Tony Stone:
Thanks TRon.. yes I do know how to deal with the circular reference... I only mentioned it to show that this solution creates yet another hurdle for a beginner to deal with if they were trying to do something as simple as keep a design time form clean and organized like the IDE should be doing for them. :) I mean an IDE is supposed to stream line the development process and help you be more organized after all, right? But yeah... I don't disagree with you that a dataModule is a decent solution. I personally feel like it breaks up much code though... you end up having form related code in a separate unit now. I am not sure I think that is organized. Again... I am no expert at all... these are just my opinions.
And yes I suppose your idea of creating at run time is a solution as well... however then, whats the point of an IDE? ;)
When it comes to things like how software should work I am not always stubborn and adamant about being right but this one I have to dig my heals in.
The current way of putting NVC's on a form serves absolutely no purpose and only takes away from the power and usefulness of a good GUI design tool. (yes again my opnion)
Not trying to be too harsh but I just had to let it be known that, it is in my opinion the weirdest and stupidest thing to display them on a form. lol I also understand it probably bothers me more than most other people but some things i get passionate about. I appreciate all the work developers have put into Lazarus...
Navigation
[0] Message Index
[#] Next page
[*] Previous page