View Single Post
Old 10-03-2013, 10:27 PM   #69
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
Quote:
Originally Posted by Katsunami View Post
I hope the original designer of Sigil had a very good reason to do it like that. Personally, I would never have intertwined Sgil's GUI and business logic.
The GUI is the business logic. It was designed as an application not as a GUI with a library. This is how most GUI applications are designed. Tight coupling between the GUI and business logic.

Don't forget the GUI need to show the data elements. The GUI needs to hold those elements. You can have them stored in a library object but then you need to duplicate them for the GUI to display them because the GUI needs them in a format understandable by the GUI. So you end up with two options.

1) You have two sets of the same data that need to be kept in sync. Make a change to the GUI and make sure you change the lib version. Make an API change using the lib then you have to ensure the GUI gets updated. In this case how do you inform the GUI the elements changes? You need to signal to the GUI that that happened. Now you have a whole lot more logic to deal with.

2) Put the data into the GUI format (model and view based not necessarily owned by the GUI). Then you only have one copy to deal with and you don't need extra logic for syncing. You could have a library that uses the GUI model for the data but you're in the same boat because it's coupled to the GUI framework and not really a library (in the sense of a decoupled reusable component) at that point.

This is a basic trade off in GUI programming of dealing with time and effort to get something done. What it really comes down to is why spend the extra time and effort on something that you're design isn't supposed to ever need to do.

Quote:
Originally Posted by Katsunami View Post
(Even if it wasn't for the fact that, when I was in university, it would almost certainly lower your mark by two points or so if you did something like that without a *very* good reason...)
Have you seen how the C# classes at university are taught? GUI builders where the business logic goes into the GUI event handlers.

Quote:
Originally Posted by Katsunami View Post
What version of Python does Calibre use at this moment? There is some (very small) stuff I may want to add to one of Kiwidude's plugins. I think it's a good exercise to get going with Python and take a first look at how Calibre actually works, but of course then I must use the same Python version as Calibre does.
Calibre uses and ships with 2.7. This is mainly because of the effort involved in porting all of calibre to Python 3. New code however has all Python 3 compatibility features enabled so it's pretty close to what you'd write for Python 3.

Quote:
Originally Posted by DiapDealer
Python's standard re module leaves a lot to be desired with regard to non-ASCII text
Good to know. I don't deal with non-ASCII myself so it's never been an issue for me.

That said Sigil doesn't use Qt's regex for user level searches anyway. I wrote a custom bindings for QString to libPCRE and all the replacement code in Sigil because I found QRegExp lacking. Qt5's new PCRE based replacement is still lacking the replace options mine supports. So, that doesn't necessarily negate Python. A different regex library like the one you mentioned could be used in place of Pythons standard re.
user_none is offline   Reply With Quote