download ePUB Practical Object Oriented Design in Ruby – Intimatenights.co.uk

Practical Object Oriented Design in Ruby 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, poodrfo 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 Granted that this is the very first book about software development I ve ever finished, this is the best I ve ever read It was clear and understandable to me as a beginner with some exceptions but also comprehensive and fairly complex The writing was excellent and persuasive about the appeal of writing well organized code The first few chapters were slightlyclear and persuasive than the later chapters, which veer away from general principles into the weeds of specific techniques, but Granted that this is the very first book about software development I ve ever finished, this is the best I ve ever read It was clear and understandable to me as a beginner with some exceptions but also comprehensive and fairly complex The writing was excellent and persuasive about the appeal of writing well organized code The first few chapters were slightlyclear and persuasive than the later chapters, which veer away from general principles into the weeds of specific techniques, but the frequent specific examples and step by step explanations of them kept it all concrete and understandable If you re looking for a book on Object Oriented Programming OOP and intend to program in Ruby, I d recommend it but I can t speak to how it compares to other books that use other languages or frameworks for its examples 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 ispragmatic 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 ispragmatic 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 sof 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 While this book starts out being excellent, it just turns out as yet another of those static typing is wrong because type casts are dangerous and you need to write type annotations everywhere Then in the last chapter it basically re implements a type system via tests, by checking if a class has certain methods.That, dear reader, is exactly what static typing is for, and in 2014, we do have type inference even in C. 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.Examplesthe 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 NCrunch 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 centuryAny 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 pastProgrammers 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 codethe 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 languageThe 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 youMetaprogramming, 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 There are a plethora of libraries and frameworks, written in static languages, out there that are based on meta programmingDuck typing is built on dynamic typing to use duck typing you must embrace this dynamism 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 oneword in the method that uses the interface, one word per type that implements it, and one line per method message in the interface declarationDuck 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 typesCreating 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 saidThere is a level of design abstraction where it is almost impossible to safely make any change unless the code has testsTests 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 supportNot 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 doRefactoringCode navigationMetricsUML DiagramsArchitecture diagramsType checkingIt 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 , but doing is almost instant And SAFE 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 needexamples to make the point that the position this book takes on this issue is partisan and or uninformed I ll stop here

Leave a Reply

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