I'm not sure if you mean within
Often I've ended up with a library where a few classes are interlinked,
but only accessible through a single class which is public or internal.
Without either putting it in a completely separate assembly, or making
them all nested classes you can't make those classes invisible. I just
think it's a bit of a shame.
Ahh, I can see what you mean there. Not sure if per-namespace is nessecerily
the best way, but I do agree that there is a problem there.
Is there a way to do this in java?
Not sure what the end of the sentence was going to be here, but the
problem is that popular opinion is pretty ignorant when it comes to
threading. Harsh but true. Books and articles still regularly recommend
locking on "this" or typeof(TheClass). Maybe over the course of years
popular opinion will come round - I'm not going to hold my breath
though.
That was supposed to be something like:
"However, the pattern can certainly be emulated by any individual who cares
enough."
Not sure how I managed to miss that.
But yes, there is the book issue. I spend quite a bit of time in code
reviews fixing that point, its rather scary how often I see lock(this).
I can see why it does in a theoretical way, and I've seen others
getting confused by it, but it's never been a problem for me
I've had no particular problem with it. Its just like C and java. Still,
didn't care for the design there either.
personally. I assume your problem with it is that it does three (or
more?) separate things? (Unboxing, type conversion, and plain casting.)
Yes, although I can deal with boxing\unboxing being combined with casting.
The MC++ boxing keywords just didn't work that well and would be troublesome
to remember.
However, there are other issues. One is that its syntactically inconsistent,
there is absolutly no other construct in the language that is structured in
the same way. Statements use the same pattern, operators use the same basic
patterns, casting uses two different patterns, one which is just weird in
general(standard casting, (T)obj), and the other one is different from
standard casting(as, obviously).
The other issue is that the construct offers no flexibility. Constructs like
as could have been added in a more consistent way if casting was designed
more like modern C++ casting. There are some future enhancements I'd like to
see, atleast in a specialized dialect, for example guarenteed safe casts
placed for documentation and enforcement purposes. This would be a cast
which is required to be compile-time verified(the type is a base class of
the variable type or implements the variable type interface). These would
exist to both enforce that the assigned object must work at compile time,
and would allow the code to have cleaner self documentation.
Other casts could be used to potentially solve other problems, though I
havn't really thought about any off hand.