frontend for the win

49
FRONTEND FOR THE WIN! Антон Плешивцев, aviasales.ru

Upload: ant-pl

Post on 25-Dec-2014

239 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Frontend for the win

FRONTEND FOR THE WIN!Антон Плешивцев, aviasales.ru

Page 2: Frontend for the win

МЕТАПОИСК

Page 3: Frontend for the win

МЕТАПОИСК

Page 4: Frontend for the win

МЕТАПОИСК

Page 5: Frontend for the win

МЕТАПОИСК

Page 6: Frontend for the win

МЕТАПОИСК

Page 7: Frontend for the win
Page 8: Frontend for the win
Page 9: Frontend for the win

LEGACY

• кастомное решение

• 10К строк кода без тестов

• виджет-ориентированная архитектура

Page 10: Frontend for the win

ЖИДКОЕ ПРИЛОЖЕНИЕ

Поисковая формаПоиск

Выдача

Билеты

ФильтрыСостояние

Агенства

Фидбек

История

Календарь

Page 11: Frontend for the win

INTERFACE

Page 12: Frontend for the win

NEW AGE

• AngularJS

• 3K строк кода

• 80% покрытие тестами

Page 13: Frontend for the win

СТРУКТУРА

Page 14: Frontend for the win

СТРУКТУРАПоисковая форма

Билеты Фильтры

Page 15: Frontend for the win

СТРУКТУРАПоисковая форма

Билеты Фильтры

Форма История поисков

Календарь

Отели

Билеты

Цена

Время

Вылет

Page 16: Frontend for the win

ВЗАИМОДЕЙСТВИЕ ЧАСТЕЙ

Page 17: Frontend for the win

ВЗАИМОДЕЙСТВИЕ

Билеты

Календарь

Отели

Билеты Фильтры

Цена

Время

Вылет

?

Page 18: Frontend for the win

ВЗАИМОДЕЙСТВИЕ

Билеты

Календарь

Отели

Билеты Фильтры

Цена

Время

Вылет

service

Page 19: Frontend for the win

ВЗАИМОДЕЙСТВИЕ

Билеты Фильтры

Календарь

Отели

Билеты

Цена

Время

Вылет

«Выдача с фильтрами»

Page 20: Frontend for the win

МОДУЛИ

Page 21: Frontend for the win

MODULE PATTERNvar testModule = (function () { ! var counter = 0; ! return { ! incrementCounter: function () { return counter++; }, ! resetCounter: function () { console.log( "counter value prior to reset: " + counter ); counter = 0; } }; !})();

Page 22: Frontend for the win

AMD MODULE

//Calling define with a dependency array and a factory function define(['dep1', 'dep2'], function (dep1, dep2) { ! //Define the module value by returning a value. return function () {}; });

Page 23: Frontend for the win

DEPENDENCY INJECTION

function MyController($scope, greeter) { ! $scope.test = true; ! $scope.check = function(){ greeter.check($scope.test); }; !}

Page 24: Frontend for the win

Ядро

Page 25: Frontend for the win

Ядро

Форма поиска Выдача

Page 26: Frontend for the win

Ядро

Форма поиска Выдача

Форма История Билеты Фильтры

Page 27: Frontend for the win

Ядро

Форма поиска Выдача

Форма История Билеты Фильтры

Поиск

Календарь Отели Выдача

Цена Время

Page 28: Frontend for the win

Ядро

Форма поиска Выдача

Форма История Билеты Фильтры

Поиск

Календарь Отели Выдача

Цена Время

Page 29: Frontend for the win

Ядро

Форма поиска Выдача

Форма История Билеты Фильтры

Поиск

Календарь Отели Выдача

Цена Время

у

Page 30: Frontend for the win

Выдача

Билеты Фильтры

{ filters: {} tickets: [] }

{ tickets: [] filters: {} sort: function(){…} }

{ reset: function(){…} filters: {} tickets: [] }

