# DelegateClass vs. Extending

**URL:** <https://www.ruby-forum.com/t/delegateclass-vs-extending/88909>\
**Category:** Ruby\
**Created:** [March 15, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/delegateclass-vs-extending/88909 "2007-03-15T15:12:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 15, 2007, 3:12pm UTC](https://www.ruby-forum.com/t/delegateclass-vs-extending/88909/1 "2007-03-15T15:12:52Z")

</div>

I was looking at DelegateClass example:

class Tempfile \< DelegateClass(File)  
# constant and class member data initialization…

```
def initialize(basename, tmpdir=Dir::tmpdir)
  # build up file path/name in var tmpname...

  @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL,

```

1. 

```
  # ...

  super(@tmpfile)

  # below this point, all methods of File are supported...
end

# ...

```

end

and was wondering what is the advantage of doing this and not just  
extending the File class? Thanks.
