W dniu 15 stycznia 2010 17:41 użytkownik Jon Cruz <jon@...18...> napisał:
One common approach is to use a "pimpl". And there are others.
My experience with the clipboard suggests that pimpl is bad idea if the class has any private methods. Where do I put them - in the interface or in the pimpl? If I put them in the interface, they can't take the necessary parameters (for example iterators to the "hidden" sets). It leads to every class being split into one class that has pure virtual public methods and a second one that has the the implementation of public and private methods.
It probably depends on API and behavior differences. We definitely would benefit from having such differences encapsulated and constrained to as few modules as possible.
The only difference between __gnu_cxx::hash_set and tr1::unordered_set is that custom hash functions go into a different namespace.
Yes... it was a problem to add control-point-selection.h there. Prior to this, even though you may not have liked the selection-chemistry.cpp file, it was a central place to go for the implementation of selection magic. That is, it had very strong cohesion in that regards.
It's not very coherent, because "selection magic" is not a coherent category. Some of the functions do something to clones, some change z-order, some move the objects between different layers...
So verbs.cpp does dispatching, and selection-chemistry.cpp does selection manipulation.
During tools refactoring I will probably make it private and add some virtual methods to EventContext, so that the node tool won't have to be explicitly referenced in verbs.cpp. For now, adding an extra layer of redirection will only obfuscate things.
We need to see a bit of the actual numbers involved. Among other things, CPU look-ahead and caching can significantly affect performance... I've seen simple arrays and array walking outperform hash tables/maps contrary to Big-O predictions. (If interested, I think MSDN has a decent article on this).
No, it's the other way around. I do not need to empirically justify the use of a hash set, because among the available structures it has the best theoretical performance. You need to demonstrate that other, theoretically slower structures are faster in this specific use case. In ControlPointSelection, the most common operation is checking whether a query point is in the set of selected points. This use pattern suggests a hash set. Other data structures might lead to better performance in some cases, but in absence of concrete data suggesting this, the "natural" data structure should be used.
In other words, if I want to travel as fast as possible from one city to another, an airplane is the best "default" choice. Using a bus will almost always take much longer, unless I know that the two cities are close enough to each other that boarding an airplane will take longer than the bus trip.
Anticipating your reply: ideally we should benchmark everything, but it's not realistic and not very productive.
Regards, Krzysztof