Random commentary about Machine Learning, BigData, Spark, Deep Learning, C++, STL, Boost, Perl, Python, Algorithms, Problem Solving and Web Search
Wednesday, September 30, 2015
Implementing the Chain of responsibility pattern
A chain
of responsibility pattern delegates a sequence of commands to a chain of
processing objects. Objects can be dynamically added to a list
Tuesday, September 29, 2015
Implementing the Command pattern
The command pattern is used to create objects
which encapsulate behaviours and states. This pattern is frequently needed when we want
to delegate a sequence of calls with no need of explicitly knowing the parameter
details or the specific methods here involved.
Monday, September 28, 2015
Implementing the Interpreter pattern
The Interpreter is a pattern used for
implementing a specialized interpreted
language. The idea is to have a class for each symbol of the grammar, used for
defining the Interpreter.
Saturday, September 26, 2015
Implementing the Iterator pattern
The Iterator pattern is used to access all the
elements of an object without exposing its internal representation. This
pattern is commonly used by libraries of containers such as the STL for
decoupling accesses to a specific container from its implementation.
Friday, September 25, 2015
Implementing the Mediator pattern
The Mediator allows interactions among classes
with loose coupling. Each class is not required to recognize too much details
of the other classes logic, which is exposed only to the mediator. Objects are
not required to communicate directly anymore but they leverage the mediator,
thereby reducing the coupling effects.
Thursday, September 24, 2015
Implementing the Observer pattern
The Observer
pattern implements the publisher/subscriber interactions, where a number of
registered observer objects are informed about events produced by the
publishers. This pattern is frequently used for implementing a distributed
event handling system and for windows systems.
Wednesday, September 23, 2015
Implementing the Strategy pattern
The Strategy pattern allows selection at
run-time on specific algorithms for implementing a particular behaviour given a
class of similar algorithms for that function.
Implementing the State pattern
The State pattern is used to allow an object to
change his behaviour, when the internal state of the object itself is changing.
For instance this pattern can be used to change the state of an object at
run-time.
Monday, September 21, 2015
Implementing the Template pattern
The template pattern allows the definition of algorithms skeleton as an abstract class,
where subclasses have the responsibility of providing its concrete behaviour.
The word template is not related to C++ templates.
Sunday, September 20, 2015
Implementing the Visitor pattern
The Visitor pattern allows to visit an object
in a hierarchical way with no need of considering internal details. In this way
algorithms can be separated from the object structure on which they operate.
Friday, September 18, 2015
Thursday, September 17, 2015
Print the binary representation of an unsigned int
Monday, September 14, 2015
Sunday, September 13, 2015
Saturday, September 12, 2015
Friday, September 11, 2015
Add two numbers without using arithmetic operators
Count the number of bits set in an unsigned number
Wednesday, September 9, 2015
Tuesday, September 8, 2015
Multiply two numbers without using arithmetic operators
Monday, September 7, 2015
Compute the two’s complement for a given integer
Sunday, September 6, 2015
Saturday, September 5, 2015
Friday, September 4, 2015
Swap two integers variables with no additional memory
Thursday, September 3, 2015
Wednesday, September 2, 2015
Tuesday, September 1, 2015
Subscribe to:
Posts (Atom)