• 首页
  • 期刊简介
  • 编委会
  • 投稿指南
  • 收录情况
  • 杂志订阅
  • 联系我们
引用本文:闵 军,罗 泓.用lambda表达式和std::function类模板改进泛型抽象工厂设计[J].软件工程,2017,20(9):9-14.【点击复制】
【打印本页】   【下载PDF全文】   【查看/发表评论】  【下载PDF阅读器】  
←前一篇|后一篇→ 过刊浏览
分享到: 微信 更多
用lambda表达式和std::function类模板改进泛型抽象工厂设计
闵 军,罗 泓
(宜宾学院图书馆,四川 宜宾 644000)
摘 要: 抽象工厂模式在软件设计中应用广泛,但抽象工厂模式的传统实现方式存在诸多不足。随着技术的发 展,设计模式的实现方式也在不断改进。C++11新标准发布之后,涌现了许多改进方案。本文将在这些改进的基础之 上,使用C++11的lambda表达式、std::function类模板等新技术,通过数据结构和代码结构的优化等方式进一步改进 泛型抽象工厂设计,给出一种“新型泛型抽象工厂”的实现方式。实验结果表明,该方式更为简洁高效、复用性更强,优 雅地实现了对产品类型可变、参数可变、异类组合的支持。该实现方式及代码实用性较强,可以在软件项目中实际使用。
关键词: C++11;lambda;function;泛型;抽象工厂
中图分类号: TP311.1    文献标识码: A
Improvement of the Generic Abstract Factory Design through the Lambda Expression and the std::function Class Template
MIN Jun, LUO Hong
( Library of Yibin University, Yibin 644000, China)
Abstract: The abstract factory pattern has been widely used in software design,but there are still some shortcomings in the traditional implementation of the abstract factory design pattern.With the development of technology,the implementation of design patterns is constantly improving.After the release of new C++11 standards,many improvement have emerged. Based on these improvements,this paper further improves the generic abstract factory design by adopting the new technology of the C++11 lambda expression and the std::function class template,optimizing the data structure and the code structure. The implementation model of New Generic Abstract Factory is proposed.Experimental results show that this model is more concise and efficient with better reusability.This model can gracefully implement the support to variable product types,variable parameters,and heterogeneous combinations.With decent practicality,this implementation method and code can be actually applied in software projects.
Keywords: C++11;lambda;function;generic;abstract factory


版权所有:软件工程杂志社
地址:辽宁省沈阳市浑南区新秀街2号 邮政编码:110179
电话:0411-84767887 传真:0411-84835089 Email:semagazine@neusoft.edu.cn
备案号:辽ICP备17007376号-1
技术支持:北京勤云科技发展有限公司

用微信扫一扫

用微信扫一扫