All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
All things are lawful, but not all things are profitable.
Al Davis wrote:I looked at the Java tutorials info (I've seen it before) and am frustrated because it has 5 or so screens of info about -how- to write and implement an interface, but very little about -why- to do so. Maybe I'm overthinking the problem, but I'm not impressed with simply being able to reuse a defined method, especially since you have to overwrite it in code, anyway. It's good to be able to access objects which implement the Interface across class boundaries, but is that all there is? Is that an interface's primary (or sole) purpose? I keep waiting for a light to go off in my head about some "gee whiz" aspect of Interfaces, but it ain't happening and I'm getting frustrated.
Every good tree bears good fruit
Al Davis wrote:But I want to return to a question I asked a few posts ago - "It's good to be able to access objects which implement the Interface across class boundaries, but is that all there is? Is that an interface's primary (or sole) purpose?"
But I'm still not sure why using Stageable as a Type is necessary.
All things are lawful, but not all things are profitable.
Knute Snortum wrote:
But I'm still not sure why using Stageable as a Type is necessary.
Think of it this way: I have a List called controllers, containing all different classes. I want to get the first one and call its setStage() method. So I start typing...
But wait, what is xxx? Let's say that the first class in the List is Controller1. I could write
But that's not going to work for indices 1, 2, etc. So I make an interface Stageable and implement it in all the controllers. Now I can write:
Al Davis wrote:I'm somewhat new to Java - been doing the Univ of Helsinki on-line course for a couple of months - and I am totally baffled about how to design classes/architect a multi-class program.
I have a pretty good handle on the "rules" of how to implement interfaces, abstract classes, super & sub-classes, etc, but I am completely clueless as to the thought processes/design considerations that go into deciding how to put together evan a relatively simple program.
...
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
S Fox wrote:Controller1 controller = controllers.get(0); // its only index 0
Stageable controller = controllers.get(0); // also only index 0
How does this work??? I don't get it.
All things are lawful, but not all things are profitable.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |