Domain-Specific Languages, 1st edition
BRAND: PEARSON
eBook edition. 1 Year Subscription. Dành cho Cá nhân | Trường ĐH, Nhóm, Thư Viện: Gọi 0915920514 để báo giá Pearson, Vital Source eBook hoặc mua Sách In
Tổng quan sách
Khi được lựa chọn và sử dụng cẩn thận, Ngôn ngữ dành riêng cho miền (DSL) có thể đơn giản hóa mã phức tạp, thúc đẩy giao tiếp hiệu quả với khách hàng, cải thiện năng suất và giải quyết các tắc nghẽn trong quá trình phát triển. Trong Ngôn ngữ dành riêng cho miền, chuyên gia phát triển phần mềm nổi tiếng Martin Fowler trước tiên cung cấp thông tin mà các chuyên gia phần mềm cần để quyết định xem có nên sử dụng DSL hay không và khi nào. Sau đó, khi DSL tỏ ra phù hợp, Fowler trình bày các kỹ thuật hiệu quả để xây dựng chúng và hướng dẫn các kỹ sư phần mềm lựa chọn phương pháp phù hợp cho ứng dụng của họ. Các kỹ thuật của cuốn sách này có thể được sử dụng với hầu hết các ngôn ngữ hướng đối tượng hiện đại; tác giả cung cấp nhiều ví dụ về Java và C#, cũng như các ví dụ được chọn lọc trong Ruby. Bất cứ khi nào có thể, các chương đều được sắp xếp theo cách độc lập và hầu hết các chủ đề tham khảo đều được trình bày theo định dạng mẫu quen thuộc. Được trang bị cuốn sách có phạm vi rộng này, các nhà phát triển sẽ có kiến thức cần thiết để đưa ra các quyết định quan trọng về DSL—và khi thích hợp, đạt được những lợi ích kinh doanh và kỹ thuật đáng kể mà họ mang lại.Các chủ đề được đề cập bao gồm:DSL so sánh với các khung và thư viện như thế nào và khi nào những lựa chọn thay thế đó là đủSử dụng trình phân tích cú pháp và trình tạo trình phân tích cú pháp cũng như phân tích cú pháp DSL bên ngoàiHiểu, so sánh và lựa chọn cấu trúc ngôn ngữ DSLXác định xem có nên sử dụng tạo mã hay không và so sánh các chiến lược tạo mãXem trước các công cụ bàn làm việc ngôn ngữ mới để tạo DSL
- Preface xixPart I: Narratives 1
- Chapter 1: An Introductory Example 3Gothic Security 3The State Machine Model 5Programming Miss Grant’s Controller 9Languages and Semantic Model 16Using Code Generation 19Using Language Workbenches 22Visualization 24
- Chapter 2: Using Domain-Specific Languages 27Defining Domain-Specific Languages 27Why Use a DSL? 33Problems with DSLs 36Wider Language Processing 39DSL Lifecycle 40What Makes a Good DSL Design? 42
- Chapter 3: Implementing DSLs 43Architecture of DSL Processing 43The Workings of a Parser 47Grammars, Syntax, and Semantics 49Parsing Data 50Macros 52
- Chapter 4: Implementing an Internal DSL 67Fluent and Command-Query APIs 68The Need for a Parsing Layer 71Using Functions 72Literal Collections 77Using Grammars to Choose Internal Elements 79Closures 80Parse Tree Manipulation 82Annotation 84Literal Extension 85Reducing the Syntactic Noise 85Dynamic Reception 86Providing Some Type Checking 87
- Chapter 5: Implementing an External DSL 89Syntactic Analysis Strategy 89Output Production Strategy 92Parsing Concepts 94Mixing-in Another Language 100XML DSLs 101
- Chapter 6: Choosing between Internal and External DSLs 105Learning Curve 105Cost of Building 106Programmer Familiarity 107Communication with Domain Experts 108Mixing In the Host Language 108Strong Expressiveness Boundary 109Runtime Configuration 110Sliding into Generality 110Composing DSLs 111Summing Up 111
- Chapter 7: Alternative Computational Models 113A Few Alternative Models 116
- Chapter 8: Code Generation 121Choosing What to Generate 122How to Generate 124Mixing Generated and Handwritten Code 126Generating Readable Code 127Preparse Code Generation 128Further Reading 128
- Chapter 9: Language Workbenches 129Elements of Language Workbenches 130Schema Definition Languages and Meta-Models 131Source and Projectional Editing 136Illustrative Programming 138Tools Tour 140Language Workbenches and CASE tools 141Should You Use a Language Workbench? 142Part II: Common Topics 145
- Chapter 10: A Zoo of DSLs 147Graphviz 147JMock 149CSS 150Hibernate Query Language (HQL) 151XAML 152FIT 155Make et al. 156
- Chapter 11: Semantic Model 159How It Works 159When to Use It 162The Introductory Example (Java) 163
- Chapter 12: Symbol Table 165How It Works 166When to Use It 168Further Reading 168Dependency Network in an External DSL (Java and ANTLR) 168Using Symbolic Keys in an Internal DSL (Ruby) 170Using Enums for Statically Typed Symbols (Java) 172
- Chapter 13: Context Variable 175How It Works 175When to Use It 176Reading an INI File (C#) 176
- Chapter 14: Construction Builder 179How It Works 179When to Use It 180Building Simple Flight Data (C#) 180
- Chapter 15: Macro 183How It Works 184When to Use It 192
- Chapter 16: Notification 193How It Works 194When to Use It 194A Very Simple Notification (C#) 194Parsing Notification (Java) 195Part III: External DSL Topics 199
- Chapter 17: Delimiter-Directed Translation 201How It Works 201When to Use It 204Frequent Customer Points (C#) 205Parsing Nonautonomous Statements with Miss Grant’s Controller (Java) 211
- Chapter 18: Syntax-Directed Translation 219How It Works 220When to Use It 227Further Reading 227
- Chapter 19: BNF 229How It Works 229When to Use It 238
- Chapter 20: Regex Table Lexer (by Rebecca Parsons)239How It Works 240When to Use It 241Lexing Miss Grant’s Controller (Java) 241
- Chapter 21: Recursive Descent Parser (by Rebecca Parsons)245How It Works 246When to Use It 249Further Reading 249Recursive Descent and Miss Grant’s Controller (Java) 250
- Chapter 22: Parser Combinator (by Rebecca Parsons)255How It Works 256When to Use It 261Parser Combinators and Miss Grant’s Controller (Java) 261
- Chapter 23: Parser Generator 269How It Works 269When to Use It 272Hello World (Java and ANTLR) 272
- Chapter 24: Tree Construction 281How It Works 281When to Use It 284Using ANTLR’s Tree Construction Syntax (Java and ANTLR) 284Tree Construction Using Code Actions (Java and ANTLR) 292
- Chapter 25: Embedded Translation 299How It Works 299When to Use It 300Miss Grant’s Controller (Java and ANTLR) 300
- Chapter 26: Embedded Interpretation 305How It Works 305When to Use It 306A Calculator (ANTLR and Java) 306
- Chapter 27: Foreign Code 309How It Works 309When to Use It 311Embedding Dynamic Code (ANTLR, Java, and Javascript) 311
- Chapter 28: Alternative Tokenization 319How It Works 319When to Use It 326
- Chapter 29: Nested Operator Expression 327How It Works 327When to Use It 331
- Chapter 30: Newline Separators 333How It Works 333When to Use It 335
- Chapter 31: External DSL Miscellany 337Syntactic Indentation 337Modular Grammars 339Part IV: Internal DSL Topics 341
- Chapter 32: Expression Builder 343How It Works 344When to Use It 344A Fluent Calendar with and without a Builder (Java) 345Using Multiple Builders for the Calendar (Java) 348
- Chapter 33: Function Sequence 351How It Works 351When to Use It 352Simple Computer Configuration (Java) 352
- Chapter 34: Nested Function 357How It Works 357When to Use It 359The Simple Computer Configuration Example (Java) 360Handling Multiple Different Arguments with Tokens (C#) 361Using Subtype Tokens for IDE Support (Java) 363Using Object Initializers (C#) 365Recurring Events (C#) 366
- Chapter 35: Method Chaining 373How It Works 373When to Use It 377The Simple Computer Configuration Example (Java) 378Chaining with Properties (C#) 381Progressive Interfaces (C#) 382
- Chapter 36: Object Scoping 385How It Works 386When to Use It 386Security Codes (C#) 387Using Instance Evaluation (Ruby) 392Using an Instance Initializer (Java) 394
- Chapter 37: Closure 397How It Works 397When to Use It 402
- Chapter 38: Nested Closure 403How It Works 403When to Use It 405Wrapping a Function Sequence in a Nested Closure (Ruby) 405Simple C# Example (C#) 408Using Method Chaining (Ruby) 409Function Sequence with Explicit Closure Arguments (Ruby 411Using Instance Evaluation (Ruby) 412
- Chapter 39: Literal List 417How It Works 417When to Use It 417
- Chapter 40: Literal Map 419How It Works 419When to Use It 420The Computer Configuration Using Lists and Maps (Ruby) 420Evolving to Greenspun Form (Ruby) 422
- Chapter 41: Dynamic Reception 427How It Works 428When to Use It 429Promotion Points Using Parsed Method Names (Ruby) 430Promotion Points Using Chaining (Ruby) 434Removing Quoting in the Secret Panel Controller (JRuby) 438
- Chapter 42: Annotation 445How It Works 446When to Use It 449Custom Syntax with Runtime Processing (Java) 449Using a Class Method (Ruby) 451Dynamic Code Generation (Ruby) 452
- Chapter 43: Parse Tree Manipulation 455How It Works 455When to Use It 456Generating IMAP Queries from C# Conditions (C#) 457
- Chapter 44: Class Symbol Table 467How It Works 468When to Use It 469Statically Typed Class Symbol Table (Java) 469
- Chapter 45: Textual Polishing 477How It Works 477When to Use It 478Polished Discount Rules (Ruby) 478
- Chapter 46: Literal Extension 481How It Works 481When to Use It 482Recipe Ingredients (C#) 483Part V: Alternative Computational Models 485
- Chapter 47: Adaptive Model 487How It Works 488When to Use It 492
- Chapter 48: Decision Table 495How It Works 495When to Use It 497Calculating the Fee for an Order (C#) 497
- Chapter 49: Dependency Network 505How It Works 506When to Use It 508Analyzing Potions (C#) 508
- Chapter 50: Production Rule System 513How It Works 514When to Use It 517Validations for club membership (C#) 517Eligibility Rules: extending the club membership (C#) 521
- Chapter 51: State Machine 527How It Works 527When to Use It 529Secret Panel Controller (Java) 530Part VI: Code Generation 531
- Chapter 52: Transformer Generation 533How It Works 533When to Use It 535Secret Panel Controller (Java generating C) 535
- Chapter 53: Templated Generation 539How It Works 539When to Use It 541Generating the Secret Panel State Machine with Nested Conditionals (Velocity and Java generating C) 541
- Chapter 54: Embedment Helper 547How It Works 548When to Use It 549Secret Panel States (Java and ANTLR) 549Should a Helper Generate HTML? (Java and Velocity) 552
- Chapter 55: Model-Aware Generation 555How It Works 556When to Use It 556Secret Panel State Machine (C) 557Loading the State Machine Dynamically (C) 564
- Chapter 56: Model Ignorant Generation 567How It Works 567When to Use It 568Secret Panel State Machine as Nested Conditionals (C) 568
- Chapter 57: Generation Gap 571How It Works 571When to Use It 573Generating Classes from a Data Schema (Java and a Little Ruby) 573Bibliography 579Index 581
