SlideShare a Scribd company logo
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
toString().padStart(width) : cell.padEnd(width); }).join(''))).join
}; const proportion = (max, val) => Math.round(val * 100 / max); co
calcProportion = table => { table.sort((row1, row2) => row2[DENSITY
row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table
forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL]))
return table; }; const getDataset = file => { const lines = fs.read
FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines
return lines.map(line => line.split(',')); }; const main = compose
(getDataset, calcProportion, renderTable); const fs = require('fs'
compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con
DENSITY_COL = 3; const renderTable = table => { const cellWidth = [
8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const
= cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p
(width); }).join(''))).join('n'); }; const proportion = (max, val)
Have Objects Failed?
Или что не так с ООП?
Тимур Шемсединов
github.com/HowProgrammingWorks
Chief Software Architect, Metarhia
Kiev Polytechnic Institute, SE Infotech, MIA
github.com/tshemsedinov
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
ООП присвоило множество идей
● Построение программных абстракций
● Наследование абстракций
● Инкапсуляция
● Декомпозиция
● Параметрический полиморфизм (дженерики)
● Полиморфизм подтипов (Барбары Лисков)
● Повторное использование кода
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Object-Oriented Design
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Откровенное вранье
● ООП это просто и плохие примеры
● ООП бесплатно решает проблемы
■ Повторное использование кода
■ Повышение связности (cohesion)
■ Уменьшение зацепления (coupling)
● Ускоряет разработку (исследование MIT)
● ООП лучше всего подходит во всех случаях
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
ООП это просто
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Проблемы ООП
● Объединение логики и данных -
сомнительное инженерное решение
● Пошаговая модификация небезопасна,
особенно в многопоточной среде:
this.x = (expression);
this.y = (expression);
this.doSomething();
this.doSomethingElse();
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Проблемы ООП
● Оверинжениринг
Ошибка точно где-то в стратегии, которая
передается в через открытый конструктор
в фабрику абстрактных классов, где и
оборачивается в адаптер для совместимости
с наблюдателем и изоляции от итератора.
● Ощущение всемогущества
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Всемогущество
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Проблемы ООП
● Неоднозначность моделирования
■ account1.transfer(account2, amount)
■ account2.receive(account1, amount)
■ new payment(account1, account2, amount)
■ bank.transfer(account1, account2, amount)
● Анемичные классы
● Классы-модули со статическими методами
● Синглтоны и пространства имен
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Проблемы ООП
● Ромбовидное наследование
(Diamond inheritance)
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Дейкстра не одобряет
“Object-oriented programming is
an exceptionally bad idea
which could only have originated
in California.”
Dijkstra
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Мнения экспертов
Ричард Гэбриел
Пол Грэм
Александр Степанов
Ричард Столтан
Никлаус Вирт
Линус Торвальдс
Джоэл Спольски и др. ответственные товарищи...
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Проще лечить или нового сделать?
● Не думать про ООП,
как про серебряную пулю
● Знать недостатки и заблуждения
● Изучать антипаттерны
● Критически относиться
к любой парадигме
● Избегать оверинжиниринга
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Что еще можно сделать?
● Структуры и API над этими структурами
- нас окружают объекты
- но оперируем мы не всегда объектами
- часто мы оперируем информацией о них
● Мультипарадигменное программирование
● Метапрограммирование
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Инкапсуляция
● Избегать неестественной инкапсуляции
this.from(json);
this.name = “Marcus Aurelius”;
if (this.validate()) {
this.prepareToSave();
this.saveToDatabase();
}
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Наследование
● Заменять наследование (если это возможно)
■ Делегирование или агрегация
■ Фасад
■ Адаптер
● Уменьшать иерархию наследования
● Наследоваться от интерфейсов
(реализовывать их)
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Хорошо подходит ООП
● Промышленная автоматизация
● Программирование микроконтроллеров
● Internet of Things
● Системное программирование
● Моделирование игровых миров
● Структуры данных
● Пользовательские интерфейсы
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Плохо подходит ООП
● Прикладной код ERP (бизнес-логика)
● Сервера API
● Обработка видео и звука
● Вычисления
● Научные приложения (моделирование)
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
ООП подходит с оговорками
● Платежные и банковские системы
● Электронная коммерция и торговля
● Сетевые протоколы (клиенты и сервера)
● Доступ к данным
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Что не так с ООП?
● ООП во многом осталось непонятым
● Распространяет фанатизм
● Завышенные ожидания
● Нет защиты от идиотов
● Нет магии
Это проблемы программистов, а не парадигмы
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
Ссылки
Objects Have Failed
dreamsongs.com/Files/ObjectsHaveFailedSlides.pdf
Почему ООП провалилось?
blogerator.org/page/oop_why-objects-have-failed
Я не знаю ООП
habr.com/ru/post/147927/
const fs = require('fs'); const compose = (...funcs) => x => funcs.
reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab
table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma
=> (row.map((cell, i) => { const width = cellWidth[i]; return i ? c
toString().padStart(width) : cell.padEnd(width); }).join(''))).join
}; const proportion = (max, val) => Math.round(val * 100 / max); co
calcProportion = table => { table.sort((row1, row2) => row2[DENSITY
row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table
forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL]))
return table; }; const getDataset = file => { const lines = fs.read
FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines
return lines.map(line => line.split(',')); }; const main = compose
(getDataset, calcProportion, renderTable); const fs = require('fs'
compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con
DENSITY_COL = 3; const renderTable = table => { const cellWidth = [
8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const
= cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p
(width); }).join(''))).join('n'); }; const proportion = (max, val)
Have Objects Failed?
Или что не так с ООП?
Тимур Шемсединов
github.com/HowProgrammingWorks
Chief Software Architect, Metarhia
Kiev Polytechnic Institute, SE Infotech, MIA
github.com/tshemsedinov

