欢迎来到天天文库
浏览记录
ID:49411631
大小:543.00 KB
页数:10页
时间:2020-02-06
《面向对象系统分析与设计_单例模式.ppt》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright1OOSystemAnalysis&Design【SingletonPattern】29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright2Enjoychocolate…29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright3Ourjobis:Todesignachocolateboiler,whichcouldmak
2、eachocolatebars.29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright4Therulesofchocolateboiler:Tofilltheboileritmustbeempty;Todraintheboileritmustbefullandalsoboiled.Toboiltheboileritmustbefullandnotalreadyboiled.29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright5Howtod
3、esigntheclass?properties?methodbody?29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright6Aclassdiagram:29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright7Question:CanyouimprovetheChocolateBoilerclassintowhichonlyoneinstanceofChocalateBoileriscreatedinanapplication?29八月2
4、021NeusoftComputerScienceandTechnologyDepartmentcopyright8TheSingletonPatternTheSingletonPatternensuresaclasshasonlyoneinstance,andprovidesaglobalpointofaccesstoit.29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright9Classdiagram:FactoryMethodHoldsouroneandonlyinstanceofSingleton.Y
5、oucanconvenientlyaccessthemethodanywhere?29八月2021NeusoftComputerScienceandTechnologyDepartmentcopyright10ClassisoverCongratulations!
此文档下载收益归作者所有