scispace - formally typeset
Search or ask a question
Author

Martin Fowler

Bio: Martin Fowler is an academic researcher from ThoughtWorks. The author has contributed to research in topics: Software development & Extreme programming. The author has an hindex of 18, co-authored 32 publications receiving 14338 citations. Previous affiliations of Martin Fowler include Association for Computing Machinery.

Papers
More filters
Book
Martin Fowler1
01 Jan 1999
TL;DR: Almost every expert in Object-Oriented Development stresses the importance of iterative development, but how do you add function to the existing code base while still preserving its design integrity?
Abstract: Almost every expert in Object-Oriented Development stresses the importance of iterative development. As you proceed with the iterative development, you need to add function to the existing code base. If you are really lucky that code base is structured just right to support the new function while still preserving its design integrity. Of course most of the time we are not lucky, the code does not quite fit what we want to do. You could just add the function on top of the code base. But soon this leads to applying patch upon patch making your system more complex than it needs to be. This complexity leads to bugs, and cripples your productivity.

5,174 citations

Book
05 Nov 2002
TL;DR: This book discusses the evolution of Layers in Enterprise Applications, Concurrency Problems, and Object-Relational Behavioral Patterns, as well as some Technology-Specific Advice.
Abstract: Preface. Who This Book Is For. Acknowledgements. Colophon. Introduction. Architecture. Enterprise Applications. Kinds of Enterprise Application. Thinking About Performance. Patterns. The Structure of the Patterns. Limitations of These Patterns. I. THE NARRATIVES. 1. Layering. The Evolution of Layers in Enterprise Applications. The Three Principal Layers. Choosing Where to Run Your Layers. 2. Organizing Domain Logic. Making a Choice. Service Layer. 3. Mapping to Relational Databases. Architectural Patterns. The Behavioral Problem. Reading in Data Structural Mapping Patterns. Mapping Relationships. Inheritance. Building the Mapping. Double Mapping. Using Metadata. Database Connections. Some Miscellaneous Points. Further Reading. 4. Web Presentation. View Patterns. Input Controller Patterns. Further Reading. 5. Concurrency (by Martin Fowler and David Rice). Concurrency Problems. Execution Contexts. Isolation and Immutability. Optimistic and Pessimistic Concurrency Control. Preventing Inconsistent Reads. Deadlocks. Transactions. ACID. Transactional Resources. Reducing Transaction Isolation for Liveness. Business and System Transactions. Patterns for Offline Concurrency Control. Application Server Concurrency. Further Reading. 6. Session State. The Value of Statelessness. Session State. Ways to Store Session State. 7. Distribution Strategies. The Allure of Distributed Objects. Remote and Local Interfaces. Where You Have to Distribute. Working with the Distribution Boundary. Interfaces for Distribution. 8. Putting it all Together. Starting With the Domain Layer. Down to the Data Source. Data Source for Transaction Script. Data Source Table Module (125). Data Source for Domain Model (116). The Presentation Layer. Some Technology-Specific Advice. Java and J2EE. .NET. Stored Procedures. Web Services. Other Layering Schemes. II. THE PATTERNS. 9. Domain Logic Patterns. Transaction Script. How It Works. When to Use It. The Revenue Recognition Problem. Example: Revenue Recognition (Java). Domain Model. How It Works. When to Use It. Further Reading. Example: Revenue Recognition (Java). Table Module. How It Works. When to Use It. Example: Revenue Recognition with a Table Module (C#). Service Layer(by Randy Stafford). How It Works. When to Use It. Further Reading. Example: Revenue Recognition (Java). 10. Data Source Architectural Patterns. Table Data Gateway. How It Works. When to Use It. Further Reading. Example: Person Gateway (C#). Example: Using ADO.NET Data Sets (C#). Row Data Gateway. How It Works. When to Use It. Example: A Person Record (Java). Example: A Data Holder for a Domain Object (Java). Active Record. How It Works. When to Use It. Example: A Simple Person (Java). Data Mapper. How It Works. When to Use It. Example: A Simple Database Mapper (Java). Example: Separating the Finders (Java). Example: Creating an Empty Object (Java). 11. Object-Relational Behavioral Patterns. Unit of Work. How It Works. When to Use It. Example: Unit of Work with Object Registration (Java) (by David Rice). Identity Map. How It Works. When to Use It. Example: Methods for an Identity Map (Java). Lazy Load. How It Works. When to Use It. Example: Lazy Initialization (Java). Example: Virtual Proxy (Java). Example: Using a Value Holder (Java). Example: Using Ghosts (C#). 12. Object-Relational Structural Patterns. Identity Field. How It Works. When to Use It. Further Reading. Example: Integral Key (C#). Example: Using a Key Table (Java). Example: Using a Compound Key (Java). Foreign Key Mapping. How It Works. When to Use It. Example: Single-Valued Reference (Java). Example: Multitable Find (Java). Example: Collection of References (C#). Association Table Mapping. How It Works. When to Use It. Example: Employees and Skills (C#). Example: Using Direct SQL (Java). Example: Using a Single Query for Multiple Employees (Java) (by Matt Foemmel and Martin Fowler). Dependent Mapping. How It Works. When to Use It. Example: Albums and Tracks (Java). Embedded Value. How It Works. When to Use It. Further Reading. Example: Simple Value Object (Java). Serialized LOB. How It Works. When to Use It. Example: Serializing a Department Hierarchy in XML (Java). Single Table Inheritance. How It Works. When to Use It. Example: A Single Table for Players (C#). Loading an Object from the Database. Class Table Inheritance. How It Works. When to Use It. Further Reading. Example: Players and Their Kin (C#). Concrete Table Inheritance. How It Works. When to Use It. Example: Concrete Players (C#). Inheritance Mappers. How It Works. When to Use It. 13. Object-Relational Metadata Mapping Patterns. Metadata Mapping. How It Works. When to Use It. Example: Using Metadata and Reflection (Java). Query Object. How It Works. When to Use It. Further Reading. Example: A Simple Query Object (Java). Repository (by Edward Hieatt and Rob Mee). How It Works. When to Use It. Further Reading. Example: Finding a Person's Dependents (Java). Example: Swapping Repository Strategies (Java). 14. Web Presentation Patterns. Model View Controller. How It Works. When to Use It. Page Controller. How It Works. When to Use It. Example: Simple Display with a Servlet Controller and a JSP View (Java). Example: Using a JSP as a Handler (Java). Example: Page Handler with a Code Behind (C#). Front Controller. How It Works. When to Use It. Further Reading. Example: Simple Display (Java). Template View. How It Works. When to Use It. Example: Using a JSP as a View with a Separate Controller (Java). Example: ASP.NET Server Page (C#). Transform View. How It Works. When to Use It. Example: Simple Transform (Java). Two Step View. How It Works. When to Use It. Example: Two Stage XSLT (XSLT). Example: JSP and Custom Tags (Java). Application Controller. How It Works. When to Use It. Further Reading. Example: State Model Application Controller (Java). 15. Distribution Patterns. Remote Facade. How It Works. When to Use It. Example: Using a Java Session Bean as a Remote Facade (Java). Example: Web Service (C#). Data Transfer Object. How It Works. When to Use It. Further Reading. Example: Transferring Information about Albums (Java). Example: Serializing Using XML (Java). 16. Offline Concurrency Patterns. Optimistic Offline Lock (by David Rice). How It Works. When to Use It. Example: Domain Layer with Data Mappers (165) (Java). Pessimistic Offline Lock (by David Rice). How It Works. When to Use It. Example: Simple Lock Manager (Java). Coarse-Grained Lock (by David Rice and Matt Foemmel). How It Works. When to Use It. Example: Shared Optimistic Offline Lock (416) (Java). Example: Shared Pessimistic Offline Lock (426) (Java). Example: Root Optimistic Offline Lock (416) (Java). Implicit Lock (by David Rice). How It Works. When to Use It. Example: Implicit Pessimistic Offline Lock (426) (Java). 17. Session State Patterns. Client Session State. How It Works. When to Use It. Server Session State. How It Works. When to Use It. Database Session State. How It Works. When to Use It. 18. Base Patterns. Gateway. How It Works. When to Use It. Example: A Gateway to a Proprietary Messaging Service (Java). Mapper. How It Works. When to Use It. Layer Supertype. How It Works. When to Use It. Example: Domain Object (Java). Separated Interface. How It Works. When to Use It. Registry. How It Works. When to Use It. Example: A Singleton Registry (Java). Example: Thread-Safe Registry (Java) (by Matt Foemmel and Martin Fowler). Value Object. How It Works. When to Use It. Money. How It Works. When to Use It. Example: A Money Class (Java) (by Matt Foemmel and Martin Fowler). Special Case. How It Works. When to Use It. Further Reading. Example: A Simple Null Object (C#). Plugin (by David Rice and Matt Foemmel). How It Works. When to Use It. Example: An Id Generator (Java). Service Stub (by David Rice). How It Works. When to Use It. Example: Sales Tax Service (Java). Record Set. How It Works. When to Use It. References Index. 0321127420T10162002

1,922 citations

Book
01 Jan 1997
TL;DR: This book describes a lightweight outline process for OO software development and a good process doesn't need to be complicated, and is a good introduction to objects with the UML.
Abstract: From the Book: Two years ago, Addison-Wesley approached me to write a book about the then-new UML. At that time, there was a lot of interest in the UML, but only a standards document from which to learn about it. We broke many records to quickly produce a short introductory guide to the new UML, something that would provide some guidance until the more detailed and official books were to appear later that year. We didnit expect this book to last after more detailed books appeared. Most people believed that given the choice between a slim overview and a detailed text, everyone would pick the detailed text. Although that was the general view, I believed that even in the presence of detailed books, there was still room for a concise summary. Two years later, my hopes have been realized more than I could have wished. UML Distilled has been, in computer industry terms, a best-seller. Even though good detailed books have appeared on the UML, the book still sells well. Better than that, more slim books have appeared, confirming my belief that in a world with so much information, there is value in well-chosen brevity. Now, thatis all very well, but should you buy this book? Iim going to assume youive heard about the UML. It has become the standard way to draw diagrams of object-oriented designs, and it has also spread into non-OO fields. The major pre-UML methods have all died out. The UML has arrived and ishere to stay. If you want to learn about the UML, this book is one way to do it. The main reason for starting with this book is that itis a small book. Buying a big book will give you more information, but it will also take you longer to read. Iive selected the most important parts of the UML so that you donit have to. With this book, youill pick up the key elements of the notation and what they mean. If you want to move further, you can move to a more detailed book later. If you want a longer tutorial to the UML, I suggest the Unified Modeling Language User Guide (Booch, Rumbaugh, and Jacobson 1999). The User Guide is able to cover a lot more ground. Itis well written and organized in a way that explains how to apply the UML to various modeling problems. Both this book and the User Guide assume that you know something about OO development. Although many people have told me that this book is a good introduction to objects, I didnit write it with that in mind. If youire looking for an introduction to objects with the UML, you should also consider Craig Larmanis book (Larman 1998). Although the main point of this book is the UML, Iive also added material that complements the UML material. The UML is a relatively small part of what you need to know to succeed with objects, and I think that itis important to point out some of the other things here. The most important of these is software process. The UML is designed to be independent of process. You can do anything you like; all the UML does is say what your diagrams mean. However, the diagrams donit make much sense without a process to give them context. I also believe that process is important and that a good process doesnit need to be complicated. So, Iive described a lightweight outline process for OO software development. This provides a context for the techniques and will help to get you going in using objects. The other topics include patterns, refactoring, self-testing code, design by contract, and CRC cards. None of these are part of the UML, yet they are valuable techniques that I use regularly. Structure of the Book Chapter 1 looks at what the UML is, the history of its development, and the reasons why you might want to use it. Chapter 2 discusses the object-oriented development process. Although the UML exists independent of process, I find it hard to discuss modeling techniques without talking about where they fit in with object-oriented development. Chapters 3 through 6 discuss the three most important techniques in the UML: use cases, class diagrams, and interaction models. The UML is a large beast, but you donit need all of it. These three techniques are the core that almost everyone needs. Start with these and add the others as you need them. (Note that since class diagrams are so complicated in themselves, Iive put the key parts of class diagrams in Chapter 4 and the advanced concepts in Chapter 6. ) Chapters 7 through 10 explore the remaining techniques. All of these are valuable, but not every project needs every technique. So these chapters provide enough information to tell you what the technique is and whether you need it. For all of these techniques, I describe the notation, explain what the notation means, and provide tips about using the techniques. My philosophy is to make clear what the UML says and, at the same time, to give you my opinions on how best to use it. Iive also added pointers to other books that provide more detail. Chapter 11 gives a small example to show how the UML fits in with programming using (of course) Java. The inside covers summarize the UML notation. You may find it useful to refer to these as you are reading the chapters so that you can check on the notation for the various modeling concepts. If you find this book interesting, you can find other information on my work related to using the UML, patterns, and refactoring at my home page (see page xxi). Changes for the Second Edition As the UML evolved, and I received feedback about the first edition of the book, I continually updated it. We reprinted every two or three months; nearly every printing contained updates, which resulted in considerable strain on the processes of the publishing industry. With the change from UML 1.2 to 1.3, we decided to do a more thorough overhaul of the book, enough to produce a second edition. Since the book has been so popular, Iive tried not to change the essential spirit of the book. Iive carefully tried to not add much, and to see whether there are things I can take away. The biggest changes are in Chapter 3, about use cases, and Chapter 9, about activity diagrams, which have each received a severe rewrite. Iive also added a section on collaborations to Chapter 7. Elsewhere, Iive taken the opportunity to make a host of smaller changes, based on feedback and my experiences over the last couple of years. Martin Fowler Melrose, Massachusetts April 1999 fowler@acm.org http://ourworld.compuserve.com/homepages/Martin_Fowler

1,087 citations

Book
23 Sep 2010
TL;DR: This book covers a variety of different techniques available for DSLs and can be used with whatever programming language you happen to be using, most of the examples are in Java or C#.
Abstract: Designed as a wide-ranging guide to Domain Specific Languages (DSLs) and how to approach building them, this book covers a variety of different techniques available for DSLs. The goal is to provide readers with enough information to make an informed choice about whether or not to use a DSL and what kinds of DSL techniques to employ. Part I is a 150-page narrative overview that gives you a broad understanding of general principles. The reference material in Parts II through VI provides the details and examples you willneed to get started using the various techniques discussed. Both internal and external DSL topics are covered, in addition to alternative computational models and code generation. Although the general principles and patterns presented can be used with whatever programming language you happen to be using, most of the examples are in Java or C#.

908 citations


Cited by
More filters
Book
Martin Fowler1
01 Jan 1999
TL;DR: Almost every expert in Object-Oriented Development stresses the importance of iterative development, but how do you add function to the existing code base while still preserving its design integrity?
Abstract: Almost every expert in Object-Oriented Development stresses the importance of iterative development. As you proceed with the iterative development, you need to add function to the existing code base. If you are really lucky that code base is structured just right to support the new function while still preserving its design integrity. Of course most of the time we are not lucky, the code does not quite fit what we want to do. You could just add the function on top of the code base. But soon this leads to applying patch upon patch making your system more complex than it needs to be. This complexity leads to bugs, and cripples your productivity.

5,174 citations

Book
01 Nov 2002
TL;DR: Drive development with automated tests, a style of development called “Test-Driven Development” (TDD for short), which aims to dramatically reduce the defect density of code and make the subject of work crystal clear to all involved.
Abstract: From the Book: “Clean code that works” is Ron Jeffries’ pithy phrase. The goal is clean code that works, and for a whole bunch of reasons: Clean code that works is a predictable way to develop. You know when you are finished, without having to worry about a long bug trail.Clean code that works gives you a chance to learn all the lessons that the code has to teach you. If you only ever slap together the first thing you think of, you never have time to think of a second, better, thing. Clean code that works improves the lives of users of our software.Clean code that works lets your teammates count on you, and you on them.Writing clean code that works feels good.But how do you get to clean code that works? Many forces drive you away from clean code, and even code that works. Without taking too much counsel of our fears, here’s what we do—drive development with automated tests, a style of development called “Test-Driven Development” (TDD for short). In Test-Driven Development, you: Write new code only if you first have a failing automated test.Eliminate duplication. Two simple rules, but they generate complex individual and group behavior. Some of the technical implications are:You must design organically, with running code providing feedback between decisionsYou must write your own tests, since you can’t wait twenty times a day for someone else to write a testYour development environment must provide rapid response to small changesYour designs must consist of many highly cohesive, loosely coupled components, just to make testing easy The two rules imply an order to the tasks ofprogramming: 1. Red—write a little test that doesn’t work, perhaps doesn’t even compile at first 2. Green—make the test work quickly, committing whatever sins necessary in the process 3. Refactor—eliminate all the duplication created in just getting the test to work Red/green/refactor. The TDD’s mantra. Assuming for the moment that such a style is possible, it might be possible to dramatically reduce the defect density of code and make the subject of work crystal clear to all involved. If so, writing only code demanded by failing tests also has social implications: If the defect density can be reduced enough, QA can shift from reactive to pro-active workIf the number of nasty surprises can be reduced enough, project managers can estimate accurately enough to involve real customers in daily developmentIf the topics of technical conversations can be made clear enough, programmers can work in minute-by-minute collaboration instead of daily or weekly collaborationAgain, if the defect density can be reduced enough, we can have shippable software with new functionality every day, leading to new business relationships with customers So, the concept is simple, but what’s my motivation? Why would a programmer take on the additional work of writing automated tests? Why would a programmer work in tiny little steps when their mind is capable of great soaring swoops of design? Courage. Courage Test-driven development is a way of managing fear during programming. I don’t mean fear in a bad way, pow widdle prwogwammew needs a pacifiew, but fear in the legitimate, this-is-a-hard-problem-and-I-can’t-see-the-end-from-the-beginning sense. If pain is nature’s way of saying “Stop!”, fear is nature’s way of saying “Be careful.” Being careful is good, but fear has a host of other effects: Makes you tentativeMakes you want to communicate lessMakes you shy from feedbackMakes you grumpy None of these effects are helpful when programming, especially when programming something hard. So, how can you face a difficult situation and: Instead of being tentative, begin learning concretely as quickly as possible.Instead of clamming up, communicate more clearly.Instead of avoiding feedback, search out helpful, concrete feedback.(You’ll have to work on grumpiness on your own.) Imagine programming as turning a crank to pull a bucket of water from a well. When the bucket is small, a free-spinning crank is fine. When the bucket is big and full of water, you’re going to get tired before the bucket is all the way up. You need a ratchet mechanism to enable you to rest between bouts of cranking. The heavier the bucket, the closer the teeth need to be on the ratchet. The tests in test-driven development are the teeth of the ratchet. Once you get one test working, you know it is working, now and forever. You are one step closer to having everything working than you were when the test was broken. Now get the next one working, and the next, and the next. By analogy, the tougher the programming problem, the less ground should be covered by each test. Readers of Extreme Programming Explained will notice a difference in tone between XP and TDD. TDD isn’t an absolute like Extreme Programming. XP says, “Here are things you must be able to do to be prepared to evolve further.” TDD is a little fuzzier. TDD is an awareness of the gap between decision and feedback during programming, and techniques to control that gap. “What if I do a paper design for a week, then test-drive the code? Is that TDD?” Sure, it’s TDD. You were aware of the gap between decision and feedback and you controlled the gap deliberately. That said, most people who learn TDD find their programming practice changed for good. “Test Infected” is the phrase Erich Gamma coined to describe this shift. You might find yourself writing more tests earlier, and working in smaller steps than you ever dreamed would be sensible. On the other hand, some programmers learn TDD and go back to their earlier practices, reserving TDD for special occasions when ordinary programming isn’t making progress. There are certainly programming tasks that can’t be driven solely by tests (or at least, not yet). Security software and concurrency, for example, are two topics where TDD is not sufficient to mechanically demonstrate that the goals of the software have been met. Security relies on essentially defect-free code, true, but also on human judgement about the methods used to secure the software. Subtle concurrency problems can’t be reliably duplicated by running the code. Once you are finished reading this book, you should be ready to: Start simplyWrite automated testsRefactor to add design decisions one at a time This book is organized into three sections. An example of writing typical model code using TDD. The example is one I got from Ward Cunningham years ago, and have used many times since, multi-currency arithmetic. In it you will learn to write tests before code and grow a design organically.An example of testing more complicated logic, including reflection and exceptions, by developing a framework for automated testing. This example also serves to introduce you to the xUnit architecture that is at the heart of many programmer-oriented testing tools. In the second example you will learn to work in even smaller steps than in the first example, including the kind of self-referential hooha beloved of computer scientists.Patterns for TDD. Included are patterns for the deciding what tests to write, how to write tests using xUnit, and a greatest hits selection of the design patterns and refactorings used in the examples. I wrote the examples imagining a pair programming session. If you like looking at the map before wandering around, you may want to go straight to the patterns in Section 3 and use the examples as illustrations. If you prefer just wandering around and then looking at the map to see where you’ve been, try reading the examples through and refering to the patterns when you want more detail about a technique, then using the patterns as a reference. Several reviewers have commented they got the most out of the examples when they started up a programming environment and entered the code and ran the tests as they read. A note about the examples. Both examples, multi-currency calculation and a testing framework, appear simple. There are (and I have seen) complicated, ugly, messy ways of solving the same problems. I could have chosen one of those complicated, ugly, messy solutions to give the book an air of “reality.” However, my goal, and I hope your goal, is to write clean code that works. Before teeing off on the examples as being too simple, spend 15 seconds imagining a programming world in which all code was this clear and direct, where there were no complicated solutions, only apparently complicated problems begging for careful thought. TDD is a practice that can help you lead yourself to exactly that careful thought.

1,864 citations

Proceedings ArticleDOI
01 Nov 2017
TL;DR: The present document details the how, why and when to apply refactoring in computer systems that have been poorly designed, this in order to a better performance and maintenance of the constituent components.
Abstract: The present document contains the most relevant results obtained in the study of refactoring Mainly it addresses the general aspects of refactoring and the basic concepts that make it up, then it details the how, why and when to apply refactoring in computer systems that have been poorly designed, this in order to a better performance and maintenance of the constituent components Finally, it is emphasized the importance of the refactoring process as such in software development

1,676 citations

Journal ArticleDOI
TL;DR: This research is compared and discussed based on a number of different criteria: the refactoring activities that are supported, the specific techniques and formalisms that are used for supporting these activities, the types of software artifacts that are being refactored, the important issues that need to be taken into account when buildingRefactoring tool support, and the effect of refactors on the software process.
Abstract: We provide an extensive overview of existing research in the field of software refactoring. This research is compared and discussed based on a number of different criteria: the refactoring activities that are supported, the specific techniques and formalisms that are used for supporting these activities, the types of software artifacts that are being refactored, the important issues that need to be taken into account when building refactoring tool support, and the effect of refactoring on the software process. A running example is used to explain and illustrate the main concepts.

1,206 citations