More Related Content

PDF
Почему хорошее ИТ-образование невостребовано рыночком
PDF
Information system structure and architecture
PDF
Node.js security
PDF
Введение в программирование (1 часть)
PDF
Базы данных в 2020
PDF
Node.js in 2019
PPT
SciPy
PDF
5.1 Перегрузка операторов
Почему хорошее ИТ-образование невостребовано рыночком
Information system structure and architecture
Node.js security
Введение в программирование (1 часть)
Базы данных в 2020
Node.js in 2019
SciPy
5.1 Перегрузка операторов

What's hot (20)

PDF
Оптимизация производительности Python
PDF
Rust: абстракции и безопасность, совершенно бесплатно
PPTX
Funny JS #2
PDF
Decorators' recipes
PDF
Магия в Python: Дескрипторы. Что это?
PPT
Программирование. Лекция 3
ODP
Charming python sc2-8
PDF
8 встреча — Язык программирования Python (В. Ананьев)
PDF
Python dict: прошлое, настоящее, будущее
PDF
Векторизация кода (семинар 3)
PPTX
Как написать JIT компилятор
PDF
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
PPTX
минимизация булевых функций
PDF
Лекция 7. Стандарт OpenMP (подолжение)
PDF
Магия метаклассов
ODP
Coroutines
PDF
Komarov borba za-miesto-urfu_2013
PPTX
Дуров Р. - Cocos2d
PDF
Векторизация кода (семинар 2)
Оптимизация производительности Python
Rust: абстракции и безопасность, совершенно бесплатно
Funny JS #2
Decorators' recipes
Магия в Python: Дескрипторы. Что это?
Программирование. Лекция 3
Charming python sc2-8
8 встреча — Язык программирования Python (В. Ананьев)
Python dict: прошлое, настоящее, будущее
Векторизация кода (семинар 3)
Как написать JIT компилятор
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
минимизация булевых функций
Лекция 7. Стандарт OpenMP (подолжение)
Магия метаклассов
Coroutines
Komarov borba za-miesto-urfu_2013
Дуров Р. - Cocos2d
Векторизация кода (семинар 2)
Ad

Similar to Objects have failed (16)

