Apress.Design.Patterns.in.NET.2019.pdf

所需积分/C币:19 2019-06-01 12:28:22 3.16MB PDF
收藏 收藏
举报

Apress.Design.Patterns.in.NET.2019.pdf
Design Patterns in. NET: Reusable Approaches in C# and f#for Object-Oriented Software Design Dmitri Nesteruk St Petersburg, C.St-Peterburg, Russia ISBN-13(pbk):978-1-48424365-7 ISBN-13(electronic): 978-1-4842-4366-4 https://doi.org/10.1007/978-1-4842-4366-4 Copyright o 2019 by Dmitri Nesteruk This work is subject to copyright all rights are reserved by the publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way and transmission or information storage and retrieval, electronic adaptation, computer software or by similar or dissimilar methodology now known or hereafter developed Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no ntention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Joan murray Development Editor: Laura Berendson Coordinating Editor: Jill Balzano Cover designed by eStudio Calamar CoverimagedesignedbyFreepik(www.freepik.com Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-ny@springer-sbm.com,orvisitwww.springeronline.comApressMedia,Llcisa California LLC and the sole member(owner) is Springer Science+ Business Media Finance Inc SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation Forinformationontranslationspleasee-mailrights@apress.com,orvisithttp://www.apress com/rights-permissions Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles. for more information reference our print andebooKBulksaleswebpageathttp://www.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is availabletoreadersonGithubviathebooksproductpagelocatedatwww.apress com/9781484243657.Formoredetailedinformationpleasevisithttp://www.apress.com/ source-code Printed on acid-free paper Table of contents About the author ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ Introduction xiii Part a ntroduction ■口■■■ Single Responsibility Principle….… 1336 Chapter 1: The SOLID Design Principles mmmm RRRR R RnaN Open-Closed Principle. Liskov Substitution Principle. Interface Segregation Principle........................17 Dependency Inversion Principle......……2 Chapter 2: The Functional Perspective ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■口■■■■■口■■■ 27 Function basics 27 Functional literals in ctt mmmm 30 Storing functions in C#.…..….....…...…30 Functional literals in ftt 33 Composition Functional-Related Language Features Part la creational patterns ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 39 Chapter 3: Builder mmmammmanmmmmammmmammmma 41 Scenario Simple builder. 44 TABLE OF CONTENTS Fluent builder Communicating Intent. 46 Composite builder 48 Builder parameter 52 Fluent Interface Inheritance 55 DSL Construction in F#t. mmmm. 59 Summary… 61 Chapter 4: Factories ■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■口■■■■■冒■■口■■ 63 Scenario…… 63 Factory Method Factory Inner Factory 6 Logⅰ cal Separation.…,,,,, 69 Abstract Factory.…, 69 Functional Factory……,,…,, 72 Summary........,,174 Chapter 5: Prototype BBBBRRRRABRBBBRRRRRRRRRRRBIBRBRIaN 77 Deep vs. Shallow Copying ICloneable is bad Deep Copying with a Special Interface 80 Deep Copying objects.......................81 Duplication via Copy construction. Serialization ,84 Prototype Factory ,86 Summary. TABLE OF CONTENTS Chapter 6: Singleton ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■ 91 Singleton by Convention …92 Classic Implementation.........,………93 Lazy Loading 94 The Trouble with Singleton.……95 Singletons and Inversion of Control.mm....m...mno 100 Monostate m, 101 Summary 102 Part la structural patterns ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 103 Chapter 7: Adapter mmmm. ng105 Scenari0,…………105 Adapter…....107 Adapter Temporaries.mmammmmamnaanmnammnammamemnamnmnmnmnn 109 The problem with Hashing…… 113 Property Adapter(Surrogate) 116 Adapters in the. NET Framework 118 Summary Chapter 8: Bridge anaamaaamamEaRImRIIIIEEn 121 Conventional bridge.m...e..u. 121 Dynamic Prototyping bridge Summary........,,,,,129 Chapter 9: composite mmmmmammmam IIaa 131 Grouping Graphic Objects 131 Neural networks…134 Shrink Wrapping the composite mmmmm. Summary.. 10 TABLE OF CONTENTS Chapter 10: Decorator .atmaaaaaa EEaIRIRLIIIERERn 141 Custom String Builder Adapter- Decorator….…144 Multiple Inheritance. mmmmmmmmmmmmmmmmmmmmmmmmmm. 145 Dynamic Decorator Composition...,,.,,…,……149 Static Decorato…153 Functional decorator 155 Summary Chapter11: Facade.… 159 Building a Trading Terminal An Advanced terminal mmmm 162 Where’ s the Facade? ,165 Summary Chapter 12: Flyweight aamamaaaaa IAEA 169 Usernames Text Formatting ...........................................................172 Summary............ 176 Chapter13: Proxy… ■■■■■■ g177 Protection Proxy 177 Property Proxy…… 180 Virtual Proxy… 183 Communication Proxy mmmemnmemmnmnmnnnnnn. Summary TABLE OF CONTENTS Part ve behavioral patterns 圆■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■ 191 Chapter 14: Chain of Responsibility m ar g193 Scena0…193 Method chain 194 Broker chain…198 Summary 203 Chapter 15: Command memmemaenat 目■■■■■ u205 Scenari0n…………………………205 Implementing the Command Pattern Undo Operations 208 Composite Commands……212 Functional command 216 Queries and Command Query Separation.…,…………218 Summary Chapter 16: Interpreter ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■a■■■■a■■a 221 Numeric Expression Evaluator.nmtnnannnaanncanannanannnan. 222 exing…,,,,,23 Parsing…226 Using lexer and parser ...mmmmm..m.m....m..... 230 Interpretation in the functional Paradigm ............ 230 Summary Chapter 17: Iterator mammae 237 Array-Backed Properties 238 et's make an iterator Improved Iteration 245 Summary…..…247 TABLE OF CONTENTS Chapter 18; Mediator mmmaammmmmammammmmmmmmmmmaa249 Chat room Mediator with Events 254 Summary. Chapter 19: Memento 261 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■ Bank account 261 Undo and redo 263 Summary 26 Chapter 20: Null object. 269 Scenario 269 Intrusive approach 271 Null object 271 Design Improvements…....,,……272 Null Object virtual Proxy 273 Dynamic Null object 274 Summary 276 Chapter 21: Observer mmmmmammmmmmmmmammmmmmmmmammmmammmmmm279 Weak event pattern,… 28 Property Observers n284 Dependency Problems m.n. 286 Event streams. mmmmm. 292 Observable collections, mmo. 297 Declarative Subscriptions…..,.,,….298 Summary 300 TABLE OF CONTENTS Chapter 22: State amammmmammmmmmmam 30 State-Driven state transitions 302 Handmade state machine m305 State Machines with Types, Actions, and Ignoring Transitions n309 Reentrancy Again.…...,,,,,,,,,,…,……311 Hierarchical States 312 More Features Summary… 13144 Chapter 23: Strategy ammamaamanmmmaaaamm 315 Dynamic Strategy.…, 316 Static Strategy…, 319 Functional Strategy 321 Summary…… 322 Chapter 24: Template Method.aaaa ma aam 323 Game simulation …323 Functional Template Method 326 Summary 328 Chapter 25: Visitor. 329 intrusive visitor…330 Reflective printer…332 Functional reflective visitor 334 Improvements. .......mmmmmmmm...m.m...mmmmmm...mm..m What Is Dispatch? .mtamaanaanaaneanaanaaamaaaanaann 336 Dynamic visitor∴138

