java - What is the rationale for using per-method/field access specification? -
in c++ access specifier field or method based on location under first declared access specification:
public: int my_public_variable; private: void secretprivateoperations(); int internal_counter;
what design rationale behind java specifying access prepending access specifier each method/field?
public int my_public_variable; private void secretprivateoperations(); private int internal_counter;
compare:
public: t a(); t b(); ... t z();
versus
public: t a() { <lots of code> } t b() { <lots of code> } protected: t c() { <more code> } public: t d() { <more code> }
if "factor out" access specifiers this, things can pretty nasty pretty quickly. yes, indentation helps. yes, have ctrl-f. there still can lot of noise through (multi-thousand line files, example), , having take mind off of task kind of thing wouldn't productivity.
java , c++ java deal in different ways. java keeps access specifiers local, knowing method you're working on enough determine scope. c++ stuffs declarations access specifier can "factored out". may not nice when implementing methods, it's more concise in header files, , possibly easier grok too.
Comments
Post a Comment