欢迎来到天天文库
浏览记录
ID:34818286
大小:4.26 MB
页数:249页
时间:2019-03-11
《Functional Design Patterns.pdf》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、FunctionalDesignPatterns@ScottWlaschinfsharpforfunandprofit.comFunctionalDesignPatternsX@ScottWlaschinfsharpforfunandprofit.comFunctionalDesignPatterns@ScottWlaschinfsharpforfunandprofit.comFunctionalpatterns•Apomorphisms•Dynamorphisms•Chronomorphisms•Zygohi
2、stomorphicprepromorphismsFunctionalpatterns•CorePrinciplesofFPdesign–Functions,types,composition•Functionsasparameters–Abstraction,Dependencyinjection–Partialapplication,Continuations,Folds,•Chainingfunctions–Errorhandling,Async–Monads•Dealingwithwrappeddata
3、–Lifting,Functors–ValidationwithApplicatives•Aggregatingdataandoperations–MonoidsThistalkFunctionalprogrammingisscaryFunctionalprogrammingisscaryObjectorientedprogrammingisscaryOOpattern/principleFPpattern/principle•SingleResponsibilityPrinciple•Functions•Op
4、en/Closedprinciple•Functions•DependencyInversion•Functions,alsoPrinciple•InterfaceSegregation•FunctionsPrinciple•Factorypattern•Yes,functions•Strategypattern•Ohmy,functionsagain!•Decoratorpattern•Functions•Visitorpattern•FunctionsSeriously,FPpatternsarediff
5、erentAshortandmostlywronghistoryofprogrammingparadigmsObject-Orientedprogramming•Whatweenvisioned:–Smalltalk•Whatwegot:–C++“Worseisbetter”–ObjectorientedCobol–PHP–JavaFunctionalprogramming•Whatweenvisioned:–Haskell,OCaml,F#,etc•Whatwegot:–??Pleasedon’tletthi
6、shappentoFP!Importanttounderstand!COREPRINCIPLESOFFPDESIGNCoreprinciplesofFPdesignStealfrommathematicsTypesarenotclassesFunctionsarethingsFunctionCompositioneverywhereCoreprinciple:Stealfrommathematics“Programmingisoneofthemostdifficultbranchesofappliedmathe
7、matics”-E.W.DijkstraWhymathematicsDijkstrasaid:•Mathematicalassertionstendtobeunusuallyprecise.•Mathematicalassertionstendtobegeneral.Theyareapplicabletoalarge(ofteninfinite)classofinstances.•Mathematicsembodiesadisciplineofreasoningallowingassertionstobemad
8、ewithanunusuallyhighconfidencelevel.“Object-orientedprogrammingisanexceptionallybadideawhichcouldonlyhaveoriginatedinCalifornia.”E.W.DijkstraMathematicalfunctionsDomain(int)Codomain(int)……-10011
此文档下载收益归作者所有