Проектирование С++ API в стиле Qt | Participants
|
- Statistics
- Participants
- Translate into Russian
- Translation result
- 99% translated in draft. Almost done, let's finish it!
If you do not want to register an account, you can sign in with OpenID.
Designing Qt-Style C++ APIs | ||
We have done substantial research at Trolltech into improving the Qt development experience. In this article, I want to share some of our findings and present the principles we've been using when designing Qt 4, and show you how to apply them to your code. | В компании Trolltech мы провели масштабное исследование с целью улучшения процесса разработки с использованием Qt. В этой я статье хочу поделиться некоторыми результатами, которые мы получили. А также рассказать о принципах, которыми мы руководствовались в процессе проектирования Qt 4, и показать сферы их применения. | |
Six Characteristics of Good APIs | ||
The Convenience Trap | ||
The Boolean Parameter Trap | ||
Static Polymorphism | ||
The Art of Naming | ||
Pointers or References? | ||
Case Study: QProgressBar | ||
How to Get APIs Right | ||
Designing application programmer interfaces, APIs, is hard. It is an art as difficult as designing programming languages. There are many different principles to choose from, many of which tend to contradict each other. | Проектирование интерфейсов программирования приложений (API) — непростая задача. Это искусство столь же сложное, как и проектирование языков программирования. Существует множество различных принципов выбора, многие из которых часто противоречат друг другу. | |
Computer science education today puts a lot of emphasis on algorithms and data structures, with less focus on the principles behind designing programming languages and frameworks. This leaves application programmers unprepared for an increasingly important task: the creation of reusable components. | Современное образование в сфере компьютерных наук делает упор на алгоритмы и структуры данных, уделяя меньше внимания принципам проектирования языков программирования и фреймворков. Из-за этого новоиспеченные прикладные программисты не готовы к такой важной задаче, как создание повторно используемых компонентов. | |
Before the rise of object-oriented languages, reusable generic code was mostly written by library vendors rather than by application developers. In the Qt world, this situation has changed significantly. Programming with Qt is writing new components all the time. A typical Qt application has at least some customized components that are reused throughout the application. Often the same components are deployed as part of other applications. KDE, the K Desktop Environment, goes even further and extends Qt with many add-on libraries that implement hundreds of additional classes. | Прежде чем объектно-ориентированные языки стали такими популярными, повторно используемый код писали в основном разработчики библиотек, а не прикладные разработчики. В мире Qt ситуация в корне изменилась. Программирование на Qt означает постоянное написание новых компонентов. Типичное Qt-приложение имеет хотя бы несколько настраиваемых компонентов, которые используются в различных местах приложения. Часто те же компоненты становятся частью других приложений. В KDE (K Desktop Environment) пошли еще дальше — Qt расширяется множеством add-on библиотек и реализует сотни дополнительных классов. | |
But what constitutes a good, efficient C++ API? What is good or bad depends on many factors -- for example, the task at hand and the specific target group. A good API has a number of features, some of which are generally desirable, and some of which are more specific to certain problem domains. | Но что представляет из себя хороший C++ API? Что хорошо, а что плохо, зависит от многих факторов, например, от поставленной задачи и конкретной целевой группы. Хороший API имеет ряд возможностей, некоторые из которых используются большую часть времени, а некоторые являются более специфическими для определенных проблемных областей. | |
Six Characteristics of Good APIs | ||
An API is to the programmer what a GUI is to the end-user. The 'P' in API stands for "Programmer", not "Program", to highlight the fact that APIs are used by programmers, who are humans. | API для программиста это то же самое, что GUI для пользователя. Буква «P» в «API» значит «программист», а не «программа». Она подчеркивает тот факт, что API используются программистами, то есть людьми. |
© Trolltech.
