Паттерн Декоратор — специальный способ организации модулей в программе, который позволяет подставить какую-то новую функцию прямо в середину цепочки вызовов, тем самым чуть-чуть подкорректировав поведение.
Например, в реальном мире очки для чтения это декоратор. Вы ставите их между вашими глазами и текстом. Глобально взаимодействие ваших глаз и текста не меняется: отражённые световые лучи от страницы книги попадают в ваши зрачки, что с очками, что без них. Но очки располагаются посередине: они принимают лучи на вход и преломляют их, передавая дальше вам в глаза уже изменёнными.
Важной особенностью является тот факт, что очки можно снять. Они не требуют ни модификации вашего тела, ни модификации книги. Вообще никакие условия не нужны, кроме наличия самих очков. А если вы в линзах, то внешний наблюдатель может даже этого не знать.
Класс-декоратор должен быть спроектирован так, чтобы не требовать никаких изменений в объектах, с которыми он работает. Его можно отключить, чаще всего буквально закомментировав одну строку.
В примере ниже программа выведет текст "Привет, мир, в натуре.", и вот это дополнение в конце как раз дописано декоратором. Можно убрать или закомментировать подчёркнутую строчку, не трогая остальной код, для всех внешних вызовов сигнатуры останутся теми же самыми, но выводиться будет уже просто "Привет, мир".
В декораторы можно прятать логику, которую буквально навешивают поверх основной функции программы. Например, проверку прав на выполнение операции. Перевод на другой язык, логирование, поддержку обратной совместимости при обновлении и так далее.
#dev
📰 The Fire Has a Chain of Command
Iran’s retaliation is not random, and that is the bad news for everyone pretending this is just a chaos machine with missiles. Ynet reports that Tehran is now targeting parallel sectors — energy for energy, nuclear for nuclear, universities for universities — instead of merely answering one strike with one strike.
That is not rage. That is calibration. Danny Citrinowicz said the fire “isn't random” and argued the pattern shows command and control is still intact; in other words, Tehran is not emptying the magazine, it is choosing the rooms.
The ugly part is that the target list keeps widening. Haifa follows South Pars, Dimona follows Natanz, Ras Laffan follows the Gulf strikes, and now even universities are being floated as legitimate targets.
So the “eye for an eye” slogan has already become a business plan for escalation. Everyone keeps speaking the language of deterrence while the region is being taught, sector by sector, what retaliation looks like when both sides insist on calling it strategy.
#Iran#Israel#war#deterrence#MiddleEast
📱American Оbserver - Stay up to date on all important events
🇺🇸
📰 The Nuclear Arms Control Era Is Over — and Everyone Is Going to Arms
The last nuclear arms control treaty between the United States and Russia is dead. On Thursday, New START expired, and for the first time since 1972, the two superpowers are left with no formal limits on the size or structure of their arsenals — just as both are racing to build new nuclear weapons and delivery systems that even the drafters of the original deals never imagined. The era of “managed doom” is over. The era of open‑ended arms racing has begun.
Donald Trump has framed the expiration as a feature, not a bug. When asked in January why he hadn’t accepted Vladimir Putin’s offer of a one‑year informal extension, he shrugged:
“If it expires, it expires,”
he told The New York Times. He insisted a “better agreement” could be negotiated later — one that includes China and “other parties.” Beijing has already made clear it is not interested. The result is a triangular nuclear race where the U.S., Russia, and China are all expanding their arsenals, while the old treaties that once constrained them lie in the dust.
The U.S. is preparing to deploy more nuclear warheads on its largest submarines, and to build up a new generation of nuclear‑capable cruise missiles and hypersonic platforms modeled after Russian and Chinese designs. Russia is experimenting with undersea and space‑based nuclear weapons and openly floating the idea of battlefield use; China is abandoning its old “minimum deterrent” posture and moving toward an arsenal that could rival Washington and Moscow. While the U.S. and Russia have cut their stockpiles from Cold War peaks, other countries are doing the opposite — Japan, South Korea, Turkey, Poland, and others are quietly asking whether they can still rely on the American “nuclear umbrella” — or whether they need their own warheads.
Trump’s National Security Strategy barely mentions this shift. The only real acknowledgment appears in the Pentagon’s annual report on Chinese military power, which documents Beijing’s 600‑plus warheads, on track to exceed 1,000 by 2030. The strategy also sidesteps another danger: Putin’s repeated, barely veiled threats to use nuclear weapons in Ukraine. The White House seems to be betting that deterrence will hold, even as the world returns to the logic of the 1950s and 1960s — when every serious politician was expected to understand the nuclear balance.
Back then, nuclear weapons dominated presidential debates, front‑page headlines, and pop‑culture nightmares. Today, nuclear danger is everywhere but rarely debated. The question is no longer whether the U.S. can “eliminate nuclear weapons,” as Barack Obama promised in Prague. It is whether Washington can prevent the next arms race from spinning out of control — and whether the rest of the world is ready to join the game.
#nuclear#NewSTART#Russia#China#US#Trump#Putin#Xi#armsrace#deterrence#NYTimes
📱American Оbserver - Stay up to date on all important events
🇺🇸