• About
  • Contact
  • Books

Sanjib Sinha

~ On Computer Science, PHP, Python, Ethical Hacking and more…

Sanjib Sinha

Tag Archives: design patterns in php

Composer and Effective PHP Patterns

18 Saturday Aug 2018

Posted by Sanjib Sinha in Classes and Object, git, MySQL, operating systems, PHP, PHP Developers, Software

≈ 1 Comment

Tags

composer, design patterns in php, PHP, php7, seperation of concerns

object oriented design patterns in php

object oriented design patterns in php


Object Oriented Design Patterns in PHP 7

Gang of Four!

How about starting this discussion by quoting from them?

Their famous book “Design Patterns, Elements of Reusable Object-Oriented Software”; and they are Erich Gamma, Richard Helm, Ralph Johnson and

John Vlissides.

The book starts with this meaningful statement— “Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. You must find pertinent objects, factor them into classes at the right granularity, define class interfaces and inheritance hierarchies, and establish key relationships among them.

Your design should be specific to the problem at hand but also general enough to address future problems and requirements. You also want to avoid redesign, or at least minimize it. Experienced object-oriented designers will tell you that a reusable and flexible design is difficult if not impossible to get “right” the first time. Before a design is finished, they usually try to reuse it several times, modifying it each time.

Yet experienced object-oriented designers do make good designs. Meanwhile, new designers are overwhelmed by the options available and tend to fall back on non-object-oriented techniques they’ve used before. It takes a long time for novices to learn what good object-oriented design is all about. Experienced designers evidently know something inexperienced ones don’t. What is it?”

This introductory paragraph ends with a question mark.
Continue reading →

Share this:

  • Facebook
  • WhatsApp
  • Twitter

Like this:

Like Loading...

Horizontal reuse of code in php

17 Tuesday Jul 2018

Posted by Sanjib Sinha in Classes and Object, PHP, PHP Developers, Software

≈ Leave a comment

Tags

application, design patterns in php, horizontal reuse of code, interface, PHP, php 7, trait

The object-oriented programming is all about effective planning and design and interface plays the role of a blueprint; traits help objects to implement that blueprint. Going overboard with traits break that effectiveness.
Let us try to understand that point in the light of our selling application. Consider this code.

//iDeliveryParty.php
namespace MyInterface;

interface iDeliveryParty {
function get($product);
function post($review);
}

However, not every user may want to post a review. In that case, the traits will come to our help for not only implementing the interface but also enhance the re-usability of the code.
Continue reading →

Share this:

  • Facebook
  • WhatsApp
  • Twitter

Like this:

Like Loading...

Adapter Pattern in PHP

02 Wednesday Nov 2016

Posted by Sanjib Sinha in Classes and Object, Laravel 5, Laravel 5.2.4: Be A Laravel Expert, laravel 5: learn easy, PHP, PHP 7 in 7 Days

≈ Leave a comment

Tags

Adapter Pattern in PHP, design pattern in php, design patterns in php, php training, php training in calcutta, php training in kolkata, php tutorials on design pattern

Beginning Laravel

Beginning Laravel


Beginning Laravel

Can we Adapt SMS into MAIL?
Now we’re going to do an impossible task.
Are you prepared?
Can we start?
This chapter is about the adapter pattern. It’s one of the design patterns that you’re currently on. Let us start with a real world example.
You know that internet connection is absolutely necessary for sending emails. Is it true in the real world? You’d say, well, I know that. An internet networking is a must.

Continue reading →

Share this:

  • Facebook
  • WhatsApp
  • Twitter

Like this:

Like Loading...

Chain of responsibility in php

01 Tuesday Nov 2016

Posted by Sanjib Sinha in Classes and Object, Laravel 5, Laravel 5.2.4: Be A Laravel Expert, laravel 5: learn easy, PHP, PHP 7 in 7 Days

≈ 2 Comments

Tags

Chain of responsibility in php, design pattern in php, design patterns in php, php training in calcutta, php training in kolkata, php tutorials on design pattern

