b-rabbit icon indicating copy to clipboard operation
b-rabbit copied to clipboard

[Feature]: Rethinking package classes design pattern.

Open wiseaidev opened this issue 3 years ago • 3 comments
trafficstars

Description

Hey @nidhaloff, I have a question related to the design pattern followed in this class. For me it looks redundant. Take a look at its usage in the tests:

https://github.com/nidhaloff/b-rabbit/blob/f71ed6ed953db752dc72c1d34d9557a2406fd391/tests/test_b_rabbit.py#L10-L11

In order to create an EventPublisher, you have to call the inner class and pass the outer reference, BRabbit, as a parameter to the __init__ function:

https://github.com/nidhaloff/b-rabbit/blob/f71ed6ed953db752dc72c1d34d9557a2406fd391/tests/test_b_rabbit.py#L23

It kind of looks unnecessary to do so since you already have the outer reference, the BRabbit instance. It looks like a self-reference problem or something of that nature. Also, I think this way it will allocate unnecessary space in memory.

Solution

All Inner classes should be moved outside the BRabbit class for better design.

wiseaidev avatar Oct 07 '22 16:10 wiseaidev

@wiseaidev Good idea. Unfortunately, I can't remember the reason for this design. It has been years since I worked on this. Would you be interested to contribute your ideas? I can add you as a direct contributor to this repo in order to give you more freedom.

nidhaloff avatar Oct 07 '22 18:10 nidhaloff

Yup!

wiseaidev avatar Oct 07 '22 19:10 wiseaidev

@wiseaidev Done!

nidhaloff avatar Oct 07 '22 19:10 nidhaloff