PDF
How to get knowledge and improve it all your professional life long
PDF
Презентация студента: Python | Принципы ООП
PDF
functional patterns - dotnetconf'11
PPTX
парадигмы программирования и шаблоны проектирования
PDF
Приёмы функционального программирования в обычном JavaScript
PDF
Теории и практики функционального программирования.
PDF
Теории и практики фунционального программирования - GDG D2D
PPTX
Презентация студента: Python ООП (прграммирование)
PDF
Не бойся, это всего лишь данные... просто их много
PDF
Объектное и прототипное программирование в Javascript
PDF
Yuriy Sherstyuk - Algorithms in Front End: from V8 to VDOM
PDF
ук 03.001.02 2011
PPTX
разработка бизнес приложений (6)
PDF
2016-11-12 01 Егор Непомнящих. Агрегация и осведомленность
PDF
Функциональное программирование с использованием библиотеки fp-ts | Odessa Fr...
PDF
ООП в Scala: выход из застоя (ScalaNsk meeting #5, 22.11.2013)
How to get knowledge and improve it all your professional life long
Презентация студента: Python | Принципы ООП
functional patterns - dotnetconf'11
парадигмы программирования и шаблоны проектирования
Приёмы функционального программирования в обычном JavaScript
Теории и практики функционального программирования.
Теории и практики фунционального программирования - GDG D2D
Презентация студента: Python ООП (прграммирование)
Не бойся, это всего лишь данные... просто их много
Объектное и прототипное программирование в Javascript
Yuriy Sherstyuk - Algorithms in Front End: from V8 to VDOM
ук 03.001.02 2011
разработка бизнес приложений (6)
2016-11-12 01 Егор Непомнящих. Агрегация и осведомленность
Функциональное программирование с использованием библиотеки fp-ts | Odessa Fr...
ООП в Scala: выход из застоя (ScalaNsk meeting #5, 22.11.2013)
Ad

More from Timur Shemsedinov (20)

PDF
How to use Chat GPT in JavaScript optimizations for Node.js
PDF
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
PDF
Multithreading in Node.js and JavaScript
PDF
Node.js threads for I/O-bound tasks
PDF
Node.js Меньше сложности, больше надежности Holy.js 2021
PDF
Rethinking low-code
PDF
Hat full of developers
PDF
FwDays 2021: Metarhia Technology Stack for Node.js
PDF
Node.js for enterprise - JS Conference
PDF
Node.js for enterprise 2021 - JavaScript Fwdays 3
PDF
Node.js in 2021
PDF
Node.js middleware: Never again!
PDF
Patterns and antipatterns
PDF
Race-conditions-web-locks-and-shared-memory
PDF
Asynchronous programming and mutlithreading
PDF
Node.js in 2020 - part 3
PDF
Node.js in 2020 - part 2
PDF
Node.js in 2020 - part 1
PDF
Web Locks API
PDF
Node.js in 2020
How to use Chat GPT in JavaScript optimizations for Node.js
IT Revolution in 2023-2024: AI, GPT, business transformation, future professi...
Multithreading in Node.js and JavaScript
Node.js threads for I/O-bound tasks
Node.js Меньше сложности, больше надежности Holy.js 2021
Rethinking low-code
Hat full of developers
FwDays 2021: Metarhia Technology Stack for Node.js
Node.js for enterprise - JS Conference
Node.js for enterprise 2021 - JavaScript Fwdays 3
Node.js in 2021
Node.js middleware: Never again!
Patterns and antipatterns
Race-conditions-web-locks-and-shared-memory
Asynchronous programming and mutlithreading
Node.js in 2020 - part 3
Node.js in 2020 - part 2
Node.js in 2020 - part 1
Web Locks API
Node.js in 2020

Objects have failed

  • 1. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c toString().padStart(width) : cell.padEnd(width); }).join(''))).join }; const proportion = (max, val) => Math.round(val * 100 / max); co calcProportion = table => { table.sort((row1, row2) => row2[DENSITY row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL])) return table; }; const getDataset = file => { const lines = fs.read FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines return lines.map(line => line.split(',')); }; const main = compose (getDataset, calcProportion, renderTable); const fs = require('fs' compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con DENSITY_COL = 3; const renderTable = table => { const cellWidth = [ 8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const = cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p (width); }).join(''))).join('n'); }; const proportion = (max, val) Have Objects Failed? Или что не так с ООП? Тимур Шемсединов github.com/HowProgrammingWorks Chief Software Architect, Metarhia Kiev Polytechnic Institute, SE Infotech, MIA github.com/tshemsedinov
  • 2. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c ООП присвоило множество идей ● Построение программных абстракций ● Наследование абстракций ● Инкапсуляция ● Декомпозиция ● Параметрический полиморфизм (дженерики) ● Полиморфизм подтипов (Барбары Лисков) ● Повторное использование кода
  • 3. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Object-Oriented Design
  • 4. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Откровенное вранье ● ООП это просто и плохие примеры ● ООП бесплатно решает проблемы ■ Повторное использование кода ■ Повышение связности (cohesion) ■ Уменьшение зацепления (coupling) ● Ускоряет разработку (исследование MIT) ● ООП лучше всего подходит во всех случаях
  • 5. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c ООП это просто
  • 6. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Проблемы ООП ● Объединение логики и данных - сомнительное инженерное решение ● Пошаговая модификация небезопасна, особенно в многопоточной среде: this.x = (expression); this.y = (expression); this.doSomething(); this.doSomethingElse();
  • 7. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Проблемы ООП ● Оверинжениринг Ошибка точно где-то в стратегии, которая передается в через открытый конструктор в фабрику абстрактных классов, где и оборачивается в адаптер для совместимости с наблюдателем и изоляции от итератора. ● Ощущение всемогущества
  • 8. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Всемогущество
  • 9. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Проблемы ООП ● Неоднозначность моделирования ■ account1.transfer(account2, amount) ■ account2.receive(account1, amount) ■ new payment(account1, account2, amount) ■ bank.transfer(account1, account2, amount) ● Анемичные классы ● Классы-модули со статическими методами ● Синглтоны и пространства имен
  • 10. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Проблемы ООП ● Ромбовидное наследование (Diamond inheritance)
  • 11. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Дейкстра не одобряет “Object-oriented programming is an exceptionally bad idea which could only have originated in California.” Dijkstra
  • 12. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Мнения экспертов Ричард Гэбриел Пол Грэм Александр Степанов Ричард Столтан Никлаус Вирт Линус Торвальдс Джоэл Спольски и др. ответственные товарищи...
  • 13. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Проще лечить или нового сделать? ● Не думать про ООП, как про серебряную пулю ● Знать недостатки и заблуждения ● Изучать антипаттерны ● Критически относиться к любой парадигме ● Избегать оверинжиниринга
  • 14. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Что еще можно сделать? ● Структуры и API над этими структурами - нас окружают объекты - но оперируем мы не всегда объектами - часто мы оперируем информацией о них ● Мультипарадигменное программирование ● Метапрограммирование
  • 15. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Инкапсуляция ● Избегать неестественной инкапсуляции this.from(json); this.name = “Marcus Aurelius”; if (this.validate()) { this.prepareToSave(); this.saveToDatabase(); }
  • 16. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Наследование ● Заменять наследование (если это возможно) ■ Делегирование или агрегация ■ Фасад ■ Адаптер ● Уменьшать иерархию наследования ● Наследоваться от интерфейсов (реализовывать их)
  • 17. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Хорошо подходит ООП ● Промышленная автоматизация ● Программирование микроконтроллеров ● Internet of Things ● Системное программирование ● Моделирование игровых миров ● Структуры данных ● Пользовательские интерфейсы
  • 18. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Плохо подходит ООП ● Прикладной код ERP (бизнес-логика) ● Сервера API ● Обработка видео и звука ● Вычисления ● Научные приложения (моделирование)
  • 19. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c ООП подходит с оговорками ● Платежные и банковские системы ● Электронная коммерция и торговля ● Сетевые протоколы (клиенты и сервера) ● Доступ к данным
  • 20. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Что не так с ООП? ● ООП во многом осталось непонятым ● Распространяет фанатизм ● Завышенные ожидания ● Нет защиты от идиотов ● Нет магии Это проблемы программистов, а не парадигмы
  • 21. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c Ссылки Objects Have Failed dreamsongs.com/Files/ObjectsHaveFailedSlides.pdf Почему ООП провалилось? blogerator.org/page/oop_why-objects-have-failed Я не знаю ООП habr.com/ru/post/147927/
  • 22. const fs = require('fs'); const compose = (...funcs) => x => funcs. reduce((x, fn) => fn(x), x); const DENSITY_COL = 3; const renderTab table => { const cellWidth = [18, 10, 8, 8, 18, 6]; return table.ma => (row.map((cell, i) => { const width = cellWidth[i]; return i ? c toString().padStart(width) : cell.padEnd(width); }).join(''))).join }; const proportion = (max, val) => Math.round(val * 100 / max); co calcProportion = table => { table.sort((row1, row2) => row2[DENSITY row1[DENSITY_COL]); const maxDensity = table[0][DENSITY_COL]; table forEach(row => { row.push(proportion(maxDensity, row[DENSITY_COL])) return table; }; const getDataset = file => { const lines = fs.read FileSync(file, 'utf8').toString().split('n'); lines.shift(); lines return lines.map(line => line.split(',')); }; const main = compose (getDataset, calcProportion, renderTable); const fs = require('fs' compose = (...funcs) => x => funcs.reduce((x, fn) => fn(x), x); con DENSITY_COL = 3; const renderTable = table => { const cellWidth = [ 8, 8, 18, 6]; return table.map(row => (row.map((cell, i) => { const = cellWidth[i]; return i ? cell.toString().padStart(width) : cell.p (width); }).join(''))).join('n'); }; const proportion = (max, val) Have Objects Failed? Или что не так с ООП? Тимур Шемсединов github.com/HowProgrammingWorks Chief Software Architect, Metarhia Kiev Polytechnic Institute, SE Infotech, MIA github.com/tshemsedinov