0
AndroMDAは「カートリッジ」という用語を使用しています(例えば、すぐに使えるNHibernateサポート用)。 私はそれを理解しているので、API /コンポーネントを取り込み、それをラップし、新しい機能を追加することはなく、単純化し、多くの場合完全に機能するようにします。「カートリッジ」パターンは存在しますか?
私の質問:
が広く使われている用語ですか?
適切に定義できますか?
クラス/メソッド名に接尾辞 "Cartridge"を使用する必要がありますか?
例:次のBase64ヘルパーはBase64変換用のカートリッジですか? あなたは、パフォーマンス・チューニングのためのすべての電源を離れて与えるが、あなたは、単にシンプルな(かつ小)文字列をデコードしたい場合は、それが正常に動作します:
使用法:
Base64StringCartridge.Decode(input);
実装
public static string Decode(string data)
{
try
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = System.Convert.FromBase64String(data);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
catch
{
return "";
}
}