Share E-Book

Beautiful Architecture Leading Thinkers Reveal the Hidden Beauty in Software Design (Diomidis Spinellis etc.)(Z-Library)

Author

,

Rating 4.0 AI initial rating

Log in to rate

Software
Language English

What are the ingredients of robust, elegant, flexible, and maintainable software architecture? Beautiful Architecture answers this question through a collection of intriguing essays from more than a dozen of today's leading software designers and architects. In each essay, contributors present a notable software architecture, and analyze what makes it innovative and ideal for its purpose. Some of the engineers in this book reveal how they developed a specific project, including decisions they faced and tradeoffs they made. Others take a step back to investigate how certain architectural aspects have influenced computing as a whole. With this book, you'll discover: • How Facebook's architecture is the basis for a data-centric application ecosystem • The effect of Xen's well-designed architecture on the way operating systems evolve • How community processes within the KDE project help software architectures evolve from rough sketches to beautiful systems •How creeping featurism has helped GNU Emacs gain unanticipated functionality • The magic behind the Jikes RVM self-optimizable, self-hosting runtime • Design choices and building blocks that made Tandem the choice platform in high-availability environments for over two decades • Differences and similarities between object-oriented and functional architectural views • How architectures can affect the software's evolution and the developers' engagement Go behind the scenes to learn what it takes to design elegant software architecture, and how it can shape the way you approach your own projects, with Beautiful Architecture. This book includes contributions from: John Klein and David Weiss • Pet Goodliffe • Jim Waldo • Michael Nygard • Brian Sietten • Dave Fetterman • Derek Murray and Keir Fraser • Greg Lehey • Rhys Newman and Christopher Denis • Ian Rogers and Dave Grove • Jim Blandy • Till Adam and Mirko Boehm • Bertrand Meyer • Panagiotis Louridas

