incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avinash Narayanan <avinasha...@gmail.com>
Subject Re: AS3 Enhancements: method overloading. Why do people want this?
Date Mon, 16 Jan 2012 15:06:05 GMT
@Nicholas it might not be the best way forward(and at the risk of sounding
stupid), but what prevents someone from sending them as an :Object? with a
key value pair? key being maybe the type of data?

Thanks
Avinash Y


On Mon, Jan 16, 2012 at 8:32 PM, Nicholas Kwiatkowski <nicholas@spoon.as>wrote:

> While I'm no prueist OOP chest-beater, I would love to see method
> overloading.  I deal a lot with back-end communication systems, and one
> thing I hate doing over, and over, and over again are methods like :
>
> public function sendAsString(stringToSend:String):bool
> public function sendAsBool(boolToSend:Boolean):bool
> public function sendAsArray(arrayToSend:Array):bool
> public function sendAsInt(intToSend:int):bool
> ...
> ...
>
>
> All of the code within those functions is EXACTALLY the same.  This also
> means that the API is much easier, and allows the constitution between the
> component and the base-application to be much easier to implement and
> easier to understand.  It also helps with a lot of our "convert it to a
> generic and convert it back later" that we have to deal with over and over
> again in the SDK.
>
> We should be able to do the following :
>
> public function send(itemToSend:String):bool
> public function send(itemToSend:Boolean):bool
> public function send(itemToSend:Array):bool
> public function send(itemToSend:int):bool
> ....
> ...
>
> which would make the call as simple as  :   myComponent.send(anything);
>
> -Nick
>
> On Mon, Jan 16, 2012 at 9:53 AM, Martin Heidegger <mh@leichtgewicht.at
> >wrote:
>
> > Overloading is the a way to implement two interface with conflicting
> > arguments for the same method:
> >
> > interface A {
> >   function test(a: String): void;
> > }
> >
> > interface B {
> >  function test(b:int):void;
> > }
> >
> > class C implements A,B {
> >  function test(a:String):void {};
> >  function test(b:int):void {};
> > }
> >
> > Without it relying on interfaces might be a stressful thing.
> >
> > yours
> > Martin.
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message