Clicca qui! Clicca qui!
Clicca qui! Clicca qui!

Archive for the
‘Tipologie & Campi di Applicazione’ Category

Best Php Design Patterns


Design patterns are commonly defined as time-tested solutions to recurring design problems. The term refers to both the description of a solution that you can read, and an instance of that solution as used to solve a particular problem.

Why use design patterns?

Design patterns have two major benefits. First, they provide you with a way to solve issues related to software development using a proven solution. The solution facilitates the development of highly cohesive modules with minimal coupling. They isolate the variability that may exist in the system requirements, making the overall system easier to understand and maintain. Second, design patterns make communication between designers more efficient.

Right, can you show me some example?

Sure, i’ll show you some of the most used design patterns in PHP Language, starting by the Factory Pattern.

Factory Pattern

Factory is a creational design pattern which solves the problem of creating product objects without specifying their concrete classes. It defines a method, which should be used for creating objects instead of direct constructor call (new operator). Subclasses can override this method to change the class of objects that will be created.

class Automobile
    private $brand;
    private $model;

    public function __construct($brand, $model)
        $this->brand = $brand;
        $this->model = $model;

    public function getBrandAndModel()
        return $this->brand . ' ' . $this->model;

class AutomobileFactory
    public static function create($brand, $model)
        return new Automobile($brand, $model);

$automobile = AutomobileFactory::create('Ferrari', 'La Ferrari');

// if i print $automobile->getBrandAndModel(), the result will be "Ferrari La Ferrari"

This specific case is too much simple for explain the factory advantages, but if you need to do complex operations in order to instance the object, the factory pattern can include this complexity once, and avoid many possible mistakes.


The Singleton pattern is Class has one instance and provides a global access point to it.

    class Singleton {
        public static function getInstance() {
            static $instance = null;
            if (null === $instance) {
                $instance = new static();

            return $instance;

        protected function __construct() {

        private function __clone() {

        private function __wakeup() {

    class SingletonChild extends Singleton {

    $obj = Singleton::getInstance();
    $anotherObj = SingletonChild::getInstance();

    print_r($obj === Singleton::getInstance()); // true
    print_r($anotherObj === Singleton::getInstance()); // false
    print_r($anotherObj === SingletonChild::getInstance()); // true

Electronic Data Interchange

EDI, or Electronic Data Interchange, is a technology that helps trading partners and organizations get more done, speed up logistics timelines and eliminate manual errors by automating business-to-business (B2B) communications

The advantages of the EDI approach:

  • Unlimited EDI Translation on any desktop or server
  • EDI transfer ensures real-time processing and eliminates times associated with manually sending, receiving and entering orders
  • Increase business through secure connections between partners / suppliers / customers around the world.
  • Costs saving in operational efficiency

3 Reasons for Use Laravel

​I’m a web developer and I wish to talk about Laravel. Laravel is PHP framework, developed by Taylor Otwell in 2011 immediately finds a great consensus from the developers, why?​

1. Laravel implements the MVC pattern

The MVC is an architectural pattern using for developing UI, that divides an application into three interconnected parts; Model, View, Controller. The Model is the core of this pattern. It is not directly connected to UI and this means that the Model directly manages the data from the Database and the inputs recived from the Controller. The View is simply the visualization of the Model’s Data. Laravel use the Blade template to paginate the Data. The Controller is “The man in the Middle”, It encoding the View’s data for the model and organize the Model’s raw data for the View. This pattern have the Advantage of avoiding the code reuse, this reduces the time of Refactor and Debugging. In laravel, thanks to artisan comand, create a Model with the Controller is very fast:

php artisan make:model Easy --controller

2. Front-end

Laravel offers two way to develop very quickly you Front-end the Blade tempalate or the integration With Vue.js. Vue.js is a JavaScript framework, then it is logically separate from Laravel, for this reason is necessary a bundle of API to render the Back-end Data. But the real vantages of Vue.js is the possibilty to reuse some component with no fatigue and the possibility to create fully reactive View. On the other hand Blade is based on php, for this reason is not necessary the API approch to render the Back-end Data in this way you lose the reactivity of the View.​

3. Authentication

Laravel also offers the possibility to create pure API application using a single command:

php artisan passport:install

Laravel passport is a native package, developed for the api authentication, is very easy to use, it have all the necessary to setup the token and create the AuthMiddleware indipendenty. It have also the option to create some Vue component if you front-end is integrated in Laravel.

php artisan vendor:publish --tag=passport-components

Laravel by default implement the RESTFull standard for the API, for this the Laravel apps are much faster than apps that use SOAP standard and in these contexts every seconds is important.​For these reason Laravel has become the used and supported framework, on stackoverflow there are currently 122 455 questions about laravel against the 62 872 questions about Symfony.​If I could not convice you it will be necessary you googled laravel’s weak points​


Vue.js Docs Laravel Docs


A Briefing of Python


Python is an interpreted, high-level, general-purpose programming language. Python is dynamically typed and garbage-collected. It supports multiple programming paradigms, including procedural, object-oriented, and functional programming. Python has a comprehensive standard library providing most commonly required functionalities, and it’s available for many operating systems. It has been first released in 1991.​


​In December 1989, Guido Van Rossum had been looking for a “‘hobby’ programming project that would keep him occupied during the week around Christmas” as his office was closed when he decided to write an interpreter for a “new scripting language. He had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers”. He attributes choosing the name “Python” to “being in a slightly irreverent mood (and a big fan of Monty Python’s Flying Circus)”​

Wetting your appetite

​Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.​Let’s see some basic stuff:​

1. Functions Defined

The core of extensible programming is defining functions. Python allows mandatory and optional arguments, keyword arguments, and even arbitrary argument lists.​

# Python 3: Fibonacci series up to n
>>> def fib(n):
>>>     a, b = 0, 1
>>>     while a < n:
>>>         print(a, end=' ')
>>>         a, b = b, a+b
>>>     print()
>>> fib(1000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

2. Compound Data Types

Lists (known as arrays in other languages) are one of the compound data types that Python understands. Lists can be indexed, sliced and manipulated with other built-in functions.​

# Python 3: List comprehensions
>>> fruits = ['Banana', 'Apple', 'Lime']
>>> loud_fruits = [fruit.upper() for fruit in fruits]
>>> print(loud_fruits)
# List and the enumerate function
>>> list(enumerate(fruits))
[(0, 'Banana'), (1, 'Apple'), (2, 'Lime')]

3. Intuitive Interpretation

Calculations are simple with Python, and expression syntax is straightforward: the operators +, -, * and / work as expected; parentheses () can be used for grouping.​

# Python 3: Simple arithmetic
>>> 1 / 2
>>> 2 ** 3
>>> 17 / 3  # classic division returns a float
>>> 17 // 3  # floor division

4. Quick & Easy to Learn

Experienced programmers in any other language can pick up Python very quickly, and beginners find the clean syntax and indentation structure easy to learn.​

# Python 3: Simple output (with Unicode)
>>> print("Hello, I'm Python!")
Hello, I'm Python!
# Input, assignment
>>> name = input('What is your name?\n')
>>> print('Hi, %s.' % name)
What is your name?
Hi, Python.

5. All the Flow You’d Expect

Python knows the usual control flow statements that other languages speak — if, for, while and range — with some of its own twists, of course.​

# For loop on a list
>>> numbers = [2, 4, 6, 8]
>>> product = 1
>>> for number in numbers:
...    product = product * number
>>> print('The product is:', product)
The product is: 384

So far, so good. Now, if you’re interested in learning Python, take a look at this wide collection of guides, from beginners to advanced programmers and… have fun!