Interface_ex_1

Description

Interface example
Luis Rojas
Note by Luis Rojas, updated more than 1 year ago
Luis Rojas
Created by Luis Rojas over 7 years ago
61
0

Resource summary

Page 1

interface Logger { public function execute($message);}class LogToFile implements Logger { public function execute($message){ //code... }}class LogToDb implements Logger { public function execute($message){ //code... }}class UsersController { protected $logger; // Over interface not implementation public function __construct(Logger $logger){ $this->logger = $logger; } public function show(){ $user = 'Juan'; // The execute method will depend over which concrete class $this->logger->execute($user); }}$controller1 = new UsersController(new LogToFile);$controller1->show();$controller2 = new UsersController(new LogToDb);$controller2->show();

Show full summary Hide full summary

Similar

Interface en Java
tavoberry
Diccionario tecnológico
My Gorvein
Componentes SWING
ALEX Merino
Interface en Java
tavoberry
Diseño de las interfaces del desarrollo de software de aplicación
Julio Cesar Zuluaga
Diseño de interfaces de aplicacion de usuario
Sindy Galvis
DISEÑO DE LAS INTERFACES DEL DESARROLLO DE SOFTWARE DE APLICACION DE USUARIO
Elkin Rodriguez
Diseño de Interfaces de aplicación de usuario
Andrea Muñoz
PROTOCOLO PPP
Efrain Cuevas riaño
Understanding and conceptualizing interaction
Katya Treviño
1_Componentes SWING
pancho as