Practical Object-oriented Design In Ruby
On the occasion of her book “”, InfoQ interviewed the author Sandi Metz. Published last year, the book was received warmly by the Ruby community and non-Rubyists alike thanks to its pragmatic approach to design practices often seen as too complicated when presented (or imposed) without a clear context and motivation.
![Practical Object-oriented Design In Ruby Practical Object-oriented Design In Ruby](https://hype.codes/sites/default/files/icons_for_articles/red/vote.png)
The Addison-Wesley Professional Ruby Series provides readers with practical, people-oriented, and in-depth information about applying the Ruby platform to create. Practical Object-Oriented Design in Ruby: An Agile Primer (Addison-Wesley Professional Ruby) eBook: Sandi Metz: Amazon.co.uk: Kindle Store. Ruby's widely admired ease of use has a downside: Too many Ruby and Rails applications have been created without concern for their long-term maintenance.
Although Ruby is used as the language for the examples, the book could easily be shelved under generic software design as the author takes an unbiased approach to the dynamic vs. Static languages argument. Seasoned developers can find in this book a lot of pain points they surely encountered along their careers too. Novice developers will find clear explanations and examples of relevant design practices and become more aware of the advantages and drawbacks of applying certain practices in certain contexts. Above all, the book stresses the need to continuously assess if the design is good enough to support current knowledge of the application (requirements) while minimizing the cost of future changes. In Sandi’s words: “Code that is Transparent, Reasonable, Usable, and Exemplary (TRUE) not only meets today’s needs but can also be changed to meet the needs of the future.”. InfoQ talked with Sandi about how her book was received, learning from open source code, making sensible use of code analysis tools and other topics.
InfoQ: What is the target audience of the book? Do you think expert and novice developers alike can benefit from this book?
Sandi: The original target audience was my younger, less-experienced self, at a time when I'd written object-oriented code for a couple of years. This person would likely be described as 'intermediate'. While writing, I believed that readers with less experience would not yet be able to appreciate the book and that readers with more experience would not be interested. However, now that POODR has been published and readers get to self-select, it has become clear how wrong I was. I've had many absolute novices tell me they found it useful and many experienced programmers say they enjoyed it.
The range of readers is much wider than I anticipated. The other surprise is how many non-Rubyists are reading POODR. The book is about OO and contains very little that's specific to Ruby so perhaps this shouldn't be surprising, but I did not imagine this audience and it's deeply pleasing that they're finding it useful.
InfoQ: Your book talks a lot about exemplary code and the idea that good/bad code promotes similar kind of code down the line. In industry recruiting there seems to be a lot of focus on how good a developer is, but to which extent is that individual ability overshadowed by the influence of bad examples within the company? Sandi: My experience is that real applications in real businesses contain tons of imperfect code; this is the way of the practical world.
Novices, by definition, don't know enough to fix (or even judge) bad examples and so are always in the unenviable position of needing guidance from more experienced programmers. Experienced programmers are created 'on the job'; we learn this work by doing it. We rely on our peers to teach us and our practice to improve us, and it is the obligation of the senior to teach the junior. The fortunate truth of the open source world is that every programmer has access to far more code than just that of their company, and access to many more 'senior' programmers than the few employed where they work. Novices don't have to have been born knowing how to write (or even recognize) exemplary code, but they do have to accept the burden of getting out and exposing themselves to many influences. InfoQ: How can novice developers learn to design in practice without jeopardizing existing code?
In the book you mention the danger of adhering to patterns without having a clear idea of the tradeoffs that come with that decision. What other obstacles should be avoided by novice developers wanting to master OO design? Sandi: Novices should write a lot of code and show it to anyone who will look at it, and also look at code written by others.
Github is everyone's friend and nothing substitutes for time. InfoQ: Code analysis tools: heaven or hell? Sandi: Heaven, for those with good judgment, otherwise, hell (or at least, hell-ish). The tools are great for the mindless grunt-work of walking a code base and counting things, but it's up to a human to decide what to do with the results. To a code analysis tool, a technically 'good' design of the wrong thing scores well and a 'bad' design of something that will never change scores poorly. The tool will compliment you on the first and scream about the second, but, in this case, doing what it suggests is a waste of money. The strength to resist the urge to write code that over-anticipates the future, and the bravery to leave code that smells bad but will never change, are qualities of humans, not static tools.
InfoQ: In particular how do you see the role of such tools in terms of defining dependency rules and violations? Can they help guide development to a better design or are good design practices too context-dependent to profit from such hard rules?
Sandi: I love analysis tools and the data they provide. They keep me honest; they point out problems that I overlook and mistakes that I make. I believe that no humble programmer should be without this information-they should just take the results with a grain of salt. InfoQ: In your experience what are the most common design smells in legacy applications? How would you recommend going about fixing problematic code, where to start?
Sandi: The biggest problem I personally see are objects and methods that have too many responsibilities. This is so common that my first advice to anyone having a problem is 'Make smaller things'. InfoQ: Do you have any additional recommendations for readers interested in practical OO design? Sandi: Read the GOOS book. InfoQ: How was the book received by the Ruby community?
Did you feel there was a gap in software design literature for dynamic languages, and Ruby in particular? Sandi: I've been amazed by the positive response from the Ruby community.
While academically trained Rubyists do seem to enjoy it, by far the most enthusiastic response has come from self-taught Ruby programmers. I hear every day from folks who say that they've been dying for this information. Modesty prevents me from repeating too many compliments, but as a sample, one happy reader tweeted that he was having a 'road to Damascus' experience. POODR contains very little that's new.
As a matter of fact there are a number of ideas in it that I originally thought I invented but have come to find, well, the kindest way to put this would be to say that I 'rediscovered' them. I didn't know that the ideas already existed because I couldn't read and understand the existing literature. So, there is a literature 'gap' but it's not about content, it's about readability. The enthusiastic response to POODR is an indication of how deeply regular programmers want this gap to be filled. InfoQ: Can you share with InfoQ your next projects (books, open source, others)? Sandi: I'm making a video series for POODR and am exploring the possibility of doing some teaching.
I'm enjoying the opportunities that having written a book has brought me; the only down-side is that now I have to purposely schedule time to write code. About the Interviewee Sandi Metz has 30 years of experience working on projects that survived to grow and change. She writes code every day as a software architect at Duke University, where her team solves real problems for customers who have large object oriented applications that have been evolving for more than 15 years. She’s committed to getting useful software out the door in extremely practical ways. Practical Object Oriented Design in Ruby is the distillation of many years of white-board drawings and the logical culmination of a lifetime of conversations about object oriented design. Sandy has spoken several times at Gotham Ruby User’s Conference and lives in Durham, N.C.
The Complete Guide to Writing More Maintainable, Manageable, Pleasing, and Powerful Ruby Applications Ruby's widely admired ease of use has a downside: Too many Ruby and Rails applications have been created without concern for their long-term maintenance or evolution. The Web is awash in Ruby code that is now virtually impossible to change or extend. This text helps you so The Complete Guide to Writing More Maintainable, Manageable, Pleasing, and Powerful Ruby Applications Ruby's widely admired ease of use has a downside: Too many Ruby and Rails applications have been created without concern for their long-term maintenance or evolution.
The Web is awash in Ruby code that is now virtually impossible to change or extend. This text helps you solve that problem by using powerful real-world object-oriented design techniques, which it thoroughly explains using simple and practical Ruby examples. Sandi Metz has distilled a lifetime of conversations and presentations about object-oriented design into a set of Ruby-focused practices for crafting manageable, extensible, and pleasing code. She shows you how to build new applications that can survive success and repair existing applications that have become impossible to change. Each technique is illustrated with extended examples, all downloadable from the companion Web site, poodr.info.
The first title to focus squarely on object-oriented Ruby application design, Practical Object-Oriented Design in Ruby will guide you to superior outcomes, whatever your previous Ruby experience. Novice Ruby programmers will find specific rules to live by; intermediate Ruby programmers will find valuable principles they can flexibly interpret and apply; and advanced Ruby programmers will find a common language they can use to lead development and guide their colleagues. This guide will help you Understand how object-oriented programming can help you craft Ruby code that is easier to maintain and upgrade Decide what belongs in a single Ruby class Avoid entangling objects that should be kept separate Define flexible interfaces among objects Reduce programming overhead costs with duck typing Successfully apply inheritance Build objects via composition Design cost-effective tests Solve common problems associated with poorly designed Ruby code. Full disclosure: I helped contribute early reviews of much of the content of this book. Sandi does a really great job, but not for the reason you'd expect: POODR is more pragmatic than one would expect. Especially in the Rails world, where OO design is looked down upon as 'academic' and 'not actually worthwhile,' one would expect all the usual explanations and reasonings.
But not this book. Sandi does a great job of explaining the tensions between all of these different maxims, and acknowledges th Full disclosure: I helped contribute early reviews of much of the content of this book. Sandi does a really great job, but not for the reason you'd expect: POODR is more pragmatic than one would expect.
Especially in the Rails world, where OO design is looked down upon as 'academic' and 'not actually worthwhile,' one would expect all the usual explanations and reasonings. But not this book.
Sandi does a great job of explaining the tensions between all of these different maxims, and acknowledges that software is always in flux; in many ways, it's more of a process than a product. Some techniques are useful at different points in that process, and sometimes, business constraints don't allow for constructing perfect software, if such a thing were even possible. I'm still slightly concerned with the primary metaphor for much of the design: a bicycle. Too many people think of objects as only being concrete 'things' that you can touch or feel, and while the bicycle metaphor works well, I'm hoping that it doesn't further encourage this style of thinking. This is, again, a Rails concern, and POODR doesn't really concern itself with Rails. But in Rails apps, there's a real problem with monolithic models, and while POODR should help, I'm not sure it goes far enough in that regard. But seriously, that's the only complaint that I have about it, it is a truly excellent book.
This book is spot on when it comes to object orientation. It contains many of the lessons I had to learn the hard way during the last 8 years while extensively studying books & blogs on oo.
Though POODR certainly doesn't come up with a lot of new ideas (at least I've heard most of them before), it compiles the ideas into a wonderful whole, where each part fits nicely with the rest of the book. Although definitely opinionated, the book shines by never being dogmatic and clearly explaining the This book is spot on when it comes to object orientation. It contains many of the lessons I had to learn the hard way during the last 8 years while extensively studying books & blogs on oo. Though POODR certainly doesn't come up with a lot of new ideas (at least I've heard most of them before), it compiles the ideas into a wonderful whole, where each part fits nicely with the rest of the book. Although definitely opinionated, the book shines by never being dogmatic and clearly explaining the decision process and tradeoffs behind every advice Sandi gives.
If there's one thing I would definitely take away from this book, it's from the last part on testing. Sandi describes a technique there on how to make a test code base that extensively relies mocks & stubs much more trustworthy, by adding interface related tests on both sides to ensure contract adherence. It's a technique I've heard only a few times about (the last time in 2009 by JB Rainsberger ), but never seen actually anyone describing in detail in code. Although I've applied parts of the idea, like ensuring interface adherence for ducks and hierarchies, I often missed proper tests for the stubs used in the consumer related specs. I will definitely try to use this technique more in the future.
Some minor points of critique: For one thing, one of the usual things to criticize for this kind of book (I guess): It doesn't really show end to end code with persistence and presentation added to the mix, which definitely is a place where novices and even often intermediary designers hit a wall applying those principles. The other thing that I missed (and maybe this goes hand in hand with the first one), is the notion that one single model might not be the best choice for all aspects of an applications and sometimes you have to weigh if and when to insert model borders (E. Evans famous Bounded Contexts come in mind here). That being said I really enjoyed the book and I will definitely recommend it to colleagues.
This book is an excellent book on good OO design. I would recommend it to anyone. But I would not recommend it to anyone without a large warning sign stuck to it: 'Warning: The portions about statically vs dynamically types languages show a very marked lack of balance, objectivity and depth of knowledge. Safest to simply not believe anything said about statically typed languages in this book. Most of it is not exactly wrong, but still very misleading.' Sandi: Should you happen to read this I would This book is an excellent book on good OO design. I would recommend it to anyone.
But I would not recommend it to anyone without a large warning sign stuck to it: 'Warning: The portions about statically vs dynamically types languages show a very marked lack of balance, objectivity and depth of knowledge. Safest to simply not believe anything said about statically typed languages in this book. Most of it is not exactly wrong, but still very misleading.'
Sandi: Should you happen to read this I would strongly recommend removing the bash-static-typing section in the next edition, or working very hard to make it balanced. Your book is truly not enhanced by a semi-informed attack on static typing.
And it is otherwise such a good book! Had the book not even mentioned static typing it would have gotten 5 stars. Examples: 'the huge gains in efficiency provided by removing the compile/make cycle.
This trade is a bargain. Take it' Competent programmers do not sit around waiting for the compiler and running tests manually. They use tools that do this automatically in the background for them. Within a second or two of two of changing code the tools will have detected the change, compiled the code, executed the tests, and notified you if you broke something. See for instance; There is no huge gain to be found here. Maybe there was when all statically typed languages took long to compile and these tools did not exist. That was last century!
'Any language that allows casting a variable to a new type is vulnerable' Casting is highly unusual in code written by competent programmers. Casting is a code stink. This is an argument along the lines of 'Red lights are useless, you can just drive right past!' 'Programmers find the code easier to understand when it does not contain type declarations; they can infer an object’s type from its context.' Then why do you spend 90% of the testing trying to add types back through tests? Why do you explicitly say that you do this to make the types visible?
Why do you talk time and time and time again about how to make the implicit types visible so that it is possible to understand the code? 'the belief that static typing is fundamentally preferable often persists because it is self-reinforcing. Programmers who fear dynamic typing tend to check the classes of objects in their code' Manual type checks are not common in code written by competent programmers. It is another code stink. Just like in a dynamic language. 'The notion that static typing provides safety, comforting though it may be, is an illusion' Then tell me again why the book spends 90% of the testing effort manually building a fragile type system without once mentioning how this is not needed with static typing. It's almost all 'respondstosize', 'respondstowidth' This is just type checking.
Something that a static language compiler does for you. 'Metaprogramming, used wisely, has great value; ease of metaprogramming is a strong argument in favor of dynamic typing'. Meta-programming might be somewhat harder in static languages. But our whole code base would be impossible without it. See tools such as NHibernate, Entity Framework, NServiceBus.
![Practical object-oriented design in ruby pdf Practical object-oriented design in ruby pdf](https://weltbild.scene7.com/asset/vgw/practical-object-oriented-design-in-ruby-072436645.jpg)
There are a plethora of libraries and frameworks, written in static languages, out there that are based on meta programming. 'Duck typing is built on dynamic typing; to use duck typing you must embrace this dynamism.'
Practical Object-oriented Design In Ruby Pdf
'Duck typing detaches these public interfaces from specific classes, creating virtual types that are defined by what they do instead of by who they are.' Exactly what you get in a static language by simply extracting an interface and implementing it. This add up to a grand total of one more word in the method that uses the interface, one word per type that implements it, and one line per method/message in the interface declaration. 'Duck typing reveals underlying abstractions that might otherwise be invisible. Depending on these abstractions reduces risk and increases flexibility, making your application cheaper to maintain and easier to change.' And when these abstractions get names in the code they actually become visible, without having to hunt for their meaning in tests somewhere else. You can see it right there in the code.
And you do not need to spend 90% of your testing type checking these types. 'Creating code that fails with reasonable error messages takes minor effort in the present but provides value forever. Each error message is a small thing, but small things accumulate to produce big effects and it is this attention to detail that marks you as a serious programmer. Always document template method requirements by implementing matching methods that raise useful error' But using language that guarantees this out of the box is useless, because such errors dont occur in reality. Was that not what you said? 'There is a level of design abstraction where it is almost impossible to safely make any change unless the code has tests. Tests are your record of the interface of every abstraction and as such they are the wall at your back.
They let you put off design decisions and create abstractions to any useful depth' With static languages the actual abstractions have concrete representations in the code. You do not need to go searching in tests to see the abstractions and the design. Given a well designed code base I would say that a highly abstracted code base is far easier to refactor safely without tests than a code base with few abstractions. This of course goes for static languages with the excellent tool support that they afford. Tools support Not once does the book mention what might be the greatest advantage of all to static languages. The excellent tools support that the ability to do static analysis affords. Tools that do Refactoring Code navigation Metrics UML Diagrams Architecture diagrams Type checking It is impossible(even theoretically) to make such tools, that are truly reliable/accurate, for dynamically typed languages.
In my opinion the greatest of these tools are the refactoring tools. I can very quickly completely transform the structure of large portions of code in a large code base in C# with 99% assurance that it will all work exactly the same afterwards. In seconds I rename a class/method/interface.
Another few seconds and I move half the files in one folder/namespace to another one where they fit better. Another few seconds and I extract a new interface for use as a 'duck'. All of that took about 1 minute of actually changing code.
Obviously the thinking part is apt to take more, but doing is almost instant. I do this all the time in C# and it just works! I've done these types of refactorings in dynamic languages. Even in well written code it is likely that such refactorings are so hard to perform that I will just not do it. We would probably be talking, at least, an hour for each step. More likely hours or days.
If we did not have very near 100% test coverage I would never dare to attempt it. How often do you see 100% code coverage? The list does go on and on but I'm tired now and I hardly think I need more examples to make the point that the position this book takes on this issue is partisan and/or uninformed. I'll stop here.
Chapter 3: Managing Dependencies An object has a dependancy when it knows: - 1) The name of another class. 2) The name of a message that it intends to send to someone other than self. 3) The argument that a message requires.
4) The order of those arguments. Writing Loosely Coupled Code techniques - Inject dependencies - Isolate dependencies: isolate instance creation, isolate external vulnerable messages, explicitely define defaults, isolate multiparameter initialization - Choosing the dependency d Chapter 3: Managing Dependencies An object has a dependancy when it knows: - 1) The name of another class. 2) The name of a message that it intends to send to someone other than self. 3) The argument that a message requires. 4) The order of those arguments. Writing Loosely Coupled Code techniques - Inject dependencies - Isolate dependencies: isolate instance creation, isolate external vulnerable messages, explicitely define defaults, isolate multiparameter initialization - Choosing the dependency direction.
Having been a Ruby programmer full-time for a year now, this book finally made 'click' many of the Best Practices I've seen and used in code but haven't really been able to articulate. It got a little long-winded and redundant at some points, probably because it's geared more towards people who haven't been exposed much to OO, but overall it was definitely worth reading.
These are some of the parts that were most valuable to me: 'Sometimes the value of having the feature right now is so great that Having been a Ruby programmer full-time for a year now, this book finally made 'click' many of the Best Practices I've seen and used in code but haven't really been able to articulate. It got a little long-winded and redundant at some points, probably because it's geared more towards people who haven't been exposed much to OO, but overall it was definitely worth reading.
These are some of the parts that were most valuable to me: 'Sometimes the value of having the feature right now is so great that it outweighs any future increase in costs.' 'Design is more the art of preserving changeability that it is the act of achieving perfection.' On designing a class: 'If the simplest description you can devise uses the word 'and,' the class likely has more than one responsibility. If it uses the word 'or,' then the class has more than one responsibility and they aren't even very related.'
'When faced with an imperfect and muddled class. Ask yourself: 'What is the future cost of doing nothing today?' ' 'If you can control the input, pass in a useful object, but if you are compelled to take a messy structure, hide the mess even from yourself.' On classes with too many dependencies: 'Because they increase the chance that the class will be forced to change, these dependencies turn minor code tweaks into major undertakings where small changes cascade through the application, forcing many changes.' 'depend on things that change less often than you do.' 'Classes control what's in your source code repository; messages reflect the living, animated application.' 'public methods should read like a description of responsibilities.'
'Interfaces evolve and to do so they must first be born. It is important that a well-defined interface exist than it be perfect.' 'Even if the original author did not define a good public interface it is not too late to create one for yourself.'
'The general rule for refactoring into a new inheritance hierarchy is to arrange code so that you can promote abstractions rather than demote concretions.' 'Identifying the correct abstraction is easiest if you have access to at least three existing concrete classes.' 'Because `extend` adds the module's behavior directly to an object, extending a class with a module creates class methods in that class and extending an instance of a class with a module creates instance methods in that instance.' 'Aggregation is exactly like composition except that the contained object has an independent life outside of the has-a relationship.'
'If you cannot explicitly defend inheritance as a better solution, use composition. 'Inheritance is best suited to adding functionality to existing classes when you will use most of the old code and add relatively small amounts of new code.' 'Tests provide the only reliable documentation of design. The story they tell remains true long after paper documents become obsolete and human memory fails.
Write your tests as if you expect your future self to have amnesia.' 'Costly tests do not necessarily mean that the application is poorly designed. It is quite technically possible to write bad tests for well-designed code. The best way to design good tests is to write loosely coupled tests about only the things that matter.' 'It is an unfortunate truth that the most complex code is usually written by the least qualified person.
Novice programmers don't yet have the skills to write simple code.' 'Do not test an incoming message that has no dependents; delete it; Your application is improved by ruthlessly eliminating code that is not actively being used. Such code is negative cash flow, it adds testing and maintenance burdens but provides no value. Deleting unused code saves money right now, if you do not do so you must test it.' If using an object is cheap, injecting an actual one instead of a double into a test is fine. 'An object with many private methods exudes the design smell of having too many responsibilities.
If your object has so many private methods that you dare not leave them untested, consider extracting the methods into a new object.' 'When you treat test doubles as you would any other role player and test them to prove their correctness, you avoid test brittleness and can stub without fear of consequence.' 'On testing abstract base classes: 'If you leverage Liskov and create new subclasses that are used exclusively for testing, consider requiring these subclasses to pass your subclass responsibility test to ensure they don't accidentally become obsolete.' This book helped tie together my understanding of OOP best practices in Ruby and has produced immediate benefits in the quality of code I'm writing.
![Object-oriented Object-oriented](https://i.ytimg.com/vi/ZidtkVTRNQo/maxresdefault.jpg)
It contains great examples of refactoring code, along with checklists, red flags and questions to ask yourself throughout the design process. The author does a great job of following the development and improvement of a sample app throughout the book (an app for a bike shop).
The continuous narrative helps you see how the pieces fit together, though This book helped tie together my understanding of OOP best practices in Ruby and has produced immediate benefits in the quality of code I'm writing. It contains great examples of refactoring code, along with checklists, red flags and questions to ask yourself throughout the design process.
The author does a great job of following the development and improvement of a sample app throughout the book (an app for a bike shop). The continuous narrative helps you see how the pieces fit together, though a few examples from other domains would have been helpful in some places.
At the same time, that's really an exercise for the reader. I found Chapter 4's discussion of creating a public interface particularly helpful in determining the proper responsibilities of objects by 'Asking for 'What' Instead of Telling 'How'.' The continued discussion of messages when identifying duck types in Chapter 5 helped reinforce the concepts. The chapters on modules and testing also helped tighten up my thinking on a few topics. As I've shifted from hobbyist to freelancer to full time developer over the past few years, there have been a few books or tutorials that have really helped me improve (along with bugging friends and countless hours of troubleshooting), and this is definitely one of them. Highly recommended. The thing about Sandi Metz is she has that wonderful mix of good communication and years of experience.
This book is a great demonstration of the power of that combination. It's got a laid back style that makes it feel like you and Sandi are pairing on the code under examination. As Sandi's explaining to you why she's thinking what she's thinking you spend the length of the book saying 'yes, I hand't thought about it like that but now it's obvious'. There aren't many programming book I loved it. The thing about Sandi Metz is she has that wonderful mix of good communication and years of experience. This book is a great demonstration of the power of that combination.
It's got a laid back style that makes it feel like you and Sandi are pairing on the code under examination. As Sandi's explaining to you why she's thinking what she's thinking you spend the length of the book saying 'yes, I hand't thought about it like that but now it's obvious'. There aren't many programming books like that and reading this will make you want to bin a drier and less accessible treatments of OO thinking. Even better a number of the principles explained here are language agnostic, your Python is better Python after reading this. I don't have anything bad to say about this book, which I think is a first for me. It's just that good.
I love the Ruby language and I have loved it pretty much from the first time I found out about it. My brain loves creating connections between concepts, and coming up with abstractions to depict situations, problems and solutions. This book gave me a dose of both Ruby and abstractions that was very soothing. Sandi has a very engaging way of writing, very much like the way she talks at conferences. She's neither patronizing nor overly complicated when explaining topics, but rather finds a great ba I love the Ruby language and I have loved it pretty much from the first time I found out about it. My brain loves creating connections between concepts, and coming up with abstractions to depict situations, problems and solutions. This book gave me a dose of both Ruby and abstractions that was very soothing.
Sandi has a very engaging way of writing, very much like the way she talks at conferences. She's neither patronizing nor overly complicated when explaining topics, but rather finds a great balance between making you think about the issue at hand and feeling comfortable enough to keep reading and not getting stuck.
The code examples presented were very concise and easy to follow (thanks, Ruby!) and, hell, I think even the use of UML was very appropiate and helped better depict the concepts that were being explained. If you care about the quality of the abstractions that you brain comes up with and how to bridge the gap between that and your implementations, then it is my pleasure to recommend you read this book. Also, if you have not seen any of Sandi's talks, be sure to check out one on YouTube, you will not be dissapointed. In my humble opinion, this book's greatest strength lies in its advice to think first not of objects themselves and their responsibilities, but as actors and messages passed between them. Perhaps you already knew this; I didn't, and doing so has been a tremendous new tool in my arsenal to tackle problems. Seeing and defining public interfaces and abstractions has become a lot easier. It's become so much clearer now, it's like the idea just popped into my head.
Chapter 4: Creating Flexible Interfa In my humble opinion, this book's greatest strength lies in its advice to think first not of objects themselves and their responsibilities, but as actors and messages passed between them. Perhaps you already knew this; I didn't, and doing so has been a tremendous new tool in my arsenal to tackle problems. Seeing and defining public interfaces and abstractions has become a lot easier. It's become so much clearer now, it's like the idea just popped into my head. Chapter 4: Creating Flexible Interfaces has been a joy. While reading it, I couldn't drop the book for the life of me.
It just clicked at the time: this is what I'm reading this book for. Why the 3-star? I'm gonna share another here: While I know this is a Ruby book, I guess it could have done without the obvious dynamic/weak typing bias, only to spend half the book later providing tips to prevent problems inherent in the typing system. I recommend this book as a must read for any novice to intermediate developer and as a communication tool for more experienced folks. The core is really about design and much less about ruby specifics. It touches on design best practices and concepts really clearly and gives easy to understand examples of subjects like: Single responsibility principle, the law of Demeter, duck typing, inheritance, composition, testing and more.
The big selling point is that Sandi writes from a highly practical po I recommend this book as a must read for any novice to intermediate developer and as a communication tool for more experienced folks. The core is really about design and much less about ruby specifics. It touches on design best practices and concepts really clearly and gives easy to understand examples of subjects like: Single responsibility principle, the law of Demeter, duck typing, inheritance, composition, testing and more. The big selling point is that Sandi writes from a highly practical point of view. She highlights that few rules are black and white and that they can be broken if the benefits outweigh the costs. Some bonus points are made touching sensitive points like design being about embracing change and the benefits that some UML tools have.
For non Rubyists it makes sense to dive into a 20-minute tutorial just to follow along with the examples. Highly recommend to anyone doing any sort of professional programming. Whatever your relationship to Ruby as a programming language, the principles outlined in this book cut deeply and across all areas of day-to-day work of a developer and provide profound insight on things that might have seemed to a novice or a developer initiate as trivial (or not even worth attention).
Especially when designing their object hierarchies and patterns of interaction between various components of the application Highly recommend to anyone doing any sort of professional programming. Whatever your relationship to Ruby as a programming language, the principles outlined in this book cut deeply and across all areas of day-to-day work of a developer and provide profound insight on things that might have seemed to a novice or a developer initiate as trivial (or not even worth attention). Especially when designing their object hierarchies and patterns of interaction between various components of the application and providing effective tests for them. Not to mention Metz' style of writing abounds with art and fills the reader with a certain sense of pleasure as he absorbs her wisdom.