Hi Hans,
as I see it, I am not interested into dashed stuff of a shape,
only thing I am interested in is what can I do with it...
so, I could paint my shape with a brush or draw a line,
up to me to decide and shouldn't be exposed by my interface..
for example:
interface Shape
{
void hide();
void show();
void draw();
void delete();
}
public class Square implements Shape, Jumpable
{
//implementation..
public void draw()
{
final Pen pen = new Pen(LineType.DASHED);
pen.drawLine(100,150);
//etc
}
//..more implementation...
// Jumpable implementation
public void jump()
{
// jumping code in here..
}
}
public class MyCoolShape implements Shape
{
//implementation..
public void draw()
{
final Brush brush = new Brush(new Color(0x003300));
brush.paint(10,10,30,-30);
//etc
}
//..more implementation...
}
public final class LineType
{
public static final int DASHED = 0;
public static final int MYTYPE = 1;
private LineType(){}// do not instantiate
}
but again, as I said, nobody forbids you to use it the way you do,
and it's pointless to have huge discussion about it...
see it as personal preference...
kind regards,
-m
-Original Message-
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Hans Wichman
Sent: Wednesday, July 05, 2006 8:14 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] AS3 - why no properties in interfaces?
Hi Marijan,
it might depend on what your constants are. For example imagine you had an
interface Shape, with a method setLineType. You could have setLineType
(type:String) (eg dashed), or setLineType (type:Number) (eg 0, 2 ,5).
With
public constants you could have the Shape interface declare vars as public
static var DASHED:Number = 0; and you could call setLineType (Shape.DASHED
);.
Out of the 3 alternatives i would prefer the last, and I do not think this
exposes inner details a lot.
As said I can imagine that when you declare an interface like:
interface MyGeneralInterface {
public static var mySpecificVar:MyVerySpecificClass;
}
that it is plain wrong, but otherwise in the linetype example? I don't
know,
I'd like to hear your thoughts on it.
greetz
Hans
On 7/3/06, Marijan Milicevic [EMAIL PROTECTED] wrote:
Hi Hans,
while I cannot say it's bad, it's difficult t say there's nothin nad
about
it.
to quote an javaworld article:
It turns out that using an interface to declare constants may not be the
best practice after all. In fact, using interfaces in this way may be
downright nasty. Why? Interfaces should only be used to define types; any
other use is an abuse. Using an interface causes internal details -- such
as
constants -- to leak into the class' public API. Once something becomes
part
of the public API, you can never get rid of it.
so, in above case it could be wrong..
-m
-Original Message-
From: [EMAIL PROTECTED] on behalf of Hans Wichman
Sent: Mon 7/3/2006 7:04 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] AS3 - why no properties in interfaces?
Although there is -nothing- bad about using interfaces as a container of
constants.
On 7/3/06, Marijan Milicevic [EMAIL PROTECTED] wrote:
Hi Sascha,
But it's still beyond me why property support wasn't added. It
can be such a complex thing but would make OO life a good
amount easier.
You are refering to Java but defined fields in java are implicitly
static finals and need to be initilized within interface,
so, you are not missing that much in AS3 anyway.
Also, bad habit of java programmers is to use interfaces as container
of
constants,
which, saves them some typing (although with static imports in
1.5version
it doesn't make any difference).
-m
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and