i4Ds / Karabo-Pipeline

The Karabo Pipeline can be used as Digital Twin for SKA
https://i4ds.github.io/Karabo-Pipeline/
MIT License
11 stars 4 forks source link

API Consistency: Parameters in constructors vs. static methods? #389

Open sfiruch opened 1 year ago

sfiruch commented 1 year ago

In the following example, we require parameters in three different places:

observation_settings = Observation(
    start_frequency_hz=100e6,
    phase_centre_ra_deg=phase_center[0],
    phase_centre_dec_deg=phase_center[1],
    number_of_channels=64,
    number_of_time_steps=24,
)

interferometer_sim = InterferometerSimulation(channel_bandwidth_hz=1e6)
visibility_askap = interferometer_sim.run_simulation(
    askap_tel, sky, observation_settings
)

Should we strive for more consistency? If so, in which direction?

Somewhat related, should we tend more towards static methods, or constructors:

fh = FileHandle()
fh.clean_up()
sfiruch commented 1 year ago

@Lukas113 @kenfus @rohitcbscient Opinions?

Lukas113 commented 1 year ago

I think it makes sense to have a convention-document which describes how to organize code in general.

To me, the following makes sense:

So to conclude, to me it seems fine to pass parameters, provide static functions or create objects wherever it makes sense to do so. Also, in my opinion more consistency is desired. I would also recommend to create more protected/private functions where we don't care about API consistency, but for public functions we should. So changing private/protected code (where we care about implementation details) doesn't cause an immediate API breaking change each time we release a new version.

I think this answers the questions you stated to some extend?