8000 Reduce usage of untyped interface{} and casting · Issue #840 · coyim/coyim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Reduce usage of untyped interface{} and casting #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
olabiniV2 opened this issue Dec 26, 2021 · 0 comments
Open

Reduce usage of untyped interface{} and casting #840

olabiniV2 opened this issue Dec 26, 2021 · 0 comments

Comments

@olabiniV2
Copy link
Contributor

We have a large amount of places - especially in interactions with other parts of Coy - where the GUI uses the interface{} type and then casts it in different ways. Sometimes, we also use more specific types, but then do type-switches anyway. We should try to rely more on the compiler to help us give advice when we're doing things that are problematic by reducing use of type switches.

There are two big areas where we should be extra careful with this. The first one is with all the MUC message code. Here, we wanted to separate the implementation of the data-types from the session/muc/data package from the representation of messages and other actions. For this reason, type-switches are used a lot - and in some cases just regular switches but based on pseudo-types, such as IsOwner, etc. We should move to using the Visitor pattern for most of these places.

The other place is where we are interacting with different parts of GTK that is untyped. For example, in the ListModel storage, and also using GLib properties. In this places, we should implement wrapping structures or methods, and reduce the place that calls the untyped functionality as much as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0