Выдача Цена{ sorting: ‘price’ tickets: [] filters: {} sort: function(){…} }

{ visible: [1000, 10 000] reset: function(){} filters: {} tickets: [] }

Page 31: Frontend for the win

Выдача

Билеты Фильтры

{ filters: {} tickets: [] }

{ tickets: [] filters: {} sort: function(){…} }

{ reset: function(){…} filters: {} tickets: [] }

Выдача Цена{ sorting: ‘price’ tickets: [] filters: {} sort: function(){…} }

{ visible: [1000, 10 000] reset: function(){} filters: {} tickets: [] }

Page 32: Frontend for the win

Выдача

Билеты Фильтры

Выдача Цена$scope.filters.price = [1000, 15000]

Page 33: Frontend for the win

Выдача

Билеты Фильтры

Выдача Цена

$scope.filters.price = [1000, 15000]

$scope.filters.price = [1000, 15000]

Page 34: Frontend for the win

Выдача

Билеты Фильтры

Выдача Цена$scope.filters.price = [1000, 15000]

$scope.filters.price = [1000, 15000]

onchange(‘filters.price’, function(){ update_tickets(); })

Page 35: Frontend for the win

PITFALL

Page 36: Frontend for the win

PITFALLВыдача

Фильтры

Цена

$scope.filters = { price: [100, 10000], duration: [3600, 84600], … }

Page 37: Frontend for the win

BEFOREВыдача

Фильтры

Цена $scope.filters

$scope.filters

$scope.filters

Page 38: Frontend for the win

AFTERВыдача

Фильтры

Цена $scope.filters

$scope.filters

$scope.filters

Page 39: Frontend for the win

TEMPLATES

Page 40: Frontend for the win

UNOBTRUSIVENANO("templates.searches.tickets.widgets.proposals", function(NANO){ return NANO.templates(‘ticket.html’, { "@data-ticket-id": "ticket.id", "@data-source": "source", ".ticket_proposal": { "gate<-proposals": { ".gate_name": "gate.name", ".gate_select_button a@href": "gate.url", ".gate_select_button a@data-gate": "gate.id", ".gate_price": "gate.price", ".gate_payment_methods .payment_method": { "method<-gate.payment_methods": { "@class+": " #{method}" } } } } }); });

Page 41: Frontend for the win

DECLARATIVE

<li class="proposal-carousel" ng-repeat="proposal in ticket.proposals_for_carousel()"> <a class="agency_offer" ng-click="buy_ticket(ticket, proposal)"></a> <span>{{ proposal.name() | cut:15 }}</span> <span class="price"> <span>{{ proposal.price() | current_price:search.currency }}</span> </span> </li>

Page 42: Frontend for the win

UNOBTRUSIVElayout.find(".yes").bind("click", function(){ self.toggle(layout, "yes"); }); layout.find(".no").bind("click", function(){ self.toggle(layout, "no"); }); layout.find("#new_feedback").submit(function(){ return self._submit(); });

<form class="feedback"> <div class="yes">Да</div> <div class="no">Нет</div> ... </form>

+

Page 43: Frontend for the win

DECLARATIVE<form class="feedback" ng-submit="submit()"> <div class="yes" ng-click='success(true)'>Да</div> <div class="no" ng-click='success(false)'>Нет</div> ... </form>

Page 44: Frontend for the win

ИТОГИ

Page 45: Frontend for the win

COMPOSITE ARCHITECTURE IS POWERFUL

Page 46: Frontend for the win

PROTOTYPE INHERITANCE IS GOOD

Page 47: Frontend for the win

DECLARATIVE ALWAYS BETTER THEN IMPERATIVE

Page 48: Frontend for the win

ANGULARJS IS BETTER THAN ANYTHING ELSE

Page 49: Frontend for the win

ABOUT

АНТОН ПЛЕШИВЦЕВ !twitter.com/allaud github.com/allaud https://www.facebook.com/ant.pl.3 !aviasales.ru