Hendra Kurniawan wrote:I want extension1 to have Creator<Integer, interfaceB> and extension2 to have Creator<Double, interfaceC>. See the pattern? Creator<var1, var2> where var1 is the type of immediate parent and var 2 is the interface implemented by said class. Is there any way to do this? can anybody tell the code of ObjectCreator.createCreator()?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Hendra Kurniawan wrote:okay, perhaps it's called factory, don't really know because I'm not familiar with java pattern and just don't have the time to do it.
Maybe that's why my naming convention seems unorthodox. I want to create Creator<J, J1> where J1 is consistent with the name of interface implemented by the calling object. like in the example, extension2 extend base<Double> and implement interface C, therefore Creator object for exetension2 will be Creator<Double, interfaceC>.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Hendra Kurniawan wrote:I don't really know how what I want to do is relevant to the solving of my question, but okay, since you're very adamant to know what I want to achieve :
I'm trying to somehow through extension, reduce the amount of code. The Creator object, I want to make it accessible to base's children. but not only that, I want to also preserve the types as you may have seen, I want to preserve the interface implemented and the type of base used for the children. and if you're wondering why the interface is included too? I just want to cover all the bases. Who might know one day I will need to preserve the interfaces too. So bottom line, I want to write less code.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Hendra Kurniawan wrote:I don't really know how what I want to do is relevant to the solving of my question, but okay, since you're very adamant to know what I want to achieve :
I'm trying to somehow through extension, reduce the amount of code. The Creator object, I want to make it accessible to base's children. but not only that, I want to also preserve the types as you may have seen, I want to preserve the interface implemented and the type of base used for the children. and if you're wondering why the interface is included too? I just want to cover all the bases. Who might know one day I will need to preserve the interfaces too. So bottom line, I want to write less code.
Winston Gutkowski wrote:
Hendra Kurniawan wrote:I don't really know how what I want to do is relevant to the solving of my question, but okay, since you're very adamant to know what I want to achieve :
I'm trying to somehow through extension, reduce the amount of code. The Creator object, I want to make it accessible to base's children. but not only that, I want to also preserve the types as you may have seen, I want to preserve the interface implemented and the type of base used for the children. and if you're wondering why the interface is included too? I just want to cover all the bases. Who might know one day I will need to preserve the interfaces too. So bottom line, I want to write less code.
So basically I was right in my first post: You want to simply create "an Object" on the fly, without knowing what its type is going to be beforehand.
Hendra Kurniawan wrote:I don't really know how what I want to do is relevant to the solving of my question, but okay, since you're very adamant to know what I want to achieve...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Hendra Kurniawan wrote:I don't really know how what I want to do is relevant to the solving of my question
I'm trying to somehow through extension, reduce the amount of code... I just want to cover all the bases. Who might know one day I will need to preserve the interfaces too. So bottom line, I want to write less code.
Junilu Lacar wrote:
I'm trying to somehow through extension, reduce the amount of code... I just want to cover all the bases. Who might know one day I will need to preserve the interfaces too. So bottom line, I want to write less code.
And what if some day, long after you expended all this effort now, you suddenly realize that you never really needed all this flexibility after all? In the real world, do you buy a bus because you might someday need to take fifty of your friends to the beach? What about a hundred friends? Oh no, now you need two buses! Wait, what about when you get married? You'll need to transport the whole town! Better get going on that fleet of buses. It's just silly, right? Well, it seems to me like you're looking to actually build a bus right now with all this stuff that you're trying to do.
Sometimes, to reduce the amount of code, you just need to code for the here and now. KISS - keep it simple, silly. Think about those other bridges when you get to them, if you ever even get to them.
Or as "Uncle Bob" likes to say: too much flexibility is TECHNICAL DEBT.
Henry Wong wrote:Regardless, the straw that broke the camel's back was the question "how many times have this been needed"? The answer was none. So, the programmer created tons of code (build a framework actually) on hundreds of classes, for something that was never used. At best, it was arguably not an efficient way for doing it (and unproven that it will work). At worst, it was a non-issue, and the effort was a complete waste of time.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Don't get me started about those stupid light bulbs. |