Slide 1

Slide 1 text

Two things I found effective when starting up a new web service Tech Talk Tokyo #2 May 24th, 2016. @necojackarc

Slide 2

Slide 2 text

Taka Software Engineer Twitter: @necojackarc GitHub: necojackarc Blog (JP): http://necojackarc.hatenablog.com/ Blog (EN): http://necojackarc.hateblo.jp/

Slide 3

Slide 3 text

Outline ○ Introducing a new web service by PIXTA ○ Sharing two effective methods which make systems more extensible: ● Immutable Data Model with additional restrictions ● Adding extra components to MVC frameworks, especially “Ruby on Rails”

Slide 4

Slide 4 text

1. Introducing a new web service The name is “fotowa”. URL: https://fotowa.com/

Slide 5

Slide 5 text

About “fotowa” III. photo shoot & online delivery II. request IV. reward I. registration Matching service between those who want to have their photos taken and photographers

Slide 6

Slide 6 text

Development of “fotowa” ○ We released the first version on February 29th, 2016. ○ It took one and a half months. ○ I needed to take care of a lot of changes because the requirements weren't fixed. ○ I found some methods which were effective to deal with frequent changes.

Slide 7

Slide 7 text

2. Extended Immutable Data Model

Slide 8

Slide 8 text

What is Immutable Data Model? ○ One of the styles of data modeling ○ In a word, forbidding updating database ● Practically, it’s almost impossible to make an application without updating any data. ● So, it’s okay to just try and exclude as much update as possible.

Slide 9

Slide 9 text

Benefits of Immutable Data Model ○ Keeping your data model simple ● Updating usually causes complexity. ○ Making your design open to change ● You can easily extend and modify the design. ○ Making your database robust

Slide 10

Slide 10 text

Let’s apply additional restrictions!

Slide 11

Slide 11 text

Additional restrictions They improve your database much more! ○ Never updating records (already adopted) ○ Never deleting records ○ No null columns ○ No deleted flags The more restrictions you apply, the more improvements you (might be able to) get :)

Slide 12

Slide 12 text

3. Adding extra components to Rails

Slide 13

Slide 13 text

Brief introduction of Ruby on Rails ○ It’s a MVC framework. ● It originally has three components that are models, controllers and views. ○ Developers often suffer from “fat stuff”. ● Since Rails has only three components, developers tend to put “all business logic” on controllers or models. It causes fat models or fat controllers.

Slide 14

Slide 14 text

“ You may be thinking: “But Rails makes it really hard to do OOP right!” from “7 Patterns to Refactor Fat ActiveRecord Models”

Slide 15

Slide 15 text

It’s not true. Adding extras solves these problems.

Slide 16

Slide 16 text

● Decorators ● Errors ● Forms ● Lib ● Observers ● Parameters ● Serializers ● Services ● Uploaders Components I actually added

Slide 17

Slide 17 text

It enables you to apply Single Responsibility Principle.

Slide 18

Slide 18 text

Conclusion ○ Extended Immutable Data Model makes your database open to change. ○ Adding extra components enables you to follow Single Responsibility Principle which makes your application open to change.

Slide 19

Slide 19 text

Changes are inevitable  Let’s prepare for changes!

Slide 20

Slide 20 text

References ○ イミュータブルデータモデル(入門編) ● http://www.slideshare.net/kawasima/ss-40471672 ○ SIerにおけるDBAのしごと ● http://qiita.com/kawasima/items/7eafd8406866f9d6e91b ○ 7 Patterns to Refactor Fat ActiveRecord Models ● http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decomp ose-fat-activerecord-models/ ○ 肥大化したActiveRecordモデルをリファクタリングする7つの方法(翻訳) ● http://techracho.bpsinc.jp/hachi8833/2013_11_19/14738

Slide 21

Slide 21 text

THANKS!