I would not tie populating of data to creation. You could reasonably create a frame and keep it but change the content it displays later. if you populate in onCreate
then you have to free and recreate in order to get fresh data. So having a LoadData()
is a better approach.
Depending on the complexity of the app and the number of forms and frames that you have, it may be handy to have all your Frames inherit from a common base frame. You could then introduce a virtual LoadData
method in the base and override in frame subclasses.
Alternatively, you could also design an interface and have frames implement it. If done properly that could allow you to treat forms, frames or even panels, etc, uniformly.
It is difficult to give you a more specific advice, as it depends on the complexity of the gui and the app. In general, it is always good to have as little logic/code in forms/frames as possible. So introducing some kind of FormManager class that handles registration and display of forms/frames can help isolate this behavior in a single location. But if it's a small, simple app you can get away with just doing it in forms.