Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Без ОРМ
Search
Deep Refactoring
October 26, 2017
Education
480
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Без ОРМ
https://youtu.be/mb6-NHMzSkY
Deep Refactoring
October 26, 2017
Transcript
30 slides
Без ORM Иван Гришаев, 2017
Википедия is a technique for converting data between incompatible type
systems using object-oriented programming languages.
ORM, например
Что дает — абстракция над БД — упрощает процесс разработки
— объектность™
В реальности — абстракции (чаще всего) зло — база меняется
редко (и болезненно) — коллекции > объекты
SQL — создан до ООП — декларативный — не-Тьюринг полный
— решает задачи
Задача о переводе SQL в объекты... — неразрешима в принципе!
— сравнима с трансляцией языков
Примерная сложность SEL/INS/UPD/DEL + (на этом пора заканчивать) INNER/LEFT JOIN
++ WITH RECURSIVE ++++ JSON(b) ++++++++ GIS ++++++++++++++ FULLTEXT SEARCH ++++++++++++++++++++++++++++ ...
Проблемы — ORM системы сложны — внутренние API не документированы
— не спасают от raw SQL
Боязнь raw SQL — доменный язык (как HTML, CSS) —
ООП-код растет — неэффективная работа с БД
None
None
Эти ваши объекты
К чему приводит ORM — Боязнь (незнание) SQL — Хрупкость
базы — Лишний ОО-код — ORM-specific bugs
К чему приводит ORM — Зависимость — Нечитаемые запросы —
Трудно понять, что на выходе
None
None
None
None
А если будет тормозить? — Сперва добейся! — Конфигурация —
Железо — Меньше кода
Вам не нужны объекты — опасные property — нужны удобные
структуры — и функции для работы с ними — Clojure, Go, Rust
Что предлагаешь? — Построители запросов — Запросы из структур данных
— SQL-шаблоны — Генерация функций
Построители запросов
Запросы из структур данных
SQL templates
Наш проект — PostgreSQL, JDBC/Clojure — 70 таблиц — до
15 join-ов в запросах — GIS, JSONb — рекурсивные запросы
None
SQL templates
HugSQL, YeSQL — Один *.sql файл — Clojure, JS, Python,
PHP, Perl, Go, C#, Erlang, Ruby
Конец — Вопросы?
More Decks by Deep Refactoring
See All by Deep Refactoring
Поворот на 90°
deeprefactoring
0
150
Card Payments 101
deeprefactoring
0
150
Звонки на стероидах
deeprefactoring
0
150
Make Time
deeprefactoring
0
110
Learn-to-Rank или как научить бездушную машину хорошо искать
deeprefactoring
0
200
Уменьшаем количество рефлексии в коде
deeprefactoring
1
110
Прикладная кодогенерация для Java разработчика
deeprefactoring
0
470
Пишем игровой навык для Алисы Яндекс с помощью Excel
deeprefactoring
0
220
Подружиться с исключениями. Иван Гришаев, Exoscale
deeprefactoring
0
230
Other Decks in Education
See All in Education
【ainiチャット】2段階認証設定方法
ainischool
0
160
LP2627
cbtlibrary
0
200
EL GEOPARQUE MUNDIAL UNESCO VOLCANES DE CALATRAVA: DE LA INVESTIGACIÓN CIENTÍFICA A LA TRANSPOSICIÓN DIDÁCTICA EN EL AULA
juanmartin2026
0
58k
Introduction - Lecture 1 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
3.6k
1007
cbtlibrary
0
270
Evaluation Methods - Lecture 6 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
1.7k
1104
cbtlibrary
0
190
Biological Source, Chemical Constituents And Therapeutic Efficacy
pawan_pharm
0
120
Web Architectures - Lecture 2 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
1002
cbtlibrary
0
510
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 7
hiola
0
1.8k
Introduction to Primary and Secondary Metabolites their Metabolic Pathways
drpoonamkc
0
190
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
4k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
680
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Navigating Weather and Climate Data
rabernat
0
590
Test your architecture with Archunit
thirion
2
2.5k
The untapped power of vector embeddings
frankvandijk
2
2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
What the history of the web can teach us about the future of AI
inesmontani
PRO
3
800
A Soul's Torment
seathinner
9
3.9k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Code Reviewing Like a Champion
maltzj
529
40k
Building Adaptive Systems
keathley
44
3.3k