Format PDF
Size 4.4 MB
(First 20 pages)

Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Page 1
(This page has no text content)
Page 2
(This page has no text content)
Page 3
Beautiful Architecture Edited by Diomidis Spinellis and Georgios Gousios Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo
Page 4
Beautiful Architecture Edited by Diomidis Spinellis and Georgios Gousios Copyright © 2009 O’Reilly Media. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Editor: Mary Treseler Production Editor: Sarah Schneider Copyeditor: Genevieve d’Entremont Proofreader: Nancy Reinhardt Indexer: Fred Brown Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrator: Robert Romano Printing History: January 2009: First Edition. O’Reilly and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Beautiful Architecture and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-0-596-51798-4 [M] 1231531335
Page 5
All royalties from this book will be donated to Doctors Without Borders.
Page 6
(This page has no text content)
Page 7
C O N T E N T S FOREWORD ix by Stephen J. Mellor PREFACE xiii Part One ON ARCHITECTURE 1 WHAT IS ARCHITECTURE? 3 by John Klein and David Weiss Introduction 3 Creating a Software Architecture 10 Architectural Structures 14 Good Architectures 19 Beautiful Architectures 20 Acknowledgments 23 References 23 2 A TALE OF TWO SYSTEMS: A MODERN-DAY SOFTWARE FABLE 25 by Pete Goodliffe The Messy Metropolis 26 Design Town 33 So What? 41 Your Turn 41 References 42 Part Two ENTERPRISE APPLICATION ARCHITECTURE 3 ARCHITECTING FOR SCALE 45 by Jim Waldo Introduction 45 Context 47 The Architecture 51 Thoughts on the Architecture 57 4 MAKING MEMORIES 63 by Michael Nygard Capabilities and Constraints 64 Workflow 65 Architecture Facets 66 User Response 87 v
Page 8
Conclusion 88 References 88 5 RESOURCE-ORIENTED ARCHITECTURES: BEING “IN THE WEB” 89 by Brian Sletten Introduction 89 Conventional Web Services 90 The Web 92 Resource-Oriented Architectures 98 Data-Driven Applications 102 Applied Resource-Oriented Architecture 103 Conclusion 109 6 DATA GROWS UP: THE ARCHITECTURE OF THE FACEBOOK PLATFORM 111 by Dave Fetterman Introduction 111 Creating a Social Web Service 117 Creating a Social Data Query Service 124 Creating a Social Web Portal: FBML 133 Supporting Functionality for the System 146 Summation 151 Part Three SYSTEMS ARCHITECTURE 7 XEN AND THE BEAUTY OF VIRTUALIZATION 155 by Derek Murray and Keir Fraser Introduction 155 Xenoservers 156 The Challenges of Virtualization 159 Paravirtualization 159 The Changing Shape of Xen 163 Changing Hardware, Changing Xen 169 Lessons Learned 172 Further Reading 173 8 GUARDIAN: A FAULT-TOLERANT OPERATING SYSTEM ENVIRONMENT 175 by Greg Lehey Tandem/16: Some Day All Computers Will Be Built Like This 176 Hardware 176 Mechanical Layout 178 Processor Architecture 179 The Interprocessor Bus 184 Input/Output 184 Process Structure 185 Message System 186 File System 190 Folklore 195 The Downside 195 vi C O N T E N T S
Page 9
Posterity 197 Further Reading 198 9 JPC: AN X86 PC EMULATOR IN PURE JAVA 199 by Rhys Newman and Christopher Dennis Introduction 200 Proof of Concept 202 The PC Architecture 205 Java Performance Tips 206 Four in Four: It Just Won’t Go 207 The Perils of Protected Mode 210 Fighting A Losing Battle 214 Hijacking the JVM 217 Ultimate Flexibility 229 Ultimate Security 231 It Feels Better the Second Time Around 232 10 THE STRENGTH OF METACIRCULAR VIRTUAL MACHINES: JIKES RVM 235 by Ian Rogers and Dave Grove Background 236 Myths Surrounding Runtime Environments 237 A Brief History of Jikes RVM 240 Bootstrapping a Self-Hosting Runtime 241 Runtime Components 246 Lessons Learned 259 References 259 Part Four END-USER APPLICATION ARCHITECTURES 11 GNU EMACS: CREEPING FEATURISM IS A STRENGTH 263 by Jim Blandy Emacs in Use 264 Emacs’s Architecture 266 Creeping Featurism 272 Two Other Architectures 275 12 WHEN THE BAZAAR SETS OUT TO BUILD CATHEDRALS 279 by Till Adam and Mirko Boehm Introduction 279 History and Structure of the KDE Project 282 Akonadi 287 ThreadWeaver 303 Part Five LANGUAGES AND ARCHITECTURE 13 SOFTWARE ARCHITECTURE: OBJECT-ORIENTED VERSUS FUNCTIONAL 315 by Bertrand Meyer Overview 315 C O N T E N T S vii
Page 10
The Functional Examples 318 Assessing the Modularity of Functional Solutions 321 An Object-Oriented View 330 Assessing and Improving OO Modularity 336 Agents: Wrapping Operations into Objects 341 Acknowledgments 345 References 346 14 REREADING THE CLASSICS 349 by Panagiotis Louridas Everything Is an Object 353 Types Are Defined Implicitly 361 Problems 367 Brick and Mortar Architecture 372 References 380 AFTERWORD 383 by William J. Mitchell CONTRIBUTORS 387 INDEX 393 viii C O N T E N T S
Page 11
Foreword Stephen J. Mellor THE CHALLENGES OF DEVELOPING HIGH-PERFORMANCE , HIGH-RELIABILITY , and high-quality software systems are too much for ad hoc and informal engineering techniques that might have worked in the past on less demanding systems. The complexity of our systems has risen to the point where we can no longer cope without developing and maintaining a single overarching architecture that ties the system into a coherent whole and avoids piecemeal implementation, which causes testing and integration failures. But building an architecture is a complex task. Examples are hard to come by, due to either proprietary concerns or the opposite, a need to “sell” a particular architectural style into a wide range of environments, some of which are inappropriate. And architectures are big, which makes them difficult to capture and describe without overwhelming the reader. Yet beautiful architectures exhibit a few universal principles, some of which I outline here: One fact in one place Duplication leads to error, so it should be avoided. Each fact must be a single, nondecomposable unit, and each fact must be independent of all other facts. When change occurs, as it inevitably does, only one place need be modified. This principle is well known to database designers, and it has been formalized under the name of normalization. The principle also applies less formally to behavior, under the name factoring, such that common functionality is factored out into separate modules. ix
Page 12
Beautiful architectures find ways to localize information and behavior. At runtime, this manifests as layering, the notion that a system may be factored into layers, each representing a layer of abstraction or domain. Automatic propagation One fact in one place sounds good, but for efficiency’s sake, some data or behavior is often duplicated. To maintain consistency and correctness, propagation of these facts must be carried out automatically at construction time. Beautiful architectures are supported by construction tools that effect meta- programming, propagating one fact in one place into many places where they may be used efficiently. Architecture includes construction An architecture must include not only the runtime system, but also how it is constructed. A focus solely on the runtime code is a recipe for deterioration of the architecture over time. Beautiful architectures are reflective. Not only are they beautiful at runtime, but they are also beautiful at construction time, using the same data, functions, and techniques to build the system as those that are used at runtime. Minimize mechanisms The best way to implement a given function varies case by case, but a beautiful architecture will not strive for “the best.” There are, for example, many ways of storing data and searching it, but if the system can meet its performance requirements using one mechanism, there is less code to write, verify, maintain, and occupy memory. Beautiful architectures employ a minimal set of mechanisms that satisfy the requirements of the whole. Finding “the best” in each case leads to proliferation of error-prone mechanisms, whereas adding mechanisms parsimoniously leads to smaller, faster, and more robust systems. Construct engines If you wish to build brittle systems, follow Ivar Jacobson’s advice and base your architecture on use cases and one function at a time (i.e., use “controller” objects). Extensible systems, on the other hand, rely on the construction of virtual machines— engines that are “programmed” by data provided by higher layers, and that implement multiple application functions at a time. This principle appears in many guises. “Layering” of virtual machines goes back to Edsger Dijkstra. “Data-driven systems” provide engines that rely on coding invariants in the system, letting the data define the specific functionality in a particular case. These engines are highly reusable—and beautiful. x F O R E W O R D
Page 13
O(G), the order of growth Back in the day, we thought about the “order” of algorithms, analyzing the performance of sorting, say, in terms of the time it takes to sort a set of a certain number of elements. Whole books have been written on the subject. The same applies for architecture. Polling, for example, works well for a small number of elements, but is a response-time disaster as the number of items increases. Organizing everything around interrupts or events works well until they all go off at once. Beautiful architectures consider the direction of likely growth and account for it. Resist entropy Beautiful architectures establish a path of least resistance for maintenance that preserves the architecture over time and so slows the effects of the Law of System Entropy, which states that systems become more disorganized over time. Maintainers must internalize the architecture so that changes will be consistent with it and not increase system entropy. One approach is the Agile concept of the Metaphor, which is a simple way to represent what the architecture is “like.” Another is extensive documentation and threats of unemployment, though that seldom works for long. Usually, however, it generally means tools, especially for generating the system. A beautiful architecture must remain beautiful. These principles are highly interrelated. One fact in one place can work only if you have automatic propagation, which in turn is effective when the architecture takes construction into account. Similarly, constructing engines and minimizing mechanisms support one fact in one place. Resisting entropy is a requirement for maintaining an architecture over time, and it relies on the architecture including construction and support for propagation. Moreover, a failure to consider the way in which a system will likely grow will cause the architecture to become unstable, and eventually fail under extreme but predictable circumstances. And combining minimal mechanisms with the notion of constructing engines means that beautiful architectures usually feature a limited set of patterns that enable construction of arbitrary system extensions, a kind of “expansion by pattern.” In short, beautiful architectures do more with less. As you read this book, ably assembled and introduced by Diomidis Spinellis and Georgios Gousios, you might look for these principles and consider their implications, using the specific examples presented in each chapter. You might also look for violations of these principles and ask whether the architecture is thus ugly or whether some higher principle is involved. During the development of this Foreword, your authors asked me if I might say a few words about how someone becomes a good architect. I laughed. If we only knew that.... But then I recalled from my own experience that there is a powerful, if nonanalytic, way of becoming a F O R E W O R D xi
Page 14
beautiful architect. That way* is never to believe that the last system you built is the only way to build systems, and to seek out many examples of different ways of solving the same type of problem. The example beautiful architectures presented in this book are a step forward in helping you meet that goal. * Or exercise more and eat less. xii F O R E W O R D
Page 15
Preface THE IDEA FOR THE BOOK YOU’RE READING WAS CONCEIVED IN 2007 as a successor to the award- winning, best-selling Beautiful Code: a collection of essays about innovative and sometimes surprising solutions to programming problems. In Beautiful Architecture, the scope and purpose is different, but similarly focused: to get leading software designers and architects to describe a software architecture of their choice, peeling back the layers of their creations to show how they developed software that is functional, reliable, usable, efficient, maintainable, portable, and, yes, elegant. To put together this book, we contacted leading architects of well-known or less-well-known but highly innovative software projects. Many of them replied promptly and came back to us with thought-provoking ideas. Some of the contributors even caught us by surprise by proposing not to write about a specific system, but instead investigating the depth and the extent of architectural aspects in software engineering. All chapter authors were glad to hear that the work they put in their chapters is also helping a good cause, as the royalties of this book are donated to Medécins Sans Frontières (Doctors Without Borders), an international humanitarian aid organization that provides emergency medical assistance to suffering people. xiii
Page 16
How This Book Is Organized We have organized the contents of this book around five thematic areas: overviews, enterprise applications, systems, end-user applications, and programming languages. There is an obvious, but not deliberate, lack of chapters on desktop software architectures. Having approached more than 50 software architects, this result was another surprise for us. Are there really no shining examples of beautiful desktop software architectures? Or are talented architects shying away from an area often driven by a quest to continuously pile ever more features on an application? We are really looking forward to hearing from you on these issues. Part I: On Architecture Part I of this book examines the breadth and scope of software architecture and its implications for software development and evolution. Chapter 1, What Is Architecture?, by John Klein and David Weiss, defines software architecture by examining the subject through the perspectives of quality concerns and architectural structures. Chapter 2, A Tale of Two Systems: A Modern-Day Software Fable, by Pete Goodliffe, provides an allegory on how software architectures can affect system evolution and developer engagement with a project. Part II: Enterprise Application Architecture Enterprise systems, the IT backbone of many organizations, are large and often tailor-made conglomerates of software usually built from diverse components. They serve large, transactional workloads and must scale along with the enterprise they support, readily adapting to changing business realities. Scalability, correctness, stability, and extensibility are the most important concerns when architecting such systems. Part II of this book includes some exemplar cases of enterprise software architectures. Chapter 3, Architecting for Scale, by Jim Waldo, demonstrates the architectural prowess required to build servers for massive multiplayer online games. Chapter 4, Making Memories, by Michael Nygard, goes through the architecture of a multistage, multisite data processing system and presents the compromises that must be made to make it work. Chapter 5, Resource-Oriented Architectures: Being “In the Web”, by Brian Sletten, discusses the power of resource mapping when constructing data-driven applications and provides an elegant example of a purely resource-oriented architecture. xiv P R E F A C E
Page 17
Chapter 6, Data Grows Up: The Architecture of the Facebook Platform, by Dave Fetterman, advocates data-centric systems, explaining how a good architecture can create and support an application ecosystem. Part III: Systems Architecture Systems software is arguably the most demanding type of software to design, partly because efficient use of hardware is a black art mastered by a selected few, and partly because many consider systems software as infrastructure that is “simply there.” Seldom are great systems architectures designed on a blank sheet; most systems that we use today are based on ideas first conceived in the 1960s. The chapters in Part III walk you through four innovative systems software architectures, discussing the complexities behind the architectural decisions that made them beautiful. Chapter 7, Xen and the Beauty of Virtualization, by Derek Murray and Keir Fraser, gives an example of how a well-thought-out architecture can change the way operating systems evolve. Chapter 8, Guardian: A Fault-Tolerant Operating System Environment, by Greg Lehey, presents a retrospective on the architectural choices and building blocks (both software and hardware) that made Tandem the platform of choice in high-availability environments for nearly two decades. Chapter 9, JPC: An x86 PC Emulator in Pure Java, by Rhys Newman and Christopher Dennis, describes how carefully designed software and a good understanding of domain requirements can overcome the perceived deficiencies of a programming system. Chapter 10, The Strength of Metacircular Virtual Machines: Jikes RVM, by Ian Rogers and Dave Grove, walks us through the architectural choices required for creating a self-optimizable, self- hosting runtime for a high-level language. Part IV: End-User Application Architectures End-user applications are those that we interact with in our everyday computing lives, and the software that our CPUs burn the most cycles to execute. This kind of software normally does not need to carefully manage resources or serve large transaction volumes. However, it does need to be usable, secure, customizable, and extensible. These properties can lead to popularity and widespread use and, in the case of free and open source software, to an army of volunteers willing to improve it. In Part IV, the authors dissect the architectures and the community processes required to evolve two very popular desktop software packages. Chapter 11, GNU Emacs: Creeping Featurism Is a Strength, by Jim Blandy, explains how a set of very simple components and an extension language can turn the humble text editor into an operating system* the Swiss army knife of a programmer’s toolchest. * As some die-hard users say, “Emacs is my operating system; Linux just provides the device drivers.” P R E F A C E xv
Page 18
Chapter 12, When the Bazaar Sets Out to Build Cathedrals, by Till Adam and Mirko Boehm, demonstrates how community processes such as sprints and peer-reviews can help software architectures evolve from rough sketches into beautiful systems. Part V: Languages and Architecture As many people have pointed out in their works, the programming language we use affects the way we solve a problem. But can a programming language also affect a system’s architecture and, if so, how? In the architecture of buildings, new materials and the adoption of CAD systems allowed the expression of more sophisticated and sometimes strikingly beautiful designs; does the same also apply to computer programs? Part V, which contains the last two chapters, investigates the relationship between the tools we use and the designs we produce. Chapter 13, Software Architecture: Object-Oriented Versus Functional, by Bertrand Meyer, compares the affordances of object-oriented and functional architectural styles. Chapter 14, Rereading the Classics, by Panagiotis Louridas, surveys the architectural choices behind the building blocks of modern and classical object-oriented software languages. Finally, in the thought-provoking Afterword, William J. Mitchell, an MIT Professor of Architecture and Media Arts and Sciences, ties the concept of beauty between the building architectures we encounter in the real world and the software architectures residing on silicon. Principles, Properties, and Structures Late in this book’s review process, one of the reviewers asked us to provide our personal opinion, in the form of commentary, on what a reader could learn from each chapter. The idea was intriguing, but we did not like the fact that we would have to second-guess the chapter authors. Asking the authors themselves to provide a meta-analysis of their writings would lead to a Babel tower of definitions, terms, and architectural constructs guaranteed to confuse readers. What was needed was a common vocabulary of architectural terms; thankfully, we realized we already had that in our hands. In the Foreword, Stephen Mellor discusses seven principles upon which all beautiful architectures are based. In Chapter 1, John Klein and David Weiss present four architecture building blocks and six properties that beautiful architectures exhibit. A careful reader will notice that Mellor’s principles and Klein’s and Weiss’s properties are not independent of each other. In fact, they mostly coincide; this happens because great minds think alike. All three, being very experienced architects, have seen many times in action the importance of the concepts they describe. xvi P R E F A C E
Page 19
We merged Mellor’s architectural principles with the definitions of Klein and Weiss into two lists: one containing principles and properties (Table P-1), and one containing structures (Table P-2). We then asked the chapter authors to mark the terms they thought applied to their chapters, and produced a corresponding legend for each chapter. In these tables, you can see the definition of each principle, property, or architectural construct that appears in the chapter legend. We hope the legends will guide your reading of this book by giving you a clean overview of the contents of each chapter, but we urge you to delve into a chapter’s text rather than simply stay with the legend. TABLE P-1. Architectural principles and properties Principle or property The ability of an architecture to... Versatility ...offer “good enough” mechanisms to address a variety of problems with an economy of expression. Conceptual integrity ...offer a single, optimal, nonredundant way for expressing the solution of a set of similar problems. Independently changeable ...keep its elements isolated so as to minimize the number of changes required to accommodate changes. Automatic propagation ...maintain consistency and correctness, by propagating changes in data or behavior across modules. Buildability ...guide the software’s consistent and correct construction. Growth accommodation ...cater for likely growth. Entropy resistance ...maintain order by accommodating, constraining, and isolating the effects of changes. TABLE P-2. Architectural structures Structure A structure that... Module ...hides design or implementation decisions behind a stable interface. Dependency ...organizes components along the way where one uses functionality of another. Process ...encapsulates and isolates the runtime state of a module. Data access ...compartmentalizes data, setting access rights to it. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. P R E F A C E xvii
Page 20
Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values determined by context. Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Beautiful Architecture, edited by Diomidis Spinellis and Georgios Gousios. Copyright 2009 O’Reilly Media, Inc., 978-0-596-51798-4.” If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at permissions@oreilly.com. Safari® Books Online When you see a Safari® Books Online icon on the cover of your favorite technology book, that means the book is available online through the O’Reilly Network Safari Bookshelf. Safari offers a solution that’s better than e-books. It’s a virtual library that lets you easily search thousands of top tech books, cut and paste code samples, download chapters, and find quick answers when you need the most accurate, current information. Try it for free at http://safari .oreilly.com xviii P R E F A C E
The above is a preview of the first 20 pages. Register to read the complete e-book.

Recommended for You

Loading recommended books...
Failed to load, please try again later

Tip the Site

Scan the WeChat Pay or Alipay code to tip. No login required.

WeChat Pay
Alipay

Every 10 yuan is 1 year of VIP; the remainder counts as months (5 yuan is 5 months, 100 yuan is 10 years). Signed-in users are enabled immediately and both you and the admin get an email. Guests receive an ID and are sent to register.

← Back to List