ThemeForest

What the easy way, what’s the way to go.

3678 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Brazil
  • Referred between 1 and 9 users
tsafi says

Here is the thing I ask myself many times, in a coding matter AS3 .

When working on extend class the dilemma always is how to move thing around on complex project when sharing var via extend class, so OK you have the event type, bubbles (Dispatching)but really sometime its tiring matter to handle all this events ,then you have the global matter singleton is a great way but i look at this in a sub local matter, then you have the public static var ,man that save you tons of time, one variable and you are done sharing your XML verb` via sub class and save you some coding variable but you need to be on top things so thing won’t get out of control .

So what’s your preference why to go ? I am interesting to hear some opinions

11 months ago
3086 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 10 and 49 items
  • Italy
  • Referred between 100 and 199 users
ParkerAndKent says

Hi Tsafi,

your question isn’t very clear :)

Are you talking about the best way to retrive instance variables when sub classing?

11 months ago
2996 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 50 and 99 items
  • India
  • Referred between 200 and 499 users
VF says

Someone please translate :P

Anyway, it is upto the complexity and necessity of project that should decide than by the developer, whatever may be your concern. I am new to oop but from initial experiences, I see the project nature is still dominating on making decisions than coding habits of dev.

11 months ago
1622 posts
  • Has been a member for 3-4 years
  • Won a Competition
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 50 000 and 100 000 dollars
  • Bought between 10 and 49 items
  • Italy
  • Referred between 50 and 99 users
bitfade says

edit…

11 months ago
2996 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 50 and 99 items
  • India
  • Referred between 200 and 499 users
VF says

^ thought this kind of questions deserves a blurred answer / openion! :P

11 months ago
2350 posts
  • Has been a member for 4-5 years
  • Won a Competition
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
  • Europe
  • Referred between 50 and 99 users
wickedpixel says
tsafi said
Here is the thing I ask myself many times, in a coding matter AS3 .

When working on extend class the dilemma always is how to move thing around on complex project when sharing var via extend class, so OK you have the event type, bubbles (Dispatching)but really sometime its tiring matter to handle all this events ,then you have the global matter singleton is a great way but i look at this in a sub local matter, then you have the public static var ,man that save you tons of time, one variable and you are done sharing your XML verb` via sub class and save you some coding variable but you need to be on top things so thing won’t get out of control .

So what’s your preference why to go ? I am interesting to hear some opinions

Yes.




:)
I can’t say I have worked on very complex projects…
The main structure I had working was a central Core that contained the most important parameters as static variables…
After that, the best thing was a tree of kids and parents where kids only listened for the parents events in order to take action. And that with events that carry custom data needed for kids to use.
I wasn’t that big in using all those fancy designed patters in oop.

11 months ago
3336 posts
  • Has been a member for 2-3 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a Free File of the Month
  • Beta Tester
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Bought between 10 and 49 items
  • Italy
doru says

is like getting inside the kitchen of a restaurant and ask a cook what he is doing with all those types of knifes of different size and shapes, why he can’t just use only one or two of them?

11 months ago
2996 posts
  • Has been a member for 3-4 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Author had a File in an Envato Bundle
  • Exclusive Author
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Bought between 50 and 99 items
  • India
  • Referred between 200 and 499 users
VF says
tsafi said
What the easy way, what’s the way to go

I know stones will be thrown. The easy way is AS2 hehe! :sarcasm:

The way to go is… some times left and sometimes right!

11 months ago
3678 posts
  • Has been a member for 3-4 years
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Brazil
  • Referred between 1 and 9 users
tsafi says

Falow wickedpixel :P .

Public method—Dispatching /public static var /singleton.

Sharing instance variables via class/sub atc` as P&K say, no need for example just sharing thoughts.

please no primitive thoughts like AS2 :P .

and wickedpixel handling public static var lets say more then 100 is a tricky way to go on massive class/sub if you share them

11 months ago
3086 posts
  • Has been a member for 3-4 years
  • Author had a File in an Envato Bundle
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Beta Tester
  • Exclusive Author
  • Sold between 250 000 and 1 000 000 dollars
  • Elite Author
  • Bought between 10 and 49 items
  • Italy
  • Referred between 100 and 199 users
ParkerAndKent says

Mmm, well… I usually keep instance variables protected, so they can be inherited by sub classes. I like to always use setters and getters to have more control on the values. I use public static variables only for the event names, obviously.

The only downside of this method is for the events dispatching, because I just use the dispatchEvent method with the static names defined in each class, so when I have to register a listener for an event of a sub class instance I need to access the event name using the class in which the static name of the event has been defined… not sure it’s clear… (I could also use a simple string, but I prefer to use the static variables to be sure to type them correctly).

Then I look at my projects like big containers with many objects into them… using setters and getters and the custom events I easily create a full comunication between the objects.

I’m not sure this is the best way to organize things, but it works just fine for my needs… I’m not really comfortable with any specific design pattern.

11 months ago
by
by
by
by
by