SAP-docs / sapui5

This is the markdown version of the official SAPUI5 documentation from the SAPUI5 Demo Kit for external contributions.
Creative Commons Attribution 4.0 International
84 stars 137 forks source link

[doc issue] Missing documentation to Event Buses #109

Closed biscimus closed 6 months ago

biscimus commented 7 months ago

Missing documentation to Event Buses

Hello Documentation Team,

Recently, I faced an issue trying to access controllers of child views inserted in the parent view. The concept of event buses really helped to reduce lines of code and to make the entire inter-controller-communication easier (in case there are better ways to solve this problem, please let me know). However, the event bus feature was overlooked by our team for quite some time, since there weren't any documentation pages referring to the feature, but only a single API reference page instead. There are a couple documentation pages describing how to incorporate child views using multiple targets, but no description how these child controllers should interact with each other & communicate information. Event buses also come in handy when generally dealing with publishing custom events, which is why I'm proposing a documentation page for the event bus feature.

Feedback Type (Optional)

None

Page Title on SAP Help Portal (prefilled)

No response

Page URL on SAP Help Portal (prefilled)

No response

KvM2 commented 7 months ago

@biscimus, Thanks for your contribution - we appreciate it. Would you mind pointing out to me any related documentation and where you miss such an event bus-related documentation? Thanks!

boghyon commented 7 months ago

@biscimus Would it be helpful to have something like https://stackoverflow.com/a/46186706/5846045 in the documentation?

biscimus commented 7 months ago

@boghyon Yes something like that would be very nice!

Thodd commented 7 months ago

Hi @biscimus,

concerning the EventBus we have to take the overall application architecture into account. While it is true that you can achieve an inter-controller communication quite easily, it is not always the preferred or best practice way.

We struggle with this topic, since it's highly dependent on the application structure and your needs. We are always a bit flimsy on that topic for a reason... and the reason being: we can't recommend it wholeheartedly ;) Less LoC doesn't necessarily mean better design, so we are a bit careful with this topic.

In general, I would recommend to use the global EventBus as sparingly as possible (if at all).

I'll give you some of my thoughts down below, as well as a concrete recommendation for UI5 apps. But please understand that this is just my opinion. Like any design pattern, the whole topic is contentious and also a reason why we are a bit "weak" on the topic in the developer guide... Ultimately it's highly dependent on your app and the scope of it.

Hope that help's you in your design considerations.

BR,

Thodd


I'll outline the architectural difficulties first:

Now to the technical side of UI5:

biscimus commented 7 months ago

@Thodd Thank you for your detailed input. If the event bus is that much of a sensitive topic, isn't that even another reason to add a documentation regarding this feature?

KlattG commented 6 months ago

@biscimus After lengthy discussion with our developers we concluded that providing additional documentation on the event bus feature is neither necessary nor prudent at this point. We promise, however, to keep an eye on the issue and inform you if anything changes.