Re: Getting the right class with inheritance and super()
- From: Kyle Schmitt <kyleaschmitt@xxxxxxxxx>
- Date: Thu, 25 Sep 2008 10:41:18 -0500
On Thu, Sep 25, 2008 at 9:51 AM, Robert Klemme
<shortcutter@xxxxxxxxxxxxxx> wrote:
Since I would recommend using delegation instead of inheritance you
don't have to. If you use inheritance you must make sure that your
class's invariant is not broken.
Upon thinking about it more, and attempting to flush it out in the
inheritence direction, I'm coming to agreement about encapsulate
instead.
I'd like it to. This was a first blush since I needed (more wanted,
but anyway) it in this project.
If you think about it for a moment you'll realize that your
FixesSizedArray is far from usable in every place where an Array is
used. Just think about algorithms that rely on collecting arbitrary
many objects in an Array (e.g. File.readlines) - you cannot use your
FixedSizedArray there.
I agree that it can't be used everywhere, but where I want to use it,
I want it to look and feel very much like an array.
However, the case of File.readlines may be an example of exactly how
I'd like to use it: it gives you a fixed amount of data.
f=FixedSizeArray.new(100)
f<<File.readlines("/var/log/messages")
Then the question becomes does the principle of least surprise. Is it
least surprising to read in the first 100 lines, in this case, and
ignore the rest, or is it least surprising to let the 100 line window
slide to the end, and only deal with the last hundred?
--Kyle
.
- Follow-Ups:
- Re: Getting the right class with inheritance and super()
- From: Michael Fellinger
- Re: Getting the right class with inheritance and super()
- From: Robert Klemme
- Re: Getting the right class with inheritance and super()
- References:
- Getting the right class with inheritance and super()
- From: Kyle Schmitt
- Re: Getting the right class with inheritance and super()
- From: David Masover
- Re: Getting the right class with inheritance and super()
- From: Robert Klemme
- Re: Getting the right class with inheritance and super()
- From: Kyle Schmitt
- Re: Getting the right class with inheritance and super()
- From: Robert Klemme
- Getting the right class with inheritance and super()
- Prev by Date: Re: [RIP] Guy Decoux.
- Next by Date: Re: better test/unit progression display
- Previous by thread: Re: Getting the right class with inheritance and super()
- Next by thread: Re: Getting the right class with inheritance and super()
- Index(es):
Relevant Pages
|