Re: How to name variables in a program?



websnarf wrote:

> dbPop3MsgHdrGet is different. You immediately know that its an
> attribute read function of some kind (Get) its been defined in a module
> called db, or a submodule of db called pop3, and the thing we are
> reading is a "message header". So its an explicit encoding, that lets
> you know exactly what it is. In C++ it would probably look something
> like db::pop3::msg->getHdr() which is not drastically different.

But the latter has more room for improvement.

The "Law of Demeter" _roughly_ means "don't type too many dots [or colors or
arrows]" on one line.

So if we only pop pop3 message headers within their own module, and abstract
them from outside the module, we get this:

namespace db {
...
class pop3 {
...
msg->getHdr();
}
}

Now we need to type db and pop3 less often, so we can safely make them
longer. Similarily, the line with msg->getHdr() is now shorter, so we have
room to make it longer:

namespace eMailDatabase {
...
class PostOfficeProtocolThree {
...
pMessage->getHeader();
}
}

Put another way - the _need_ to cram so many abbreviations into a single
identifier is a design smell. It indicates poor encapsulation.

> The other advantage of my scheme is that when you ASCII sort the
> symbols, they make some sort of sense and look fairly organized
> anyways.

Uh, just to find a quibble here, I could point out one should manually sort
ones files, then document in the native order. Stuff should look fairly
organized anyway...

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand


.



Relevant Pages

  • Re: Mail Boxes
    ... If this is POP3 from multiple ISPS, ... > get some sort of email forwarding in place at the ISP end? ...
    (microsoft.public.windows.server.sbs)
  • Re: Exchange wont send/receive
    ... I'm not sure which updates, is there a log that keeps track that I ... SMTP is working and we don't use POP3. ... The only problem is exchange not being able to sort out ...
    (microsoft.public.windows.server.sbs)
  • Re: Stupidly long reply-to field
    ... message header and notice the flags pushed off the side, ... Part of the problem is the layout you are using - Are you particularly ... Personally, I much prefer the Classic View, for this sort of reason. ...
    (Ubuntu)
  • Re: Stupidly long reply-to field
    ... Chris Jones wrote: ... message header and notice the flags pushed off the side, ... extensions that are invisible because of the same problem). ... Personally, I much prefer the Classic View, for this sort of reason. ...
    (Ubuntu)