api design for c+ + [electronic resource]

444 460 0
api design for c+ + [electronic resource]

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... * personList + AddPerson() : boolean + DeletePerson() : boolean + UpdatePerson() : boolean + address1 : string + address2 : string + city : string + state : string + zipcode : string + addressType : string 0 * + firstName : string + middleName : string + lastName : string + id : UUID telephoneList 0 * Telephone Number + number : string + numberType : string + IsValid() : boolean + GetFormattedString()... topic and is, of course, the specific focus of this book I therefore begin by describing various styles of C and C ++ APIs that you could adopt in your projects, such as flat C APIs, object-oriented APIs, template-based APIs, and data-driven APIs Chapter 6: C ++ Usage Next I discuss various C ++ language features that can impact good API design This includes numerous important issues such as good constructor... is an example of plain C API rather than a C ++ API While you can use a C API directly from a C ++ program, a good example of a specific C ++ API is the Standard Template Library (STL) The STL contains a set of container classes, iterators for navigating over the elements in those containers, and various algorithms that act on those containers (Josuttis, 1999) For instance, the collection of algorithms... refine this design in a moment, but for the moment it serves as an initial logical abstraction of the problem domain Person Address Book personList + AddPerson() : boolean + DeletePerson() : boolean FIGURE 2.1 High-level UML abstraction of an address book API 0 * + firstName : string + middleName : string + lastName : string + address1 : string + address2 : string + city : string + state : string + zipcode... chapter concentrates on generic, language-neutral qualities of an API, such as information hiding, consistency, and loose coupling It provides a C ++ context for each of these concepts, but overall the advice in this chapter should be useful to you whether you are working on a C ++ , Java, C#, or Python project Later chapters deal with C ++ -specific issues, such as const correctness, namespaces, and constructor... book For example, while I mention use of the Pimpl idiom as a solution for hiding internal details in C ++ , I dedicate more space to this important topic in the following chapter on design patterns 2.1 MODEL THE PROBLEM DOMAIN An API is written to solve a particular problem or perform a specific task So, first and foremost, the API should provide a coherent solution for that problem and should be formulated... dynamic library Chapter 7: Performance In this chapter I analyze performance issues in APIs and show you how to build highperforming APIs in C ++ This involves the use of const references, forward declarations, data member clustering, and inlining I also present various tools that can help you assess the performance of your code Chapter 8: Versioning With the foundations of API design in hand, I start to... scripting access to your API so that power users of your application can write scripts to perform custom actions I therefore talk about how to create script bindings for a C ++ API so that it can be called from languages such as Python and Ruby Chapter 12: Extensibility Another advanced topic is that of user extensibility: creating an API that allows programmers to write custom C ++ plugins that extend... the API that you found doesn’t work on the platforms that you must support or perhaps it doesn’t match the performance criteria that you have specified for your application Lack of source code While there are many open source APIs, sometimes the best API for your case may be a closed source offering That is, only the header files for the interface are made available to you, but the underlying C ++ source... built on top of many APIs, where some of these can also depend on further APIs This is illustrated in Figure 1.1, which shows an example application that depends directly on the API for three libraries (1 3), where two of those APIs depend on the API for a further two libraries (4 and 5) For instance, an image viewing application may use an API for loading GIF images, and that API may itself be built . therefore focused on the issues of designing APIs for a single language (C ++ ) rather than diluting the content to make it applicable for all languages. While readers who wish to develop APIs for. API is an example of plain C API rather than a C ++ API. While you can use a C API directly from a C ++ program, a good example of a specific C ++ API is the Standard Template Library (STL). The. currently on the market concentrate on the topic of API design for C ++ . It’s worth noting that this book is not meant to be a general C ++ programming guide there are already many good examples

Ngày đăng: 31/05/2014, 00:24

Từ khóa liên quan

Mục lục

  • Team rebOOk

Tài liệu cùng người dùng

Tài liệu liên quan