{"action":"created","issue":{"url":"https://api.github.com/repos/ivlab/MinVR2/issues/20","labels_url":"https://api.github.com/repos/ivlab/MinVR2/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/ivlab/MinVR2/issues/20/comments","events_url":"https://api.github.com/repos/ivlab/MinVR2/issues/20/events","html_url":"https://github.com/ivlab/MinVR2/issues/20","id":122602874,"number":20,"title":"callback design : VREvent vs name and VRDataIndex","user":{"login":"BenKnorlein","id":16246001,"avatar_url":"https://avatars.githubusercontent.com/u/16246001?v=3","gravatar_id":"","url":"https://api.github.com/users/BenKnorlein","html_url":"https://github.com/BenKnorlein","followers_url":"https://api.github.com/users/BenKnorlein/followers","following_url":"https://api.github.com/users/BenKnorlein/following{/other_user}","gists_url":"https://api.github.com/users/BenKnorlein/gists{/gist_id}","starred_url":"https://api.github.com/users/BenKnorlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenKnorlein/subscriptions","organizations_url":"https://api.github.com/users/BenKnorlein/orgs","repos_url":"https://api.github.com/users/BenKnorlein/repos","events_url":"https://api.github.com/users/BenKnorlein/events{/privacy}","received_events_url":"https://api.github.com/users/BenKnorlein/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-16T21:13:48Z","updated_at":"2015-12-17T15:20:23Z","closed_at":null,"body":"I wanted to start discussing about the pros and cons for different callback designs. Dan, please feel free to attach  your document with different designs and ideas. The basic question for me is \r\n\r\n```\r\nvoid callback(VREvent * event)\r\n```\r\n\r\nor\r\n\r\n```\r\nvoid callback(string name, VRDataIndex dataIndex)\r\n```\r\n\r\nI am a strong defender of the first example, but would still like to discuss. Maybe other designs are better.\r\n\r\nHere are a number of reason why i prefer the first method:\r\nIf we use a class VREvent, which consists of basically a name and a VRDataIndex i see several advantages. Basically there is not much of a difference but maybe the following makes my ideas more clear:\r\n\r\n* Both the name and dataIndex belong together, so there should be no way that they can be separated. They both belong to the same event.\r\n* It fits to standard UI event processing where the event has a name or type and data\r\n* It simplifies processing or deletion as there is only 1 object which has to be taken care of\r\n* The event can be have derived classes, e.g. a VRJoystickEvent, which provides methods to access the data in the VRDataIndex in a more convenient way. (This again also is inline with standard UIs, e.g. MouseEvent ).This will also bring more advantages for later modules (see below). Note: That this are only methods to access the VRDataIndex (in case it follows a default naming convention), so this does not go against the ideas of the basic flexibility.\r\n\r\nHere an idea why the possiblity to derive classes might be interesting: \r\nImagine there is a high-level module for a Joystick. The design of the joystick should be similar to a button in a traditional UI. This means when the Joystick is created, the Joystick registers its callback automatically. When the Joystick receives a VREvent which was assigned to him, the joystick can cast it as a VRJoystickEvent and run its own callback. This would allow a user to create a Joystick and register a callback with it in which he receives a VRJoystickEvent. In this case he would not have to deal with the name of the event or the VRDataIndex which would give the developer a nice interface. (Note: which events to handle could be defined when constructing, or the high-level module could also handle the input)\r\n"},"comment":{"url":"https://api.github.com/repos/ivlab/MinVR2/issues/comments/165481554","html_url":"https://github.com/ivlab/MinVR2/issues/20#issuecomment-165481554","issue_url":"https://api.github.com/repos/ivlab/MinVR2/issues/20","id":165481554,"user":{"login":"BenKnorlein","id":16246001,"avatar_url":"https://avatars.githubusercontent.com/u/16246001?v=3","gravatar_id":"","url":"https://api.github.com/users/BenKnorlein","html_url":"https://github.com/BenKnorlein","followers_url":"https://api.github.com/users/BenKnorlein/followers","following_url":"https://api.github.com/users/BenKnorlein/following{/other_user}","gists_url":"https://api.github.com/users/BenKnorlein/gists{/gist_id}","starred_url":"https://api.github.com/users/BenKnorlein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenKnorlein/subscriptions","organizations_url":"https://api.github.com/users/BenKnorlein/orgs","repos_url":"https://api.github.com/users/BenKnorlein/repos","events_url":"https://api.github.com/users/BenKnorlein/events{/privacy}","received_events_url":"https://api.github.com/users/BenKnorlein/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T15:20:23Z","updated_at":"2015-12-17T15:20:23Z","body":"Yeah. You are right. We do not gain much from Subclassing, when there is no additional functionality in  the VREvent as we do not use the constructor of the Subclass at that level, but maybe we would like to add some at a later stage of MinVR2. we could also have an extra mechanism at a higher level, e.g. a high-level device/plugin/module could register a VREvent factory to create its specific event. \r\n\r\nI think if we do not provide the base (a VREvent) now, the design and usage will have to change a lot if we like to use specific events on a higher level. If we use them now, it will provide us more functionality and more compatibility between low and high level. In additon, we could subclass using a Decorator pattern to provide addtional functionality which would not require calling the specialized constructor in the beginning.\r\n\r\nFinally i also still think that the other points are also valid: Deletion, handling in an Eventqueue etc becomes more clear and easy to handle. And for me both values, name and data should not be separable.  \r\n"}}