Помимо вышеперечисленных пунктов, существует также концептуальная разбивка Smalltalk против Simula.
Концептуально «Smalltalk-style» обычно указывает, что метод, запускаемый при вызове сообщения, определяется во время выполнения, помогая полиморфизму.
С другой стороны, «стиль Симулы», как правило, указывает на то, что все вызовы методов на самом деле являются просто удобным способом записи перегруженных вызовов функций - без полиморфизма во время выполнения. (Пожалуйста, исправьте меня, если я ошибаюсь.)
В середине у нас есть Java: все методы виртуальные по умолчанию, но статически типизированы и имеют диспетчеризацию типа во время компиляции.
Пример:
// C++
class Base {
void doSomething() {
cout << "Base::doSomething() called!\n";
}
}
class Derived : Base {
void doSomething() {
cout << "Derived::doSomething() called!\n";
}
}
int main() {
Base* b = new Base();
Derived* d = new Derived();
b->doSomething(); // prints "Base::doSomething() called!"
d->doSomething(); // prints "Derived::doSomething() called!"
Base* d2 = d; // OK; Liskov substitution principle.
d2->doSomething(); // prints "Base::doSomething called!" (!)
delete b;
delete d;
return 0;
}
VS:
// Objective-C
//Base.h
@interface Base
{
}
-(void)doSomething
@end
//Base.m
#import "Base.h"
@implementation Base
-(void) doSomething {
printf("doSomething sent to Base!");
}
@end
//Derived.h
#import "Base.h"
#import "Base.m"
@interface Derived : Base
{
}
@end
//Derived.m
#import "Derived.h"
@implementation Derived
-(void) doSomething {
printf("doSomething sent to Derived!")
}
@end
//Main.m
#import "Base.h"
#import "Base.m"
#import "Derived.h"
#import "Derived.m"
int main() {
Base* b = [[Base alloc] init];
Derived* d = [[Derived alloc] init];
[b doSomething]; // prints "doSomething sent to Base!"
[d doSomething]; // prints "doSomething sent to Derived!"
Base* d2 = d;
[d2 doSomething]; // prints "doSomething sent to Derived!"
[b release];
[d release];
return 0;
}
Я думаю, что вы на правильном пути. Вы должны просто уметь делать что-то вроде:
ICryptoTransform encryptor = ...
Stream encStream = new CryptoStream(outputFileStream, encryptor, CryptoStreamMode.Write);
Serializer.Serialize(encStream, obj);
encStream.FlushFinalBlock()
encStream.Close();
ICryptoTransform decryptor = ...
Stream decStream = new CryptoStream(inputputFileStream, decryptor, CryptoStreamMode.Read);
Serializer.Deserialize<Type>(decStream);
decStream.FlushFinalBlock()
decStream.Close();
По основам инфраструктуры шифрования .NET (включая то, как получить объекты ICryptoTransform, см. Другие вопросы, например Как лучше всего зашифровать короткие строки?
Another option is to actually encrypt the entire folder where the data is stored by installing a system-wide file system filter. The advantages here are that:
Of course the disadvantage (for those who don't write C anyway) is that you can't write it in C#.