Prime Metaprogramming Ruby Author Paolo Perrotta – Intimatenights.co.uk

Metaprogramming Ruby Metaprogramming Ruby is one of the books that has been taking the ruby programming community by force, and it is easy to see why Metaprogramming has been espoused for quite some time as one of the most compelling features of the language, and for a lot of newcomers to the language it seems a complicated and arcane subject reserved for those who really know the hows and whys of programming in Ruby A book that provides insights into this subject is destined for the bookshelves of rubyists ever Metaprogramming Ruby is one of the books that has been taking the ruby programming community by force, and it is easy to see why Metaprogramming has been espoused for quite some time as one of the most compelling features of the language, and for a lot of newcomers to the language it seems a complicated and arcane subject reserved for those who really know the hows and whys of programming in Ruby A book that provides insights into this subject is destined for the bookshelves of rubyists everywhere as they seek to hone their Metaprogramming skills.The book itself is written in a fairly novel fashion It has 2 parts, the main one being composed of 5 chapters that follows a fictional week of work for a pair of ruby programmers delving into metaprogramming to solve various tasks The 5 chapters form a fairly in depth look at the Ruby object model, the various intricacies of it and, obviously, the metaprogramming aspects that deal with manipulating and playing around with the object model at run time The last day of the week is then on what most would class as quintessential metaprogramming code that writes code The second and much smaller part of the book is about metaprogramming in rails This is a very quick tour of some key parts of rails design that really shows metaprogramming in action, with examples of ActiveRecord s dynamic attribute and finder methods The book is summed up with a chapter on how to use metaprogramming safely, with examples showing how to test a class that uses metaprogramming techniques and on how to guard against unintended side effects that are the cause of many problems.The book as a whole is well written, with a novel and easy writing style, and it presents some fairly complex ideas in a way that is simple and accessible If you have been programming in ruby for some time then it is likely that this book won t contain anything shockingly new but it could help to clarify some key points and help you understand Ruby better like it has done with me If you are a newcomer to Ruby, then the content of this book could open your eyes to a whole new vista of possibilities with Ruby and programming in general just be careful to not over do it It s a very useful book for those who want to learn about the ruby language anatomy, and how objects work, the book is a bit old using ruby 1.9.3 and rails 2.something but most rules apply regardless of the version you re working on right now. Everyone in the Ruby world seems to be talking about metaprogramming how you can use it to remove duplication in your code and write elegant, beautiful programs Now you can get in on the action as well This book describes metaprogramming as an essential component of Ruby Once you understand the principles of Ruby, including the object model, scopes, and eigenclasses, you re on your way to applying metaprogramming both in your daily work and in your fun, after hours projects Learning metaprogramming doesn t have to be difficult or boring By taking you on a Monday through Friday workweek adventure with a pair of programmers, Paolo Perrotta helps make mastering the art of metaprogramming both straightforward and entertaining The book is packed with Pragmatic examples of metaprogramming in action, many of which come straight from popular libraries or frameworks, such as Rails Programming challenges that let you experiment and play with some of the most fun, out there metaprogramming concepts Metaprogramming spellspractical recipes and idioms that you can study and apply right now, to write code that is sure to impress Whether you re a Ruby apprentice on the path to mastering the language or a Ruby wiz in search of new tips, this book is for you Every Ruby developer should read this book, if only to learn some of the depths of what is possible in the language, and how the ideas from different paradigms OO, message passing, FP can come together with such power.The book is conversational in tone, and the idea of spells discussed throughout provide helpful mnemonics to recognize the concepts in the wild later.I read this after attempting to write Rails plugins a lot of what seemed quite unusual to me or sensible, if a bit quirky now Every Ruby developer should read this book, if only to learn some of the depths of what is possible in the language, and how the ideas from different paradigms OO, message passing, FP can come together with such power.The book is conversational in tone, and the idea of spells discussed throughout provide helpful mnemonics to recognize the concepts in the wild later.I read this after attempting to write Rails plugins a lot of what seemed quite unusual to me or sensible, if a bit quirky now makes a lot of sense The narrative writing style of let s pretend it s your first week on the job felt kind of odd, but as far as material it s exactly what I was looking for starting to understand the nuts and bolts of how Ruby works under the hood. I picked up this book hoping I would satisfy my curiosity about DSL, ORM, and the inner mechanics of the Ruby On Rails Framework Let me just say the book exceeded my expectations It doesn t only show the magic of the Ruby language, it also goes deep into metaprogramming and how it can be leveraged to solve some classic programming and software design problems However, I didn t very much like the storytelling element and the absence of a complete real project to grasp the fundamentals of metap I picked up this book hoping I would satisfy my curiosity about DSL, ORM, and the inner mechanics of the Ruby On Rails Framework Let me just say the book exceeded my expectations It doesn t only show the magic of the Ruby language, it also goes deep into metaprogramming and how it can be leveraged to solve some classic programming and software design problems However, I didn t very much like the storytelling element and the absence of a complete real project to grasp the fundamentals of metaprogramming Overall, the book is good It certainly delivers I won t recommend it to beginners though There will be a steep learning curve But, if you have enough time and curiosity, go ahead I will be rereading this book periodically to keep my Ruby skills sharp It clarified concepts I was familiar with Eigenclass and classeval and instructs on how to skillfully use them He uses examples from several popular projects He knows his stuff.I was impressed with the list of spells ie design patterns he used They are Argument Array Collapse a list of arguments into an array.Around AliasCall the previous, aliased version of a method from a redefined method.Blank SlateRemove methods I will be rereading this book periodically to keep my Ruby skills sharp It clarified concepts I was familiar with Eigenclass and classeval and instructs on how to skillfully use them He uses examples from several popular projects He knows his stuff.I was impressed with the list of spells ie design patterns he used They are Argument Array Collapse a list of arguments into an array.Around AliasCall the previous, aliased version of a method from a redefined method.Blank SlateRemove methods from an object to turn them into Ghost Methods.Class ExtensionDefine class methods by mixing a module into a class s eigenclass.Class Extension MixinEnable a module to extend is include through a Hook Method.Class Instance VariableStore class level state in an instance variable of the Class object.Class MacroUse a class method in a class definition.Clean RoomUse an object as an environment in which to evaluate a block.Code ProcessorProcess a String of Code from an external source.Context ProbeExecute a block to access information in an object s context.Deferred EvaluationFore a piece of code and its context in a proc or lambda for evaluation later.Dynamic DispatchDecide which method to call at runtime.Dynamic MethodDecide how to define a method at runtime.Dynamic ProxyForwad to another object any messages that don t match a method.Flat ScopeUse a closure to share variable between two scopes.Ghost MethodRespond to a message that doesn t have an associated method.Hook MethodOverride a method to intercept object model events.Kernal MethodDefine a method in module Kernal to make the method available to all objects.Lazy Instance VariableWait until the first access to initialize an instance variable.Mimic MethodDisguise a method as another language contruct.Monkey patchChange the features of an existing class.Named ArgumentsCollect method arguments into a hash to identify them by name.NamespaceDefine constants within a module to avoid name clashes.Nil GuardOverride a reference to nil with an Object ExtensionDefine Singleton Methods by mixing a module into an object s eigenclass.Open ClassModify an existing class.Pattern DispatchSelect which methods to call based on their names.SandboxExecute untrusted code in a safe environment.Scope GateIsolate a scope with the class, module, or def keyword.Shared ScopeShare variables among multiple contexts in the same Flat Scope.Singleton MethodDefine a method on a single objectString of CodeEvaluate a string of Ruby code.Symbol to ProcConvert a symbo to a block that calls a single method I will be rereading this book periodically to keep my Ruby skills sharp It clarified concepts I was familiar with Eigenclass and classeval and instructs on how to skillfully use them He uses examples from several popular projects He knows his stuff.I was impressed with the list of spells ie design patterns he used They are Argument ArrayCollapse a list of arguments into an array.Around AliasCall the previous, aliased version of a method from a redefined method.Blank SlateRemove methods I will be rereading this book periodically to keep my Ruby skills sharp It clarified concepts I was familiar with Eigenclass and classeval and instructs on how to skillfully use them He uses examples from several popular projects He knows his stuff.I was impressed with the list of spells ie design patterns he used They are Argument ArrayCollapse a list of arguments into an array.Around AliasCall the previous, aliased version of a method from a redefined method.Blank SlateRemove methods from an object to turn them into Ghost Methods.Class ExtensionDefine class methods by mixing a module into a class s eigenclass.Class Extension MixinEnable a module to extend is include through a Hook Method.Class Instance VariableStore class level state in an instance variable of the Class object.Class MacroUse a class method in a class definition.Clean RoomUse an object as an environment in which to evaluate a block.Code ProcessorProcess a String of Code from an external source.Context ProbeExecute a block to access information in an object s context.Deferred EvaluationFore a piece of code and its context in a proc or lambda for evaluation later.Dynamic DispatchDecide which method to call at runtime.Dynamic MethodDecide how to define a method at runtime.Dynamic ProxyForwad to another object any messages that don t match a method.Flat ScopeUse a closure to share variable between two scopes.Ghost MethodRespond to a message that doesn t have an associated method.Hook MethodOverride a method to intercept object model events.Kernal MethodDefine a method in module Kernal to make the method available to all objects.Lazy Instance VariableWait until the first access to initialize an instance variable.Mimic MethodDisguise a method as another language contruct.Monkey patchChange the features of an existing class.Named ArgumentsCollect method arguments into a hash to identify them by name.NamespaceDefine constants within a module to avoid name clashes.Nil GuardOverride a reference to nil with an Object ExtensionDefine Singleton Methods by mixing a module into an object s eigenclass.Open ClassModify an existing class.Pattern DispatchSelect which methods to call based on their names.SandboxExecute untrusted code in a safe environment.Scope GateIsolate a scope with the class, module, or def keyword.Shared ScopeShare variables among multiple contexts in the same Flat Scope.Singleton MethodDefine a method on a single objectString of CodeEvaluate a string of Ruby code.Symbol to ProcConvert a symbo to a block that calls a single method Paolo Perrotta s Metaprogramming Ruby Program Like the Ruby Pros is a tour de force on Ruby s Object Model The book goes into considerable depth on how it works, and presents many examples of manipulating the object model to good use The format of first section of the book goes through a week of a pair of Ruby programmers as they try to fix and refactor an existing application, and how they use various metaprogramming spells techniques, idioms, etc The second section is a set of essays t Paolo Perrotta s Metaprogramming Ruby Program Like the Ruby Pros is a tour de force on Ruby s Object Model The book goes into considerable depth on how it works, and presents many examples of manipulating the object model to good use The format of first section of the book goes through a week of a pair of Ruby programmers as they try to fix and refactor an existing application, and how they use various metaprogramming spells techniques, idioms, etc The second section is a set of essays talking directly to the reader, rather than talking about people working on something The third section is a set of appendecies that encapsulate the various concepts discussed in the first two sections.One of the very nice things I liked about the first section is the use of hand drawn images to depict the concepts being discussed Not only does this give a sense of reality to the descriptions, it also gave me a sense of the inherent mutability of the model How easy to quickly erase and write a new segement of a drawing on a white board the issue of this is set in stone is completely eradicated by this technique, which reinforces the flexible nature of Ruby s object model.While metaprogramming itself can be a touchy subject how much is too much how do you test and maintain it how do you convey what you re doing to someone picking up your code and so on , it is such a useful thing to know At the end, the author offers up the opinion that, in fact, metaprogramming is just programming, after all, with all the goodness and badness that can result from that if you don t pay attention to what you re doing, andimportantly, why you re doing it.I very strongly recommend this book to Rubyists, and to others who want to discover how and why the language works as it does Anyone coming to Ruby from another object oriented language would do very well to pick up this book and read it thoroughly, completing the various quizzes in the first section before reading the proferred solutions, and experiment with these techniques.Even if one never ends up using metaprogramming, the book provides such a great explanation of the object model, it is worth reading in depth This is a book fills a long standing whole in the Ruby community by laying out a cohesive explanation of the Dark Art we call meta programming So much of Ruby metaprogramming is tribal knowledge and it can be difficult to acquire Evendifficult is understanding the underlying rationale for various bits of meta magic This book does a good job of boiling down Ruby metaprogramming into a list of spells , then explains each one in the context of a running narrative.For any Ruby programmin This is a book fills a long standing whole in the Ruby community by laying out a cohesive explanation of the Dark Art we call meta programming So much of Ruby metaprogramming is tribal knowledge and it can be difficult to acquire Evendifficult is understanding the underlying rationale for various bits of meta magic This book does a good job of boiling down Ruby metaprogramming into a list of spells , then explains each one in the context of a running narrative.For any Ruby programming struggling to grok eigenclasses, singleton methods, dynamic dispatch and other cool tricks, this book will be your ready guide


About the Author: Paolo Perrotta

Is a well known author, some of his books are a fascination for readers like in the Metaprogramming Ruby book, this is one of the most wanted Paolo Perrotta author readers around the world.


Leave a Reply

Your email address will not be published. Required fields are marked *