Notice: file_put_contents(): Write of 3350 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50

Warning: file_put_contents(): Only 12288 of 15638 bytes written, possibly out of free disk space in /var/www/tgoop/post.php on line 50
Computer Science@CScience1 P.3123
CSCIENCE1 Telegram 3123
Паттерн Factory Method (Фабричный метод)

Factory Method позволяет создавать объекты, не указывая точный класс создаваемого объекта. Это удобно, когда вы хотите делегировать создание объектов подклассам.

Пример:
Представьте, что у вас есть приложение для отправки уведомлений. В зависимости от типа уведомления (Email, SMS, Push) вы можете использовать фабричный метод для создания нужного объекта.

class Notification:
def notify(self):
pass

class EmailNotification(Notification):
def notify(self):
print("Отправка Email")

class SMSNotification(Notification):
def notify(self):
print("Отправка SMS")

class NotificationFactory:
@staticmethod
def create_notification(type):
if type == "email":
return EmailNotification()
elif type == "sms":
return SMSNotification()



tgoop.com/CScience1/3123
Create:
Last Update:

Паттерн Factory Method (Фабричный метод)

Factory Method позволяет создавать объекты, не указывая точный класс создаваемого объекта. Это удобно, когда вы хотите делегировать создание объектов подклассам.

Пример:
Представьте, что у вас есть приложение для отправки уведомлений. В зависимости от типа уведомления (Email, SMS, Push) вы можете использовать фабричный метод для создания нужного объекта.

class Notification:
def notify(self):
pass

class EmailNotification(Notification):
def notify(self):
print("Отправка Email")

class SMSNotification(Notification):
def notify(self):
print("Отправка SMS")

class NotificationFactory:
@staticmethod
def create_notification(type):
if type == "email":
return EmailNotification()
elif type == "sms":
return SMSNotification()

BY Computer Science


Share with your friend now:
tgoop.com/CScience1/3123

View MORE
Open in Telegram


Telegram News

Date: |

Judge Hui described Ng as inciting others to “commit a massacre” with three posts teaching people to make “toxic chlorine gas bombs,” target police stations, police quarters and the city’s metro stations. This offence was “rather serious,” the court said. SUCK Channel Telegram The group also hosted discussions on committing arson, Judge Hui said, including setting roadblocks on fire, hurling petrol bombs at police stations and teaching people to make such weapons. The conversation linked to arson went on for two to three months, Hui said. ZDNET RECOMMENDS Unlimited number of subscribers per channel
from us


Telegram Computer Science
FROM American