Glenn, since there is virtually no globals I have a sub that is the full monty way of adding an ent. Otherwise I was finding C# was way more verbose than vba. With as BlockTableRecord btr here and a BlockTableRecord btr there etc.
Well, if I may say so myself, I've found that trying to invent
your own API that offers the 'full monty' way of doing things,
will ultimately create more problems than it solves.
API design is an art, and is not as simple as it often seems.
The problem with your approach to a 'full monty' way of
adding an ent to a block, is that if the code is used in a
context where the name of the block is coming from user
input, and the user intended to give the name of an
existing block, but mistyped it, your code just creates the
block and doesn't return an error.
The point here is that you really can't avoid the 'verbose'
nature of ObjectARX programming, and this is an excellent
example of why.
If the code that calls that sub doesn't do what it should to
check to see if a block exists (e.g., the verbose code that
your full monty sub is supposed to avoid) when it knows or
can assume that the block should exist, and rather, blindly
passes the name of the block to your full monty sub, you
will quickly find your code riddled with hard to find bugs.
You also haven't learned about the problem with the default
indexer and the Has() method yet (they return erased entries),
and that means that to find out if a block exists, you must
test the IsErased property of the object id returned by the
default indexer, and if it is erased, you must iterate over the
entire table to find another non-erased entry with the same
name.
So, while your sub may seem seem like a great convenience
at its conception, I think after using it for real, you will quickly
learn that it has the potential to be more of a problem than a
solution. I'm not trying to knock it down for the sake of doing
that, I'm trying to show why someone that is just learniing to
use an API is not yet able to see every potential problem in
their code until the one using it is unceremoneously confronted
with an exception dialog,
It's better bite the bullet and contend with the verbose nature
of the API, and focus on learning to use it, rather than trying
to come up with ways of hiding or insulating yourself from it,
as this sub appears to be a case of.
It's hard to learn an API if you're trying to hide from it