| 08-02-2007, 06:38 PM | #1 |
I have a question. What exactly does an 'interface' do, and why should I use it. I'm working on a small projectile system and I wondering wether I should use interfaces. Sample Code: JASS:struct DemoStruct real x real y real z //other variables unit DummyProj method SetNewXYZ takes nothing returns nothing //method code endmethod method MoveToNewXYZ takes nothing returns nothing //method code endmethod endstruct |
| 08-02-2007, 07:04 PM | #2 |
I'll lend you the golden rule: if you can't think of an use for something, don't use it. Regarding your question, I am not sure what exactly you want to do, so I can't answer. Interfaces are good for custom event handling, that's what I know. |
| 08-02-2007, 07:06 PM | #3 |
Ok, then I probably have no use for them. |
| 08-02-2007, 08:10 PM | #4 |
interface is like widget i think. Widget also accept unit or item... Interface accept the structs that extends it |
| 08-03-2007, 12:10 AM | #5 |
Aren't function interfaces like function variables? Or am I completely off? |
| 08-03-2007, 12:39 AM | #6 | |
Quote:
|
| 08-03-2007, 03:52 AM | #7 | |
Quote:
Interfaces here, not function interfaces... An interface is a definition of a "type" of struct When used properly, the "is a" logic should apply. If you have an interface named shape and a struct named circle that extends shape... circle is a shape. |
| 08-03-2007, 04:04 AM | #8 |
hmm I wonder if there is a way to implement "has a" on Jass |
| 08-03-2007, 04:50 AM | #9 |
has a? |
| 08-03-2007, 07:21 AM | #10 |
Oh, I didn't realize that Interfaces and Function Interfaces were different. They had similar names, and I don't use vJASS, so I guessed. |
| 08-03-2007, 02:29 PM | #11 |
"has a" is a type of inheritance. There's generally 3 (that I know of) "is a" --This is when on class "is a"nother class. In this case, we're talking about structs. Say you have multiple structs for different types of cars, and they all share similar variables, methods, etc. So, make a car class/struct, and then have each of your different types of car class/structs have some sort of way of declaring them of the car. I'm not sure how you'd do this in vjass is it's implemented anyways. "has a" --This is when one class/struct "has a"nother class/struct in it. Say you have a car class/struct, and you've got a motor class/struct that you'd use in multiple things, generators, cars, airplanes, whatever. There's one more and I just can't remember it. Take a look up on inheritance |
| 08-03-2007, 04:08 PM | #12 |
"has a" sounds promising but how will it work. All i think of atm is hierachy |
| 08-03-2007, 08:46 PM | #13 | |
Quote:
Before you start to get too object oriented and make some crazy feature again, think of this: How many people understands OOP enough to use them, half of the people cannot grasp structs, let alone interfaces. The funny thing is that even structs are not OOP right now, there is no inheritance, I guess that is why you named them structs and not classes. And I don't think they should be classes, wc3 is a trigger based system, it is not natively OO therefore even if you do make full-feature classes they would still have crippled use in a system like this. If you want to make something usefull make a for and while loops. I am sick of that goto-based loop jass stupidity. And for god's sake DON'T make a do-while loop. |
| 08-03-2007, 09:15 PM | #14 | |||
Quote:
I hate OO and that's the reason I did not implement it to the full extent but only the parts I think are convenient to me. Regardless, I really don't see how fully OOP would be broken in JASS, afaik it wouldn't there is already a preprocessor out there wich implements the useless and overcomplicating parts of OOP. Quote:
Quote:
|
| 08-04-2007, 06:49 AM | #15 | |
Quote:
I didn't say broken, what I meant to say is that it would have limited use. I am not underrating people, there is a great deal of mapmakers who are simply kids , it takes time to learn programming ... No formal syntax is useless, if that was the case people would still be using goto command instead of for and while. The advantage of those loops is that they have iteration logic separated from loop code thus reducing a chance of error not to mention much more readable code. |