...展开详情
试读 127P Apress.Design.Patterns.in.NET.2019.pdf
立即下载 低至0.43元/次 身份认证VIP会员低至7折
    抢沙发
    一个资源只可评论一次,评论内容不能少于5个字
    img
    DoomLord
    • 至尊王者

      成功上传501个资源即可获取

    关注 私信 TA的资源

    上传资源赚积分,得勋章
    最新推荐
    Apress.Design.Patterns.in.NET.2019.pdf 19积分/C币 立即下载
    1/127
    Apress.Design.Patterns.in.NET.2019.pdf第1页
    Apress.Design.Patterns.in.NET.2019.pdf第2页
    Apress.Design.Patterns.in.NET.2019.pdf第3页
    Apress.Design.Patterns.in.NET.2019.pdf第4页
    Apress.Design.Patterns.in.NET.2019.pdf第5页
    Apress.Design.Patterns.in.NET.2019.pdf第6页
    Apress.Design.Patterns.in.NET.2019.pdf第7页
    Apress.Design.Patterns.in.NET.2019.pdf第8页
    Apress.Design.Patterns.in.NET.2019.pdf第9页
    Apress.Design.Patterns.in.NET.2019.pdf第10页
    Apress.Design.Patterns.in.NET.2019.pdf第11页
    Apress.Design.Patterns.in.NET.2019.pdf第12页
    Apress.Design.Patterns.in.NET.2019.pdf第13页
    Apress.Design.Patterns.in.NET.2019.pdf第14页
    Apress.Design.Patterns.in.NET.2019.pdf第15页
    Apress.Design.Patterns.in.NET.2019.pdf第16页
    Apress.Design.Patterns.in.NET.2019.pdf第17页
    Apress.Design.Patterns.in.NET.2019.pdf第18页
    Apress.Design.Patterns.in.NET.2019.pdf第19页
    Apress.Design.Patterns.in.NET.2019.pdf第20页

    试读已结束,剩余107页未读...

    19积分/C币 立即下载 >