Discussion:
[leveldb] leveldb log_reader.h/Reader class design consideration
陈宗志
2016-12-26 18:16:28 UTC
Permalink
I find class Reader design this way. we have a class name Reader, then we
provide an interface class Reporter


class Reader {...class Reporter {
public:
virtual ~Reporter();

// Some corruption was detected. "size" is the approximate number
// of bytes dropped due to the corruption.
virtual void Corruption(size_t bytes, const Status& status) = 0;};};

why should we design this way? In my intuition I will provide a pure
virtual function Corruption in class Reader?


class Reader {
virtual void Corruption(size_t bytes, const Status& status) = 0;};

Then if I want to use class Reader, I will inheritance from class Reader,
and provide my own implementation of Corruption.

I think the difference here is that, if we do the way leveldb db, the user
only need to know how to implement the Reporter interface. But in my
inheritance from class Reader, the user need to know the whole class
Reader.

So the leveldb way provide more encapsulation.

Is this the right consideration in leveldb's design
--
You received this message because you are subscribed to the Google Groups "leveldb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leveldb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...