Comments (4)
I have been looking into TreeTabbedBrowser
and TreeTabWidget
, and while there is plenty of room for improvement in the way the parent and subclass interact with each other... I could not find any actual code duplication. Maybe I missed something? Could you point to specific examples? I did find two TODO comments saying to remove duplication, but they are actually obsolete: the relevant bits were already rewritten to not duplicate code.
Aside from that, both tabopen
and undo
in TreeTabbedBrowser
feel quite hacky, and small changes in the parent class could easily break the current code.
from qutebrowser.
I won't have time to do a more detailed writeup until Sunday but from what I remember it wasn't so much about duplication within TreeTabbedBrowser or TreeTabWidget but between them and their parent classes. Here are a couple of examples from my notes relating to treetabbedbrowser, I hope they make sense to you!
- in
__init__()
the widget set by the parent class is replaced (but not deleted, so it ends up hanging around for the lifetime of the parent) and the work of connecting signals is done again. If we moved the widget instantiation in the parent into a_create_widget()
method (a factory?) we could just override that instead of overriding the whole of__init__()
and re-doing some work from the parent class. This is what I meant by pulling logic that differs out to a helper method. - in
_remove_tab()
an undo entry is created and then the parent method is called withadd_undo=False
. This is kind of "white box" behaviour that relies on knowledge of the parent class and creates more coupling than is needed. Instead of doing that could we add an_add_undo_entry()
to the parent class (like you've already added to the new class!) and override that? This is an example of the subclass working around the behaviour of the parent.
there is plenty of room for improvement in the way the parent and subclass interact with each other
Please take some time to share your ideas! I don't want to get too much into lecture mode because that can be quite off-putting, but this isn't a race where we are trying to check a bunch of boxes as fast as we can. We are trying to make this easier to maintain in the long run so we can keep the project healthy while adding features. I think it helps to put your reviewer hat on and look at the code with a critical eye. Instead of looking for places where the code is obviously wrong, look at places where the code is working fine and think of other ways it could be implemented that might be easier to work with for someone responsible for the code base as a whole.
Aside from that, both tabopen and undo in TreeTabbedBrowser feel quite hacky, and small changes in the parent class could easily break the current code.
Yeah, I think I can see that. Part of the reason for the attributes on the project board is that I don't want to get distracted by polishing absolutely everything, and I don't have these pieces in my head at the moment so I can't weigh in on how much they do or don't need changing. But I think every opportunity to align the child and parent classes could be valuable. I do have a couple of points from my notes on them if you want some backseating:
spoilers: A couple of half baked ideas for improvements to undo and tabopen, don't read if you don't want to be told what to do.
- tabopen: should we be overriding _get_new_tab_idx() for some of all of this instead?
- undo: could we remove some duplication by teaching the undo entry how to restore itself?
Anyway, I'm really glad to see you are taking the time to survey what could be changed before jumping in. I think it can really help to plan out what could be covered by an issue so we can avoid it dragging out in periodic bursts of attention.
from qutebrowser.
Hi @pinusc, I should have a bit more time than usual to put into this project over the next week so let me know if you want to continue with this ticket, and if you want to discuss any potential "duplication" (possibly not the clearest term) in depth.
from qutebrowser.
Oops, forgot to close when I merged the PR. See #8122 for commentary.
from qutebrowser.
Related Issues (20)
- Split off `IPCConnection` in `ipc.py`
- Configurable placeholders for audio status for tabs HOT 1
- Double download prompt segfault
- A stream site/service suddenly started causing renderer process crashed (status 133) on qutebrowser
- Add screen picker completion menu for screen sharing
- Youtube fullscreen doesn't work with Wayland (Ubuntu 24.04) HOT 2
- nitter.poast.org not working with qutebrowser HOT 2
- Feature Request: Picture-In-Picture mode for video players HOT 2
- Session autosave is unreliable HOT 1
- No module named 'PyQt6' after 3.02 update HOT 1
- Slack sign-in fails to redirect back to app HOT 6
- Crash on requesting one-time password on National Insurance website HOT 5
- Websites scroll to the top when statusbar is hidden HOT 1
- Renderer process crash when visiting atuin.sh website HOT 2
- quebrowser 3.2 Segmentation fault
- Build universal binaries for macOS
- Method to download-open a hint HOT 3
- Query state of webpage in userscript? HOT 3
- segfault: `hint links run fake-key -g ":download {hint-url}<Return><Return>"` HOT 2
- Can't view page source when using the uBlock Origin filter 'Badware' 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 qutebrowser.