I need to implement a set of 60 functions according to predefined signatures. They should be global functions, not some functions of class members. When I implement them, I use a set of well-executed classes provided by a third-party partner.
My implementation of most functions is rather short, about 5-10 lines and mainly concerns various accesses to these third-party classes. For some more complex functions, I created a couple of new classes that deal with all complex things, and I use them also in functions. All status information is stored in the static members of my and third-party classes, so I don’t need to create global variables.
Question: It would be better if I implemented one large class with 60 member functions and did it implement the whole implementation (that is, now in global functions)? And each of the functions that I need to write will simply call the corresponding member function in the class.
All status information is stored in the static members of my and third-party classes, so I don’t need to create global variables.
This is the key point. No, they certainly should not be introduced into classes. Classes are designed to create objects. In your situation, you would use them as an area for data and functions. But this is what namespaces already solve better:
namespace stuff { ... 60 functions ... namespace baz { ... if you want, you can have nested namespaces, to ... ... categorize the functions ... } namespace data { ... you can put data into an extra namespace if you want ... } }
, , - .
?
, .
, , , .
litb, , . , class , - . , , - - .
class
using namespace stuff;! , :
using namespace stuff;
#include <stuff.h> void some_function() { stuff::function_wrapper(); }
:
#include <stuff.h> using namespace stuff; void some_function() { function_wrapper(); }
, - namespace , static, .
namespace
static
, " " . 60 , , , . OO API, .
Source: https://habr.com/ru/post/1702360/More articles:Why is my Access database not updating when I read it from another process? - ms-accessWatin в TFS 2008? - .netВключить потоковое вещание в Biztalk WCF-адаптере - wcfВсегда ли безопасно объединять файлы javascript из разных источников и загружать их как один? - javascriptFinding free space on stage - algorithmСлужбы отчетов: группировка строк с цветом - formattingAlign a at the top and one at the bottom of the table - htmlЭффективность, бенчмаркинг, тестирование скорости, производительность - performanceRegex Extension Search - regexWebService and Survey - c #All Articles