We've been in the process of changing how our AS3 application talks to our back end and we're in the process of implementing a REST system to replace our old one.Sadly the developer who started the work is now on long term sick leave and it's been handed over to me. I've been working with it for the past week or so now and I understand the system, but there's one thing that's been worrying me. There seems to be a lot of passing of functions into functions. For example our class that makes the call to our servers takes in a function that it will then call and pass an object to when the process is complete and errors have been handled etc.It's giving me that bad feeling where I feel like it's horrible practice and I can think of some reasons why but I want some confirmation before I propose a re-work to system. I was wondering if anyone had any experience with this possible problem?
Passing functions into other functions as parameters, bad practice?
object oriented;object oriented design;rest
It isn't a problem. It is a known technique. These are higher order functions (functions that take functions as parameters).This kind of function is also a basic building block in functional programming and is used extensively in functional languages such as Haskell.Such functions are not bad or good - if you have never encountered the notion and technique they can be difficult to grasp at first, but they can be very powerful and are a good tool to have in your toolbelt.