C++ でデータ アクセス オブジェクト パターンを実装したいと考えていますが、多重継承やブースト (クライアントが好まない) を使用しないことが望ましいです。
何か提案はありますか?
C++ でデータ アクセス オブジェクト パターンを実装したいと考えていますが、多重継承やブースト (クライアントが好まない) を使用しないことが望ましいです。
何か提案はありますか?
OTL (otl.sourceforge.net) is an excellent C++ database library. It's a single include file so doesn't have all the complexity associated (rightly or wrongly!) with Boost.
In terms of the DAO itself, you have many options. The simplest that hides the database implementation is just to use C++ style interfaces and implement the data access layer in a particular implementation.
class MyDAO { // Pure virtual functions to access the data itself } class MyDAOImpl : public MyDAO { // Implementations to get the data from the database }
データ アクセス オブジェクトのデザイン パターンを Google ですばやく検索すると、最初のページに少なくとも 10 個の有用な結果が返されます。これらの中で最も一般的なものは、Jeff Foster によって既に示されている抽象的なインターフェイス デザインです。これに追加したい唯一のものは、オブジェクトを作成するためのデータ アクセス オブジェクト ファクトリです。
適切なコードで見つけることができる例のほとんどは Java のものです。これは Java の一般的な設計パターンですが、それでも C++ に非常に関連しており、非常に簡単に使用できます。
これは良いリンクです。抽象ファクトリを非常によく説明しています。
私が好むデータアクセスの抽象化は、リポジトリパターンです。