Паттерн Декоратор — специальный способ организации модулей в программе, который позволяет подставить какую-то новую функцию прямо в середину цепочки вызовов, тем самым чуть-чуть подкорректировав поведение.
Например, в реальном мире очки для чтения это декоратор. Вы ставите их между вашими глазами и текстом. Глобально взаимодействие ваших глаз и текста не меняется: отражённые световые лучи от страницы книги попадают в ваши зрачки, что с очками, что без них. Но очки располагаются посередине: они принимают лучи на вход и преломляют их, передавая дальше вам в глаза уже изменёнными.
Важной особенностью является тот факт, что очки можно снять. Они не требуют ни модификации вашего тела, ни модификации книги. Вообще никакие условия не нужны, кроме наличия самих очков. А если вы в линзах, то внешний наблюдатель может даже этого не знать.
Класс-декоратор должен быть спроектирован так, чтобы не требовать никаких изменений в объектах, с которыми он работает. Его можно отключить, чаще всего буквально закомментировав одну строку.
В примере ниже программа выведет текст "Привет, мир, в натуре.", и вот это дополнение в конце как раз дописано декоратором. Можно убрать или закомментировать подчёркнутую строчку, не трогая остальной код, для всех внешних вызовов сигнатуры останутся теми же самыми, но выводиться будет уже просто "Привет, мир".
В декораторы можно прятать логику, которую буквально навешивают поверх основной функции программы. Например, проверку прав на выполнение операции. Перевод на другой язык, логирование, поддержку обратной совместимости при обновлении и так далее.
#dev
✈️Bali expects 2.79 million tourists on New Year's Eve
📰 The Ministry of Transportation says 2.79 million visitors will arrive on the island during the Christmas and New Year holidays. This is traditionally the peak season on the island.
📍 Most of the travelers will arrive via the airport – 1.5 million people. Another 1.2 million will arrive via the Gilimanuk port, which connects Bali to the islands to the west, and 90,000 via the Padang Bay port to the east.
🚘 Bali's infrastructure, especially transportation, will face a major strain. Traffic is expected to increase by 20%.
🤔 Local authorities are already proposing exotic measures to combat traffic congestion – banning cars with license plates from other islands. However, it is problematic to put this into practice. The regional authorities have no such powers, and the central authorities will obviously not agree to it.
🎄 For everyone who is going to visit Bali for the holidays it is recommended to choose areas that have everything you need for a vacation. This will help to minimize movement around the island, and your mood will be much better.
@BaliNews
#transport#holidays#traffic
🚦 Bali authorities promise to avoid New Year traffic chaos
📰 After last year’s holiday gridlock, Bali police say they’re ready to keep traffic moving this festive season. A large-scale operation, Lilin Agung 2025, is now in effect across the island.
📍 Extra officers are deployed in busy tourist areas like Canggu, Seminyak, Kuta, and Uluwatu, while Ngurah Rai International Airport is operating 24/7 with heightened security and weather monitoring.
🌧️ With heavy rains and more than 1.5 million visitors expected, travelers are advised to leave for the airport well in advance and follow police instructions.
👮♂️ Authorities say all measures are in place to ensure a safe and smooth holiday travel experience
#holidays#traffic#safety@BaliNews
The increase in fines for a number of traffic violations will come into force on January 1, 2025
📌"In Article 2, the word" Law "should be replaced with the words "Federal Law", the words "after thirty days from the date of its official publication" should be replaced with the words "from January 1, 2025," the text of the amendment posted in the Duma electronic database says.
📌Under this law, failure by a driver to perform the duty to insure his civil liability, as well as driving a vehicle, if the Compulsory third Party Insurance (CTP) policy is deliberately absent, entails the imposition of an administrative fine in the amount of 800 rubles.
📌Earlier, the Parliament of the Kabardino-Balkar Republic submitted to the State Duma a bill that proposes to establish a fine for repeated violation of the Administrative Code of the Russian Federation, namely the absence of a driver's CTP policy, up to 5 thousand rubles.
CTP policy means Compulsory Third Party Insurance Policy
#news#russia#nido_russia#traffic#fine#regulations
https://t.me/nido_russia
E-commerce Conversion Crisis
E-commerce stores face a critical issue: they struggle to convert social media traffic into purchases, with conversion rates half as effective as average standards. Social media is a key source for online sales, with 64% of internet users shopping through these platforms, accounting for one-third of total online sales. The significant loss from unconverted traffic prompts stores to seek solutions, making platforms that improve conversion rates highly valuable.
Learn more about a startup addressing this issue: Read here
#Ecommerce#SocialMedia#Conversion#OnlineSales#Startup#Traffic#Retail#DigitalMarketing#Commerce#Business#Tech#Innovation#Sales#Marketing#UserExperience#Platforms#Shopping
E-commerce Conversion Crisis
E-commerce stores face a critical challenge with low conversion rates from social media traffic—about half of the general average. Despite this, social networks are a major traffic source, with 64% of users making purchases through them, accounting for a third of online sales. This gap presents significant revenue losses for stores that fail to convert this traffic, highlighting a potential market for platforms aimed at boosting conversions.
Read more: Fastfounder
#Ecommerce#Conversion#SocialMedia#Traffic#Sales#OnlineShopping#Startup#Market#Revenue#Challenges#Users#Platforms#Retail#Growth#Insights#Business#Tech#DigitalMarketing#Shopping#Income#Reports