Multiple inheritance

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple inheritance

Sebastien Jourdain via vtk-developers
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

pdhahn
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



-- 
Paul D. Hahn
CompIntense HPC, LLC

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

pdhahn
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Sebastien Jourdain via vtk-developers


On 3 Jul 2018 9:07 a.m., Paul Douglas Hahn <[hidden email]> wrote:
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

Thanks Paul. That sounds exactly like what I have done with the vtkCellWithEdges and vtkCellWithFaces classes introduced in the aforementioned merge request.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Bill Lorensen
You may want to look at generic programming to solve your problem.

On Mon, Jul 2, 2018 at 4:31 PM, Todd via vtk-developers <[hidden email]> wrote:


On 3 Jul 2018 9:07 a.m., Paul Douglas Hahn <[hidden email]> wrote:
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

Thanks Paul. That sounds exactly like what I have done with the vtkCellWithEdges and vtkCellWithFaces classes introduced in the aforementioned merge request.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers





--
Unpaid intern in BillsParadise at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Sebastien Jourdain via vtk-developers
Hi Bill

I'm familiar with generics, but it doesn't address the issue here. Defining a base class with knowledge of the behaviour or attributes of its descendant classes is a violation of the Polymorphism principle.

Todd Martin, PhD.
Freelance Engineer/Software Architect.



On Tuesday, July 3, 2018, 3:06:56 PM GMT+12, Bill Lorensen <[hidden email]> wrote:


You may want to look at generic programming to solve your problem.

On Mon, Jul 2, 2018 at 4:31 PM, Todd via vtk-developers <[hidden email]> wrote:


On 3 Jul 2018 9:07 a.m., Paul Douglas Hahn <[hidden email]> wrote:
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

Thanks Paul. That sounds exactly like what I have done with the vtkCellWithEdges and vtkCellWithFaces classes introduced in the aforementioned merge request.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC


______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers





--
Unpaid intern in BillsParadise at noware dot com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Will Schroeder-2
I think what you proposes has a lot of merit. However I start getting twitchy when I think what this means in terms of wrapping code, potential API changes, documentation changes, etc. although maybe it has little impact. (FYI we actually did try multiple inheritance in the 1993-94 time frame when we first started implementing in C++ - a very bad experience due to the awful compilers at that time.) I think for something like this to move forward a proof of concept is required to better understand what the impact on VTK would be.

On Tue, Jul 3, 2018 at 11:08 PM Todd Martin via vtk-developers <[hidden email]> wrote:
Hi Bill

I'm familiar with generics, but it doesn't address the issue here. Defining a base class with knowledge of the behaviour or attributes of its descendant classes is a violation of the Polymorphism principle.

Todd Martin, PhD.
Freelance Engineer/Software Architect.



On Tuesday, July 3, 2018, 3:06:56 PM GMT+12, Bill Lorensen <[hidden email]> wrote:


You may want to look at generic programming to solve your problem.

On Mon, Jul 2, 2018 at 4:31 PM, Todd via vtk-developers <[hidden email]> wrote:


On 3 Jul 2018 9:07 a.m., Paul Douglas Hahn <[hidden email]> wrote:
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

Thanks Paul. That sounds exactly like what I have done with the vtkCellWithEdges and vtkCellWithFaces classes introduced in the aforementioned merge request.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC


______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers





--
Unpaid intern in BillsParadise at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



--
William J. Schroeder, PhD
Kitware, Inc. - Building the World's Technical Computing Software
28 Corporate Drive
Clifton Park, NY 12065
[hidden email]
http://www.kitware.com
(518) 881-4902

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple inheritance

Sebastien Jourdain via vtk-developers
Hi Will

I think what you proposes has a lot of merit. However I start getting twitchy when I think what this means in terms of wrapping code, potential API changes, documentation changes, etc. although maybe it has little impact.

As far as wrapper code is concerned, I expect no problems, as I'm not suggesting moving away from a single inheritance model (in fact that would be disastrous) and Python, Java & c# support the interface concept.

(FYI we actually did try multiple inheritance in the 1993-94 time frame when we first started implementing in C++ - a very bad experience due to the awful compilers at that time.) I think for something like this to move forward a proof of concept is required to better understand what the impact on VTK would be.

The plan would be to add only abstract classes, so that the implementation code would appear on vtkObject descendant classes which are already in the inheritance tree. So documentation should also not be an issue. You can see an example of this in the previously mentioned MR with the GetNumberOfPointsOnFace() method which is implemented in vtkCell3D and the relevant non-linear cell types via the introduction of the vtkCellWithFaces interface/class.

In fact vtkCell3D would also benefit from similar refactoring, as it is already polluted by methods like GetFacePoints() and GetEdgePoints().

Todd

vtkn Tue, Jul 3, 2018 at 11:08 PM Todd Martin via vtk-developers <[hidden email]> wrote:
Hi Bill

I'm familiar with generics, but it doesn't address the issue here. Defining a base class with knowledge of the behaviour or attributes of its descendant classes is a violation of the Polymorphism principle.

Todd Martin, PhD.
Freelance Engineer/Software Architect.



On Tuesday, July 3, 2018, 3:06:56 PM GMT+12, Bill Lorensen <[hidden email]> wrote:


You may want to look at generic programming to solve your problem.

On Mon, Jul 2, 2018 at 4:31 PM, Todd via vtk-developers <[hidden email]> wrote:


On 3 Jul 2018 9:07 a.m., Paul Douglas Hahn <[hidden email]> wrote:
revise "base classes" -> "interface classes"

On 07/02/2018 04:04 PM, Paul Douglas Hahn wrote:
Just one caveat (you probably already know and agree with this). In my experience using C++ multiple inheritance, I think you should try to avoid situations where you have common base classes in the inheritance pathways. Virtual base classes are the usual recommendation to resolve certain problems that arise in such cases, but IMHO having experience with that, I generally recommend against it.

So I recommend your base classes should be of the "mix-in" interface category, not relaying on any common base class. The approach works fine for me in almost every situation.

Thanks Paul. That sounds exactly like what I have done with the vtkCellWithEdges and vtkCellWithFaces classes introduced in the aforementioned merge request.

- Paul

On 07/02/2018 12:44 AM, Todd Martin via vtk-developers wrote:
Single inheritance languages like Java and C# utilize interfaces extensively. Python 2.7+ handles the same concept with abstract base classes, ABCs.

Is there any interest in supporting interfaces in VTK via multiple inheritance from abstract classes (which do not inherit from vtkObject) while retaining the single inheritance model?

In my view there are good reasons to do so. For example vtkCell has methods like GetNumberOfEdges(), GetEdge(), GetNumberOfFaces(), GetFace() etc. which really only apply to multi-dimensional cells (both linear and non-linear); i.e. not points and lines. These methods are forced on the base class design by a single inheritance structure and the linear/non-linear cell sub-types. In my view it would be better if they were distributed across the sub-classes via the concept of interfaces. So I'm suggesting a limited use of multiple inheritance here, not a free-for-all approach. What do others think about this?




Todd Martin, PhD.
Freelance Engineer/Software Architect.



______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers



-- 
Paul D. Hahn
CompIntense HPC, LLC


-- 
Paul D. Hahn
CompIntense HPC, LLC


______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q= vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/ mailman/listinfo/vtk- developers





--
Unpaid intern in BillsParadise at noware dot com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers



--
William J. Schroeder, PhD
Kitware, Inc. - Building the World's Technical Computing Software
28 Corporate Drive
Clifton Park, NY 12065
[hidden email]
http://www.kitware.com
(518) 881-4902


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtk-developers