Why I let readers download my books absolutely FREE

People may doubt whether my motives for letting readers download my books absolutely free are altruistic-you may doubt that behind this big-hearted decision I probably hanker for publicity.

You are always welcome whatever way you perceive me. Good, bad, or ugly.

The true motivation stems from one single principle-knowledge should be free and remain accessible to all. Besides that, I believe only true knowledge can save us from this ubiquitous and omnipresent poverty.

So through the Leanpub platform, you may either download my books absolutely free or you may pay any amount you wish. The choice is yours.

I am a full-time writer, so I write books to put bread on my table. If you have money, pay any amount you want to, it starts at 0.99 Dollar; however, if you have no money, don’t worry, download the books absolutely free. As long as Leanpub allows this, it’s fine. If they stop that, I will start it right from here.

Now, I plan every book in a way so that it relates to a series of video stream where I explain the concepts audiovisually.

I would request you to subscribe to my YouTube channel and share it with your friends for one single reason. It indirectly helps me going this way-my own “FREE” way.

YouTube channel for good web programming practices

Leanpub platform for FREE books

For more videos

Happy reading. Happy watching. Happy coding.

Beginning Laravel

Beginning Laravel


Beginning Laravel

Let us see how Responsibility can be Unchained!
In object-oriented design, the chain-of-responsibility pattern belongs to behavioral design patterns segment. The simplest example contains a person using ATM. He’s entering pin, receiving payment and receipts etcetera.
What is behavioral design pattern? They are a type of design patterns that generally identify communicating objects.
You may ask, what kind of objects we’re talking about? These objects have common communication patterns between them. While communicating they must realize that patterns.

Continue reading →

Share this:

  • Facebook
  • WhatsApp
  • Twitter

Like this:

Like Loading...

Decorator Patterns in PHP

31 Monday Oct 2016

Posted by Sanjib Sinha in Classes and Object, Laravel 5, Laravel 5.2.4: Be A Laravel Expert, laravel 5: learn easy, PHP, PHP 7 in 7 Days

≈ Leave a comment

Tags

behavioural patterns in php, decorator patterns in php, design patterns in php, PHP, php 7 tutorial, php training in calcutta, php training in kolkata

When we want to add additional features to our existing classes we generally use decorator pattern.
Do you find this definition useful?
I believe the answer will be NO.
It says about only adding new features. It doesn’t say about how you will use that. Will you add the features by simply hard coding or you’ll add them in the run time.
That’s a pretty big difference.
Why?
Let us consider a simple example where we are talking about a hosting company. A typical hosting company sells hosting services and sometimes they also provide template designing.
Let’s design a pretty basic scenario.

Continue reading →

Share this:

  • Facebook
  • WhatsApp
  • Twitter

Like this:

Like Loading...

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • May 2018
  • April 2018
  • March 2018
  • January 2018
  • December 2017
  • November 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016

Categories

  • Android
  • Classes and Object
  • CSS
  • Dart
  • Data Journalism
  • Data-Journalism
  • Ethical hacking
    • kali linux
  • Ethical Hacking for Brginners
  • Exceptions
  • Flutter
  • General
  • git
  • HTML
  • iOS
  • JavaScript
  • Laravel 5
  • Laravel 5.2.4: Be A Laravel Expert
  • laravel 5.7
  • laravel 5.7 all model relations explained
  • Laravel 5.8
  • laravel 5: learn easy
  • life
  • metasploitable
  • Mobile Device
  • MySQL
  • NASA
  • Native iOS
  • Object Oriented Programming
  • operating systems
  • PHP
  • php 7
  • PHP 7 in 7 Days
  • PHP Developers
  • Programming Language
  • Python
    • General Syntax
    • Variables, Objects annd Values
  • Software
  • tehelka
  • wordpress

Meta

  • Register
  • Log in

Blog at WordPress.com.

Cancel
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
%d bloggers like this: