![]()
内容推荐 关于C语言编程的专家建议很难找。虽然面向对象编程语言的参考帮助有很多,但针对C语言的同类信息却少得令人吃惊。通过这本实践指南,初学者和有经验的C语言程序员都能找到相关的设计决策指导,包括在构建大型程序时如何将它们循序渐进地应用于现役代码。 作为设计模式社区的主要成员,Christopher Preschern解答了如何构造C程序、应对错误处理、设计柔性接口等问题。无论你是在寻找特定的模式,还是想了解特定主题的设计选择,本书都能助你一臂之力。在第一部分中,你将学习如何实现专门针对C编程语言的实用设计知识。 第二部分包括应用C编程模式实现大型程序。你将从中学习到模式是如何通过良好的设计决策提高工作效率的。本书包括以下模式: 错误处理 返回错误信息 内存管理 从C函数返回数据 数据生命周期和所有权 柔性API 柔性迭代器接口 在模块化程序中组织文件 摆脱#ifdel地狱 作者简介 克里斯托弗·普雷斯奇,Christopher Preschern组织了设计模式会议并发起了改进模式编写的倡议。作为ABB公司的C程序员,他收集并记录了如何编写工业级代码的实践知识。他曾在格拉茨科技大学讲授编码以及代码质量的相关课程,拥有计算机科学博士学位。 目录 Preface Part Ⅰ. C Patterns 1.ErrorHandling Running Example Function Split Guard Clause Samurai Principle Goto Error Handling Cleanup Record Object—Based Error Handling Summary Further Reading 0uflook 2.Returning Error Information Running Example Return Status Codes Return Relevant Errors Special Return Values Log Errors Summary Further Reading 0utlook 3.MemowManagement Data Storage and Problems with Dynamic Men Running Example Stack First Eternal Memory Lazy Cleanup Dedicated Ownership Allocation Wrapper Pointer Check Memory Pool Summary Further Reading 0utlook 4.ReturningDatafromC Functions Running Example Return V甜ue out.Parameters Aggregate Instance Immutable Instance Caller.Owned Buffer Callee灿locates Summary 0utlook 5.Data LifetimeandOwnership Stateless Software—Module Software.Module with Global State Caller.Owned Instance Shared Instance Summary Further Reading Outlook 6.FlexibleAPIs Header Files Handie Dynamic Interfaca Function Control Summary Further Reading 0utlook 7.Flexible Iterator Interfaces Running Example Index Access Cursor Iterator Callback Iterator Summary Further Reading Outlook 8.Organizing Files in Modular Programs Running Example Include Guard Software—Module Directories Global Include Directory Self-Contained Component APICopy Summary 0utlook 9.Escaping#ifdefHell Running Example AvoidVariants Isolated Primitives Atomic Primitives Abstraction Layer Split Variant Implementations Summary Further Reading 0utlook Part Ⅱ.Pattern Stories lO.Implementing Logging Functionality The Pattern Story File Organization Central Logging Function Logging Source Filter Conditional Logging Multiple Logging Destinations File Logging Cross—Platform Files Using the Logger Summary 11.Buildinga UserManagementSystem The Pattern Story Data Organization File Organization Authentication:Error Handling Authentication:Error Logging Adding Users:Error Handling Iterating Using the User Management System Summary 12.Conclusion What You've Learned Further Reading Closing Remarks lndex |