Decorators are handy sugars for Python programmers to shorten things and provides more concise programming.
For instance you can use decorators for user authentication for your REST API servers. Assume that, you need to auth. the user for before each REST calls. Instead of appending the same procedure to each call function, it is better to define decorator and tagging it onto your call functions.
Let's see the small example below. I hope it is self-descriptive.
How to use Decorators:
Decorators are functions called by annotations
Annotations are the tags prefixed by @
### Decorator functions ###
print "Hello Space!"
print "Hello Cosmos!"
@helloCosmos # annotation
@helloSpace # annotation
print "Hello World!"
### Above code is equivalent to these lines
# hello = helloSpace(hello)
# hello = helloCosmos(hello)
### Let's Try
Here we have some stupidly clever algorithms that are faster in execution but slower in convergence to solution.
First candidate to introduce you is Bogo Sort. Its idea is simpler. Shuffle the numbers until it finds the correct order. Complexity of the algorithm can be approximated as O(n.n!) (efficient hah ?). Its pseudo code can be written as;
Zend Framework is a good foundation for everything and can be used also as just a library of various functions. It is also the closest thing to be an "official" PHP framework so there are a lot of developers who know how to use it. It is, however, not a framework you would use to prototype something very quickly.
There are several frameworks that could be used as a quick RAD (Rapid Application Development) tools.
A good example is CakePHP, which is a very popular framework. Fairly easy to learn. It has a lot of sensible defaults and naming conventions that make your life much easier, but which you can override. Continue reading PHP MVC Frameworks→
Start with the comparison (that assumes you know normal threaded execution).
Two main difference between normal threaded system and asynchronous system are:
For threaded execution each thread has its own controller, however for asynchronous system there is only one thread controller.
Threaded execution does not give the control of ending, starting, changing to user. It is mainly controlled by the operating system internals. On the other side asynchronous execution need some explicit command to interleave one execution to other. It is more in control in the programmer's perspective.
yield function is one of the good stuff in the Ruby that gives different kind of code reuse logic to your code. It just like lambda in Scheme and Lips. when yield is called in a function it cuts the execution of its container function and pass the execution time to the do-end block then when the execution ends with the end keyword, it continues the execution from the last point.
Here is an example code that uses yield function.
eren = 20
puts "first step"
puts "last step"
around_staff do |eren|
puts "I did something around"+ eren.to_s