Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb At the core of an object

    The other day i ran into a case where i had an object with almost all its methods executing the same check at start.

    Which led me to wonder if there is any high level method that runs no matter what lower level method is called, where i could implement this check???

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    not quite sure what you are talking about.... could you provide an example of what you are talking about, and maybe a little more explaination?
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, let's take a very basic example to illustrate what im trying to do:

    pretend i have a object of class Dog with the following function "bark", "run", "eat". In every of these methods, i have a check that basically does:

    if(sleeping) return

    what i want to do, is pre-register at initialization level the methods subject to this check and call another method (wake up) if (asleep),
    rather than having the same check within each function

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    what you're talking about is called Aspect Oriented Programming, and there are a few ways of doing this with javascript. http://beppu.lbox.org/articles/2006/09/06/actsasaspect is one I've used in the past.
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #5
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    very nice little piece of code.
    I am going to dig into the whole Aspect Oriented Programming concept, this seems to be only the tip of a powerful iceberg. thanks!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •