Skip to content
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

too many classes in Qt #89

Open
Carreau opened this issue Dec 27, 2014 · 10 comments
Open

too many classes in Qt #89

Carreau opened this issue Dec 27, 2014 · 10 comments

Comments

@Carreau
Copy link
Member

Carreau commented Dec 27, 2014

@minrk opened ipython/ipython#7325

We have too many classes and subclasses in the qtconsole code. Right now, we have:

RichIPythonWidget inherits from IPythonWidget inherits from FrontendWidget inherits from (HistoryConsoleWidget, BaseFrontendMixin) inherits from ConsoleWidget, and RichIPythonWidget is the only class we actually use. None of the intermediate classes serve any use.

I think a lot of this is abstraction for abstraction's sake, and we can get rid of most or all of these classes, leaving the one and only real final IPythonWidget as the implementation of all of these things, especially the BaseFrontendMixin, which is a Mixin only mixed into one class. The ConsoleWidget makes a certain amount of sense, since it contains a lot of generic logic, but I think at least, BaseFrontendMixin, FrontendWidget, IPythonWidget, and RichIPythonWidget should probably be consolidated into a single class.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@takluyver commented

Ping @ccordoba12 @epatters @rkern @jonathanrocher @jdmarch - do you directly use any of the Qt console *Widget classes besides RichIPythonWidget? We'd like to collapse the inheritance hierarchy.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@Carreau commented

Can we do that after the codesplit ?

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@takluyver commented

Certainly, that's one thing where it doesn't make much difference, because all of that will be in one repo post-split.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@ccordoba12 commented

Nop, we just use RichIPythonWidget. However, given that that's sort of public API, could its name be preserved?

Edit: I think the other classes are there to create more generic interfaces (like a Python only frontend) but given that there haven't been any movement in that direction, I agree with the simplification.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@jdmarch commented

We also use FrontendWidget. Pinging @pankajp for further evaluation.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@minrk commented

Yup, definitely appropriate for after the code split. I was just working on the qt code, and it was bugging me, so I opened an issue. There's a chance that it will bug me enough to just merge IPythonWidget and RichIPythonWidget between now and release, since the IPython-aware widget that doesn't understand anything but plain text intermediate doesn't make a lot of sense. But I don't think any of this is needed for 3.0.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@minrk commented

@jdmarch can you point to code where you use FrontendWidget? Or at least describe how it's used?

I think getting rid of the small mixin that's mixed into exactly one class should be simple enough. It would leave FrontendWidget unchanged.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@pankajp commented

@jdmarch We don't really "use" FrontendWidget, its use in code is only due to mapping the IPython's widget hierarchy into pyface. Simplifying the widget class hierarchy in ipython would be good, and probably a good time to get rid of some of our code as well.

@Carreau
Copy link
Member Author

Carreau commented Dec 27, 2014

@minrk commented

Based on my understanding, I would probably do the following:

  • Merge HistoryConsoleWidget into ConsoleWidget. I don't think a ConsoleWidget without history makes a great deal of sense.
  • Merge BaseFrontendMixin into FrontendWidget, the only class into which the mixin is mixed.
  • Merge RichIPythonWidget into IPythonWidget. A plain-text-only IPythonWidget doesn't make much sense.
  • Possibly merge FrontendWidget into IPythonWidget, depending on Enthought feedback about how useful a FrontendWidget is, without the IPython part.

That would bring the situation from 6 classes down to 3 or even 2, which I think would be a lot more manageable. One of the most confusing parts of working on the Qt code is the super() hierarchy of some methods, where 'simple' cases are handled in a parent class, but complex cases of the same event are defined in a child.

@Carreau
Copy link
Member Author

Carreau commented Dec 31, 2014

@jdmarch commented

@minrk I think it's clear from @pankajp's response, but to be explicit: as far as we are concerned: go for it

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