SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Совершенный Ruby код
                http://goo.gl/g4uFT




                @ka8725               Андрей Колешко

суббота, 23 февраля 13 г.
Моя активность
                     Поддержка, сделал   Контрибьютор
                     с нуля
                    • redmine_s3         • locomotiveCMS
                    • get_or_build       • inherited_resources
                    • railsguides.net    • devise


суббота, 23 февраля 13 г.
Проблемы кода



суббота, 23 февраля 13 г.
Индусы
                if i.to_s.length == 1




суббота, 23 февраля 13 г.
Индусы
                if i.to_s.length == 1
                if i.is_a?(Integer) && (0 <= i && i < 10)




суббота, 23 февраля 13 г.
Китайцы
                if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i
                == 6 || i == 7 || i == 8 || i == 9)




суббота, 23 февраля 13 г.
Китайцы
                if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4 || i == 5 || i
                == 6 || i == 7 || i == 8 || i == 9)
                if 0 <= i && i < 10




суббота, 23 февраля 13 г.
Знания




суббота, 23 февраля 13 г.
Опрос хабр
              Если вы рубист, то с какого языка вы перешли на Ruby?
                  150

               112,5

                    75

                 37,5

                      0
                            PHP   Java      C#    Другой язык




суббота, 23 февраля 13 г.
Быдлокодер
                http://lurkmore.to/Быдлокодер

                    • VB, PHP, JavaScript, программирование
                            мышкой
                    • отсутствие языковой граммотности
                    • отсутствие понимание собственного кода
                    • много чего интересного по ссылке...

суббота, 23 февраля 13 г.
Проблемы архитектуры




суббота, 23 февраля 13 г.
Проектирование




суббота, 23 февраля 13 г.
Проектирование

                                       Не
                                 но!        на
                              деж             де
                            На                  жн
                                                  о!




суббота, 23 февраля 13 г.
Сложные проблемы




суббота, 23 февраля 13 г.
Cложные проблемы
                            Не идите прямо!




суббота, 23 февраля 13 г.
Проблемы тестирования




суббота, 23 февраля 13 г.
Нету тестов?
                Не беда!




суббота, 23 февраля 13 г.
Нету тестов?
                Не беда!
                Не проект!




суббота, 23 февраля 13 г.
Последствия

                    • Невозможно добавить фичу
                    • Фикс одного бага создает два бага
                    • Рефакторинг невозможен
                    • Код попахивает

суббота, 23 февраля 13 г.
Пути решения проблем




суббота, 23 февраля 13 г.
Пишите тесты

                    • В меру
                    • Научиться писать тесты = понять,
                            когда их писать не нужно
                    • http://goo.gl/1NHGU

суббота, 23 февраля 13 г.
Покрытие тестами

                    • Не стремитесь к 100% покрытию
                    • Достаточно acceptance-тестов
                    • Не тестируйте стандартные вещи,
                            плагины и т.п.
                    • Не используйте Cucumber

суббота, 23 февраля 13 г.
Какие тесты писать?


                                         Интеграционные
                                              тесты


                            Unit-тесты



суббота, 23 февраля 13 г.
Важность тестов в MVC

                    •       Модели
                    •       Контроллеры
                    • Хелперы
                    •       Отображение

                    •       Интeграционные




суббота, 23 февраля 13 г.
Kent Beck
                (создатель TDD)
                ‘Мне платят за код, который работает,
                а не за тесты.
                Моя философия - тестировать
                настолько мало, насколько это
                возможно для достижения нужного
                уровня уверенности’


суббота, 23 февраля 13 г.
Тесты после кода?
                Нет!




суббота, 23 февраля 13 г.
Тесты после кода?
                Нет!
                Да!




суббота, 23 февраля 13 г.
Пример
                class User < AR
                  validates :name, :presence => true
                end

                describe User
                  it { should validate_presence_of(:name) }
                end




суббота, 23 февраля 13 г.
Пример
                class User < AR
                  # validates :name, :presence => true
                end

                describe User
                  it { should validate_presence_of(:name) }
                end




суббота, 23 февраля 13 г.
Пример
                class User < AR
                  validates :name, :presence => true
                end

                describe User
                  it { should validate_presence_of(:name) }
                end




суббота, 23 февраля 13 г.
TDD

                                       Red




                            Refactor

                                             Green


суббота, 23 февраля 13 г.
Используйте готовые
                решения

                    • gems
                    • Шаблоны проектирования
                    • Сторонние сервисы


суббота, 23 февраля 13 г.
Парное программирование




                С котом
                Aaron Patterson (@tenderlove)

суббота, 23 февраля 13 г.
Продумывайте
                решение

                    • Консультируйтесь у знающих
                    • Вытягивайте инфу у заказчика до
                            последней мелочи
                    • Конструируйте


суббота, 23 февраля 13 г.
Переписать с нуля?




суббота, 23 февраля 13 г.
Переписать с нуля?




суббота, 23 февраля 13 г.
Переписать с нуля!
                    • Существуют все вышеописанные
                            проблемы
                    • Вы знаете проект очень хорошо
                    • Вам доставляет удовольствие
                    • Заказчик готов на это и сам просит вас
                            об этом
                      http://goo.gl/slGtV

суббота, 23 февраля 13 г.
Просвещайтесь




суббота, 23 февраля 13 г.
Прочитайте эту книгу!




суббота, 23 февраля 13 г.
Вопросы?


                @ka8725     Андрей Колешко

суббота, 23 февраля 13 г.

Weitere ähnliche Inhalte

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Complete ruby code