Android / Intent vs. Qt Signal / Slot vs. iPhone? /?

I am trying to investigate the similarity between objects / components on different mobile platforms.

On Android, there is an Activity / Intent concept for transmitting information, and on Qt, there are signals and slots.

Questions that arise here:

  • Is it legitimate to compare Activity / Intent with a signal / slot concept? The most important difference from my point of view is a different level of detail. Although actions / intentions operate on “whole screens” (actions are more accurate, since Activity does not necessarily constitute a separate screen), Signals / Slots are defined for small objects such as Widgets (in fact for every class that comes from QObject).

  • Bearing in mind platform independence, will you say that the concepts are fundamentally different from each other, or can a developer overcome technical differences in terms of communication between objects and “abstract” application logic to a sufficient extent to minimize porting efforts? as?

  • Is there a comparable iOS concept? (e.g. Target-Action mechanism - or more like delegates or notifications provided by ObjectiveC).

+4
source share
4 answers

I can only talk about the difference between the intent of Android and iOS - I have never done anything in QT, but here we go:
Intentions (at least as far as I know) are mainly used to change the state of the phone or change the state of the life cycle of different objects. They are usually not used for finer granularity details, such as notification of changed characters, etc.
In iOS, a notification system exists for both fine-grained and coarse-grained information (for example, system status and even model changes), but it functions in a completely different way.

I do not see a direct similarity between both of these mechanisms. With the intentions of the androids, I can start new Activites and possibly pass some values ​​to other actions if I really need to. With iOS notifications, I can pass any values ​​from A to B, but I will have to implement my own logic, for example, to start a service with a specific notification. In addition, iOS notification management is much more pronounced than Android intent.

+1
source
  • Qt Signal Slot cannot be compared with Android intentions. The signal and slot apply to everything in Qt; it comes from the QObject class, which is the superclass of all Qt objects, therefore, is the central concept of Qt. Android, on the other hand, uses several mechanisms to communicate objects. It uses intentions for actions and services, but also uses callbacks to handle events. They also offer different levels of flexibility: you can submit so many arguments to signals and slots, you can attach some data by intent, but you can only pass the view object for android callbacks.
  • This is fundamentally different because Android not only uses intentions, as explained above.
  • cannot answer this question since I am not an iOS programmer.
+1
source

To compare iOS notifications and intentions on Android, I went to the following summary:

Combinations:

  • Both mechanisms can be used to register for any notifications that the reporting system is changing your applications (for example, the battery level is changing).
  • both types can initiate changes in the state of the life cycle.

Differences:

  • Granularity level
    • Devices are used to transfer information between services, services, or broadcast receivers.
    • Notifications can be used to transfer information between any objects, whether finely granular, to notify sbdy when one GUI element changes, or rough granular, to respond when certain system events occur

  • IPC
    • Intents can be used for communication between applications (implicit intentions, a specific receiving component not mentioned, late binding), as well as communication between applications (explicit intentions, a specified reception component, early binding).
    • Notifications are limited to intra-application communication on iOS (is there any other way to achieve this?)

  • Use case:
    • Preferences are typically used to trigger other actions (for example, displaying a different screen) or to launch certain services (for example, playing music in the background).
    • on iOS, you would have to implement one of your own logic to switch to another screen or start playing any music in the background.

In the end, what I came to was: since these concepts seem to be fundamentally different, is this a real obstacle to the development of platform-independent Android / iOS applications? <sh> Or do you have suggestions on how to "abstract" these mechanisms and minimize porting efforts? (should cross-platform solutions also have the means to translate these concepts into native code behind the scenes?)

0
source

Some time has passed since I looked at Qt, but my memory of the fact that the signals / slots looked awful like the Objective-C (iOS) selectors (especially for IBAction methods). Typical use

[button addTarget: controller action: @selector(resetState) forControlEvents: UIControlEventTouchUpInside]; 

vs

 Qobject::connect(button, SIGNAL(clicked()), &controller, SLOT(resetState())); 
0
source

Source: https://habr.com/ru/post/1337476/


All Articles