Год выпуска: 2007
Автор: Obie Fernandez
Издательство: Addison-Wesley
ISBN 978-0-321-49045-2 (hbk. : alk. paper)
Формат: PDF
Количество страниц: 384
Язык: Английский
Размер: 2,68 МБ
Описание:
A former colleague of mine used to say that thick books about design
patterns were evidence of an inadequate programming language. What he
meant was that, because design patterns are the common idioms of code, a
good programming language should make them very easy to implement. An
ideal language would so thoroughly integrate the patterns that they
would almost disappear from sight.
The Ruby programming language takes us a step closer to my old friend’s
ideal, a language that makes implementing patterns so easy that
sometimes they fade into the background. Building patterns in Ruby is
easier for a number of reasons:
• Ruby is dynamically typed. By dispensing with static typing, Ruby
dramatically reduces the code overhead of building most programs,
including those that implement patterns.
• Ruby has code closures. It allows us to pass around chunks of code and
associated scope without having to laboriously construct entire classes
and objects that do nothing else.
• Ruby classes are real objects. Because a class in Ruby is just another
object, we can do any of the usual runtime things to a Ruby class that
we can do to any other object: We can create totally new classes. We can
modify existing classes by adding or deleting methods. We can even
clone a class and change the copy, leaving the original alone.
• Ruby has an elegant system of code reuse.