Define Interface Simplicity vs Implementation Simplicity

In Richard Gabriel’s The Rise of “Worse is Better”, he talks about the simplicity of interface vs the simplicity of implementation in a design.

I’ve never been able to quite grasp what he means and searching the web for the answer has only yielded information about Java’s interfaces (the structure of classes, etc) vs the code in Java’s methods and classes.

What does he mean by interface and implementation and what does simplicity mean for each of them?

What does he mean by interface and implementation and what does simplicity mean for each of them?

Don’t think too much about it, it’s just English.

He means your code’s interface (not necessarily interfaces!) – how people work with your code. And your code’s implementation – how your code actually does the things it needs to do. And simple is simple – is your stuff easy to work with.

Simplicity in interface means it’s easy to use your stuff. Do your functions have good names with obvious parameters and few side effects? Do they do what your users need? Do your classes have good names with obvious functionality? Do they do what your users need? Without too much trouble?

Simplicity in implementation means it’s easy for programmers (or you) to work with your stuff. Can you modify the code easily? Can you test it easily? Can you understand it? Debug it?

While simple implementation often yields simple interface, it’s not always the case. Some of the best designs isolate bits of necessarily complex implementation behind a simple interface. Likewise, if the easiest implementation isn’t what your users need, you can end up with a complex interface.

1

The page seems to be using those terms literally, without reference to any particular programming construct, so there isn’t really anything to define. Instead I’ll try giving an example.

Say you have a class that gets things from the internet. Here’s a simple interface version:

class Internet {
    int sendRequest(const std::string& url, std::string& response);
}

Internet::sendRequest(const std::string& url, std::string& response) {
    // parse the url into its various tokens
    m_protocol = /* first token, or https if not provided */
    m_domain = /* second token */
    while(...) { m_parameters.push_back(/* another token */); }
    ...
    switch(m_protocol) {
        case HTTPS: HTTPSImpl.request(m_domain, ...); break;
        ...
    }
}

Here’s a simple implementation version:

class Internet {
    int setProtocol(Internet::Protocol protocol);
    int setDomain(const std::string& domain);
    int addParameter(...);
    ...
    int sendRequest(std::string& response);
}

Internet::request(std::string& response) {
    switch(protocol) {
        case HTTPS: HTTPSImpl.request(m_domain, ...); break;
        ...
    }
}

Essentially it’s a trade-off between making the implementer deal with the complexity versus the interface user. Most of the time you’ll be (rightfully) told that hiding complexity from the user is a good thing, but Richard Gabriel’s page argues that that might not always be the case.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Define Interface Simplicity vs Implementation Simplicity

In Richard Gabriel’s The Rise of “Worse is Better”, he talks about the simplicity of interface vs the simplicity of implementation in a design.

I’ve never been able to quite grasp what he means and searching the web for the answer has only yielded information about Java’s interfaces (the structure of classes, etc) vs the code in Java’s methods and classes.

What does he mean by interface and implementation and what does simplicity mean for each of them?

What does he mean by interface and implementation and what does simplicity mean for each of them?

Don’t think too much about it, it’s just English.

He means your code’s interface (not necessarily interfaces!) – how people work with your code. And your code’s implementation – how your code actually does the things it needs to do. And simple is simple – is your stuff easy to work with.

Simplicity in interface means it’s easy to use your stuff. Do your functions have good names with obvious parameters and few side effects? Do they do what your users need? Do your classes have good names with obvious functionality? Do they do what your users need? Without too much trouble?

Simplicity in implementation means it’s easy for programmers (or you) to work with your stuff. Can you modify the code easily? Can you test it easily? Can you understand it? Debug it?

While simple implementation often yields simple interface, it’s not always the case. Some of the best designs isolate bits of necessarily complex implementation behind a simple interface. Likewise, if the easiest implementation isn’t what your users need, you can end up with a complex interface.

1

The page seems to be using those terms literally, without reference to any particular programming construct, so there isn’t really anything to define. Instead I’ll try giving an example.

Say you have a class that gets things from the internet. Here’s a simple interface version:

class Internet {
    int sendRequest(const std::string& url, std::string& response);
}

Internet::sendRequest(const std::string& url, std::string& response) {
    // parse the url into its various tokens
    m_protocol = /* first token, or https if not provided */
    m_domain = /* second token */
    while(...) { m_parameters.push_back(/* another token */); }
    ...
    switch(m_protocol) {
        case HTTPS: HTTPSImpl.request(m_domain, ...); break;
        ...
    }
}

Here’s a simple implementation version:

class Internet {
    int setProtocol(Internet::Protocol protocol);
    int setDomain(const std::string& domain);
    int addParameter(...);
    ...
    int sendRequest(std::string& response);
}

Internet::request(std::string& response) {
    switch(protocol) {
        case HTTPS: HTTPSImpl.request(m_domain, ...); break;
        ...
    }
}

Essentially it’s a trade-off between making the implementer deal with the complexity versus the interface user. Most of the time you’ll be (rightfully) told that hiding complexity from the user is a good thing, but Richard Gabriel’s page argues that that might not always be the case.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật