From: Gavin Sinclair Date: 2002-12-14T22:36:11+09:00 Subject: Is it wise to extend Matrix? Since the thread "Inheritance question" has become so deep (physically :) and my point is sort of orthoganal to it, new thread. I personally don't believe it makes sense to create a class that inherits from Matrix. Doing so would suggest to me that you are creating a new kind of Matrix. If you are, then perhaps you should visit a local mathematician to see whether there really is more than one kind of Matrix. Same goes for Array and probably some others. In Jim's case, he wanted to add some methods to Matrix. Well, he didn't want to change Matrix directly, but the methods he was going to add would in no way be out of place in the real Matrix class, so to me, inheritance is the wrong approach. Delegation is the key here. Create a new class based on Matrix, add your methods, and forget that Matrix ever existed. Of course, I think there are some implementation problems he had with the type that was returned from some methods - I lost track. But maybe he can come up with a new kind of delegation that solves that. The Stack class in Java was an extension of Vector, which everybody's favourite Ruby advocate Bruce Eckel (!) pointed out in his "Thinking in Java" is a stoopid idea. Whoever heard of a Stack having a method "elementAt(i)" ??? Anyway, I hope we see a satisfactory solution to Jim's implementation problem. This kind of thing has been generating a lot of interest. Cheers, Gavin -- Gavin Sinclair Software Engineer Sydney, Australia Soyabean Software Pty Ltd