Comments (6)
@edwinyzh I completely agree with @Nillissen .
It is true that using interface there is a little bit of additional work to create the interface but the benefits are so great:
- Memory Management: in this way DEB is not responsible anymore to free the objects that were passed to all subscribers
- The above involves in a faster execution because there is no need anymore to clone the object in order to pass different objects to subscribers. It was necessary before because they are async events and you cannot know when to free it
- Removing external dependencies: no clone no need of external units like RTTIUtils for object clone
- No memory leaks and DEB is not responsible to put you on the "wrong way"
- Cleaner repo. In addition to removing the external dependencies, the PR with the changes from an Object event to interface shows how much simple is now understand the code and architecture
I think given the above it is going on the right direction.
Happy to discuss and understand further your points :)
from delphi-event-bus.
@edwinyzh I must disagree with you 110%.
While the implementation of a message is only slightly more cumbersome, the benefits of an interfaced implementation makes up for this multiple times over.
I assume that you just don't understand the changes or the benefits of interfaces... because being lazy (needing to implement a little more code for each message) isn't a very good reason, especially seeing its your only reason.
This new implementation, particularly if you have multiple subscribers, greatly improves the speed and performance of the Delphi Event Bus. Also, it makes it much better if you are wanting use the Delphi Event Bus inside DLLs.
from delphi-event-bus.
@Nillissen and @spinettaro ,
Thanks for your comments. Now I'm reviewing my opinion. First, to clarify, it's not about being lazy, but to avoid duplicated codes.
Re. the benefits of events being interfaces, while I understand it simplifies the implementation of the DEB internals, but from the user's perspective, isn't that I can already use interface with the old version, just define:
TFileChangedEvent = class(TObject)
published
property SomeInterface: ISomeInterface read..; // will be set to nil in Destroy to avoid memory leaks.
end;
Re. the performance, with the old version I can already achieve great performance by defining published properties
for the event object and cloning them using the good-old, high performance RTTI (system.TypInfo.pas
)
Correct me if I'm wrong, and I appreciate your opinions.
from delphi-event-bus.
@edwinyzh in the case you mentioned it is still an object with all the consequences.
You are proving that we can achieve great performance with RTTI and published properties, that is ok, but given the fact we have removed the whole part that is not a problem anymore. We don't have to clone the object, facing again with RTTI and so on... Not sure if you got the point where we removed all of those and consequentially the code is easier and faster because is doing less, achieving more. how can we be faster than not doing it anymore? :D
from delphi-event-bus.
@spinettaro , I'm reviewing my opinion, and will try more (but the latest version didn't compile under XE4, need to find another time to fix it).
If I'm just starting out, I might be happy with the new interface-based design, however, with the existing code, I'd rather stay with the old version since I can already solve both the performance issue with old RTTI and passing of interface with the old Tobject-based events...
from delphi-event-bus.
closing
from delphi-event-bus.
Related Issues (20)
- consider making arguments const that are of managed types such as interface, string, TValue and so on HOT 1
- You are mistakenly attributing some code to me that is not HOT 1
- Error invoking subscriber method. Subscriber class: <something> . Original exception: EInvalidCast: Invalid class typecast HOT 33
- Error Undeclared TEventBusFactory HOT 4
- Hang on splash screen HOT 8
- Minor improvement of subscriber registration HOT 3
- REQUEST: Set Context on registration HOT 19
- Faster MREW for DEB ? HOT 8
- Remove dependency on DUnitX.Utils HOT 1
- Threading issues with asynchronous messaging to inactive subscription HOT 5
- Request/Reply pattern HOT 2
- [Question] "Active" property in TSubscription - how to use it? HOT 3
- TList inside posted event objects empties on Delphi 11 Alexandria HOT 2
- SubscribeAttribute in public, protected and private methods.
- DEB on Android HOT 2
- Crashes galore on theme change HOT 4
- Background / Async tasks deadlock HOT 1
- Question: Explanation/Examples for TThreadMode Subscriptions HOT 1
- About thread mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delphi-event-bus.