Even *if* this works
the boost in performance would be so incredibly marginal that you would never notice any difference.
You're performing premature nano optimizations, which half of the time won't work out as you hoped.
after the compiler has performed type checking
In C++, the classic cast "(Shape)" does not perform RTTI. It simply tells the compiler to treat the object as the new type. In Java, which does perform the type check, this cast is often called a "type-safe downcast."
Tudor Raneti wrote:
This way, I handle the casts myself (there's no compile time casts occuring in Java AFAIK though compile time checks are made), but being specific should yield a slight performance boost if JIT cooperates?
Tudor Raneti wrote:
If there was an improvement though, take that marginal boost in ms and multiply it by 1000,
Tudor Raneti wrote:In short, this only allows me to write like in the example above. RTTI happens anyway and thus no improvement in performance exists. Extending a common class instead of casting doesn't change the overall logic because I'm using the objects for something else not telling them to do something, so there's no difference but in style
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tudor Raneti wrote:RTTI ... HQL ... ISP ... JIT
Dennis Deems wrote:
Tudor Raneti wrote:RTTI ... HQL ... ISP ... JIT
Please spell out words instead of using abbreviations like this. There may be readers of the forum who are not familiar with them.
Tudor Raneti wrote:If I was using inheritance w/o interfaces in this, and there would be many attributes such as Dated but that wouldn't be always common among all the beans that share one main attribute in my application...
...then I would have lots of redundant functionality around...
...and I would have to use reflection or annotations to ascertain which bean has something and which does not when fetching data in a generic way from all of them...
...nor do I see how it's more or less brittle since whenever I add a new functionality I still have to extend the logic below...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Tudor Raneti wrote:
Dennis Deems wrote:
Tudor Raneti wrote:RTTI ... HQL ... ISP ... JIT
Please spell out words instead of using abbreviations like this. There may be readers of the forum who are not familiar with them.
RTTI
http://en.wikipedia.org/wiki/Run-time_type_information
HQL
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.htm
OCP
http://en.wikipedia.org/wiki/Open/closed_principle
ISP
http://en.wikipedia.org/wiki/Interface_segregation_principle
JIT
http://en.wikipedia.org/wiki/Just-in-time_compilation
Dennis Deems wrote:
Tudor Raneti wrote:
Dennis Deems wrote:
Tudor Raneti wrote:RTTI ... HQL ... ISP ... JIT
Please spell out words instead of using abbreviations like this. There may be readers of the forum who are not familiar with them.
RTTI
http://en.wikipedia.org/wiki/Run-time_type_information
HQL
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.htm
OCP
http://en.wikipedia.org/wiki/Open/closed_principle
ISP
http://en.wikipedia.org/wiki/Interface_segregation_principle
JIT
http://en.wikipedia.org/wiki/Just-in-time_compilation
I'm not asking for links. I know how to use teh interWebs. I'm asking you to express yourself like a human being communicating with other human beings.
Jeff Verdegan wrote:I consider myself to be of an average level of knowledge...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Jeff Verdegan wrote:I consider myself to be of an average level of knowledge...
Fishing for compliments, Obi-wan?
Winston
Winston Gutkowski wrote:
Jeff Verdegan wrote:I consider myself to be of an average level of knowledge...
Fishing for compliments, Obi-wan?
Jeff Verdegan wrote:
Tudor Raneti wrote:
This way, I handle the casts myself (there's no compile time casts occuring in Java AFAIK though compile time checks are made), but being specific should yield a slight performance boost if JIT cooperates?
How do you figure?
Tudor Raneti wrote:It's hypothetical. What I read around said that RTTI always runs in Java, even when you cast (I even remember I read somewhere RTTI can be turned off...
I was refering to the C++ and C# capability to cast and use the supertype functionality.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Anytime you find yourself writing code of the form "if the object is of type T1, then do something, but if it's of type T2, then do something else," slap yourself.
Tudor Raneti wrote:I don't see how a copy constructor would work in this case.
So I'm wondering if I should slap myself because Scott Meyers sais so in Effective C++:
Anytime you find yourself writing code of the form "if the object is of type T1, then do something, but if it's of type T2, then do something else," slap yourself.
Anyway... polymorphism means overhead, and if I generalize, it automatically means more overhead...
Surely generalizing means abstracting the business rules, making the code less readable IMO. Designing with interfaces looks clear to me since that's what interfaces do, declare a behavioral contract on an object.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|