SlideShare a Scribd company logo
1 of 16
Download to read offline
© 2016 Rocketrip, Inc. Confidential
Scalable Code Design
with slimmer Django models … and more
Dawa L. Sherpa
@dawalama
Lead Engineer, Rocketrip
© 2016 Rocketrip, Inc. Confidential
Rocketrip Clients Rewarding Employees for Great Behaviors
30% Average savings by
employees on travel.
© 2016 Rocketrip, Inc. Confidential
What is a Scalable Code Design ?
Why should we think about Scalable Code Design ?
What is your scalable code strategy ?
© 2016 Rocketrip, Inc. Confidential
Let’s define: Code Scalability Co-efficient (S)
T = Team Productivity
S = Scalability Co-efficient
N = Number of Engineers
I = Individual engineer’s
productivity
We can achieve code
scalability by increasing S
and I
=
T3 S =Ix x
T = S * ( N * I )
© 2016 Rocketrip, Inc. Confidential
S
I
Culture
Product
Management
Code
Architecture
Team Org
Tooling &
Process
© 2016 Rocketrip, Inc. Confidential
Where can we look to re-claim lost productivity ?
Productivity Leaks
Bugs & Refactoring [ Code design ]
Finding code [ Code design / tools ]
Checking & Testing work [ tools ]
Waiting [ conflict resolution, clarification etc. Code
design / tools ]
Others ( Meetings / task management etc )
Code
Architecture
Process &
Tooling
© 2016 Rocketrip, Inc. Confidential
Human vs Automan
✓ Econ vs Human : Richard H. Thaler, author of
Nudge/Misbehaving. Econ is rational, human is
not always rational.
✓ Automan vs Human : Automan is super logical,
human is mostly logical with human traits.
✓ Design architecture and process with human traits
in mind to improve productivity.
✓ Measure and question how engineers *feel* about
working on your code base ?
✓ Anxious
✓ Irritated
✓ Overwhelmed
© 2016 Rocketrip, Inc. Confidential
Improving S & I
✓ Decouple Code ( +S, +I, confidence, simpler, parallel work)
✓ Make code discoverable ( +S, +I, independence )
✓ Make code readable ( +S, +I, context, confidence)
✓ Make code testable (+S, +I, confidence, refactor, doc) *
✓ Show engineers system feedback ( +S, +I, confidence )
✓ Code can be reasoned about ( +S, confidence, speed)
✓ Engineers can deploy their completed tasks to production
system independently of unfinished work by others. ( +S, +I,
parallel work )
© 2016 Rocketrip, Inc. Confidential
Resources
Services
Rt Stack - Year ago
Django 1.5
MysqlApp App
App
Redis
External APIs
App App
Celery
RabbitMQ
© 2016 Rocketrip, Inc. Confidential
Services
RT Stack - Now
Django 1.9
Celery
Mysql
App App
App
Redis
External APIs
App App
React
SPA
SPA
SPA
SPA
API
Resources
© 2016 Rocketrip, Inc. Confidential
Example Django Fat Model
class Employee(db.Model):
…<field definitions>
…<managers>
…<property functions>
… activate helper functions
… account helper functions
… feature-x helper functions
… helper’s helper functions
class Employee(db.Model):
…<field definitions>
…<managers>
…<property functions>
… activate helper functions
… account helper functions
… feature-x helper functions
… helper’s helper functions
class Employee(db.Model):
…<field definitions>
…<managers>
…<property functions>
… activate helper functions
… account helper functions
… feature-x helper functions
… helper’s helper functions
fat-models.py
© 2016 Rocketrip, Inc. Confidential
Problems with Big Fat Django Models
✓ Everything is in one place. This is easier at first, but as your
software’s complexity increases, the contextual overload for the
engineering also increases exponentially.
✓ Data model and functionality is mixed. This marriage of data with
functionality makes sense if your application stays fairly simple and
small, but over time it becomes harder to refactor and understand.
✓ Easier to leak business logic into views, because it feels like views
are boilerplate using functions defined in your models.
✓ Your code structure does not distinguish features and functionality
of business systems. This adds translation complexity.
© 2016 Rocketrip, Inc. Confidential
Feature/Domain/Services
Example Django Slim Model Suggestion
class Employee(db.Model):
…<field definitions>
…<managers>
employee_account.py
…<related property functions>
… activate_account
… deactivate_account
… invite_user
employee_communication.py
…<related property functions>
… send_email
… send_txt_msg

… get_recent_messages
class Employee(db.Model):
…<field definitions>
…<managers>
…<property functions>
… activate helper functions
… account helper functions
… feature-x helper functions
… helper’s helper functions
employee_account_test.py
… test_activate_account
… test_deactivate_account
… test_invite_user
employee_communication_t
est.py
… test_send_email
… test_send_txt_msg
employee_common.py
…<related property functions>
… helper functions
employee_common_test.py
… test_common_func1
© 2016 Rocketrip, Inc. Confidential
Scalable Code : Human vs Automan
✓ Engineers can quickly conceptualize what the code is doing
• Readability ( Structure, Comments, Documentation,
Convention )
• Discoverability and inference ( Structure and Convention )
• Code can be reasoned about
✓ Engineers can evolve the system
• Refactor
• Visibility ( See the impact of their changes )
• Testability ( Validate assumptions for known states )
• Lose coupling, and grouping of logically related code
© 2016 Rocketrip, Inc. Confidential
Django x
RT Stack - Future - Microservices and beyond
Django x
Services
Django x
Celery
Mysql
App
Redis
External APIs
SPAAPI
Resources
Thank you
https://www.rocketrip.com/jobs

More Related Content

Similar to Scalable code Design with slimmer Django models .. and more

Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureGapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureAlberto Diaz Martin
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Amazon Web Services
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017adapt1362
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017adapt1291
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017adapt1328
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Amazon Web Services
 
Read Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitte
Read Curriculum vitae of Shwetabh Kumar as Project Manager at DeloitteRead Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitte
Read Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitteshwetabhkumar
 
Bayapa_Tibco_Mule_Resume
Bayapa_Tibco_Mule_ResumeBayapa_Tibco_Mule_Resume
Bayapa_Tibco_Mule_ResumeCsb Reddy
 
Architecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons LearnedArchitecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons LearnedJoão Pedro Martins
 
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...Splunk
 
Software engineering practices for the data science and machine learning life...
Software engineering practices for the data science and machine learning life...Software engineering practices for the data science and machine learning life...
Software engineering practices for the data science and machine learning life...DataWorks Summit
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedJoão Pedro Martins
 
Resume of Shwetabh Kumar, Project Manager at Deloitte
Resume of Shwetabh Kumar, Project Manager at DeloitteResume of Shwetabh Kumar, Project Manager at Deloitte
Resume of Shwetabh Kumar, Project Manager at Deloitteshwetabhkumar
 
Bluegranite AA Webinar FINAL 28JUN16
Bluegranite AA Webinar FINAL 28JUN16Bluegranite AA Webinar FINAL 28JUN16
Bluegranite AA Webinar FINAL 28JUN16Andy Lathrop
 
Airflow techtonic template
Airflow   techtonic templateAirflow   techtonic template
Airflow techtonic templateSampath Kumar
 
Iman Mukhopadhyay_Resume
Iman Mukhopadhyay_ResumeIman Mukhopadhyay_Resume
Iman Mukhopadhyay_ResumeIman Mukherjee
 
Data Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksData Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksAmazon Web Services
 
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...James Anderson
 

Similar to Scalable code Design with slimmer Django models .. and more (20)

Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en AzureGapand 2017 - Diseñando Arquitecturas Serverless en Azure
Gapand 2017 - Diseñando Arquitecturas Serverless en Azure
 
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
Build Deep Learning Applications Using Apache MXNet, Featuring Workday (AIM40...
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017
 
Adapt software introduction jan2017
Adapt software introduction  jan2017Adapt software introduction  jan2017
Adapt software introduction jan2017
 
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
Build Deep Learning Applications Using Apache MXNet - Featuring Chick-fil-A (...
 
Read Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitte
Read Curriculum vitae of Shwetabh Kumar as Project Manager at DeloitteRead Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitte
Read Curriculum vitae of Shwetabh Kumar as Project Manager at Deloitte
 
Bayapa_Tibco_Mule_Resume
Bayapa_Tibco_Mule_ResumeBayapa_Tibco_Mule_Resume
Bayapa_Tibco_Mule_Resume
 
Architecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons LearnedArchitecting a Large Software Project - Lessons Learned
Architecting a Large Software Project - Lessons Learned
 
Resume
ResumeResume
Resume
 
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...
Data-Driven DevOps: Mining Machine Data for 'Metrics that Matter' in a DevOps...
 
Software engineering practices for the data science and machine learning life...
Software engineering practices for the data science and machine learning life...Software engineering practices for the data science and machine learning life...
Software engineering practices for the data science and machine learning life...
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
 
AX_srinivas_ TechM
AX_srinivas_ TechMAX_srinivas_ TechM
AX_srinivas_ TechM
 
Resume of Shwetabh Kumar, Project Manager at Deloitte
Resume of Shwetabh Kumar, Project Manager at DeloitteResume of Shwetabh Kumar, Project Manager at Deloitte
Resume of Shwetabh Kumar, Project Manager at Deloitte
 
Bluegranite AA Webinar FINAL 28JUN16
Bluegranite AA Webinar FINAL 28JUN16Bluegranite AA Webinar FINAL 28JUN16
Bluegranite AA Webinar FINAL 28JUN16
 
Airflow techtonic template
Airflow   techtonic templateAirflow   techtonic template
Airflow techtonic template
 
Iman Mukhopadhyay_Resume
Iman Mukhopadhyay_ResumeIman Mukhopadhyay_Resume
Iman Mukhopadhyay_Resume
 
Data Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech TalksData Transformation Patterns in AWS - AWS Online Tech Talks
Data Transformation Patterns in AWS - AWS Online Tech Talks
 
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...
GDG Cloud Southlake 31: Santosh Chennuri and Festus Yeboah: Empowering Develo...
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

Scalable code Design with slimmer Django models .. and more

  • 1. © 2016 Rocketrip, Inc. Confidential Scalable Code Design with slimmer Django models … and more Dawa L. Sherpa @dawalama Lead Engineer, Rocketrip
  • 2. © 2016 Rocketrip, Inc. Confidential Rocketrip Clients Rewarding Employees for Great Behaviors 30% Average savings by employees on travel.
  • 3. © 2016 Rocketrip, Inc. Confidential What is a Scalable Code Design ? Why should we think about Scalable Code Design ? What is your scalable code strategy ?
  • 4. © 2016 Rocketrip, Inc. Confidential Let’s define: Code Scalability Co-efficient (S) T = Team Productivity S = Scalability Co-efficient N = Number of Engineers I = Individual engineer’s productivity We can achieve code scalability by increasing S and I = T3 S =Ix x T = S * ( N * I )
  • 5. © 2016 Rocketrip, Inc. Confidential S I Culture Product Management Code Architecture Team Org Tooling & Process
  • 6. © 2016 Rocketrip, Inc. Confidential Where can we look to re-claim lost productivity ? Productivity Leaks Bugs & Refactoring [ Code design ] Finding code [ Code design / tools ] Checking & Testing work [ tools ] Waiting [ conflict resolution, clarification etc. Code design / tools ] Others ( Meetings / task management etc ) Code Architecture Process & Tooling
  • 7. © 2016 Rocketrip, Inc. Confidential Human vs Automan ✓ Econ vs Human : Richard H. Thaler, author of Nudge/Misbehaving. Econ is rational, human is not always rational. ✓ Automan vs Human : Automan is super logical, human is mostly logical with human traits. ✓ Design architecture and process with human traits in mind to improve productivity. ✓ Measure and question how engineers *feel* about working on your code base ? ✓ Anxious ✓ Irritated ✓ Overwhelmed
  • 8. © 2016 Rocketrip, Inc. Confidential Improving S & I ✓ Decouple Code ( +S, +I, confidence, simpler, parallel work) ✓ Make code discoverable ( +S, +I, independence ) ✓ Make code readable ( +S, +I, context, confidence) ✓ Make code testable (+S, +I, confidence, refactor, doc) * ✓ Show engineers system feedback ( +S, +I, confidence ) ✓ Code can be reasoned about ( +S, confidence, speed) ✓ Engineers can deploy their completed tasks to production system independently of unfinished work by others. ( +S, +I, parallel work )
  • 9. © 2016 Rocketrip, Inc. Confidential Resources Services Rt Stack - Year ago Django 1.5 MysqlApp App App Redis External APIs App App Celery RabbitMQ
  • 10. © 2016 Rocketrip, Inc. Confidential Services RT Stack - Now Django 1.9 Celery Mysql App App App Redis External APIs App App React SPA SPA SPA SPA API Resources
  • 11. © 2016 Rocketrip, Inc. Confidential Example Django Fat Model class Employee(db.Model): …<field definitions> …<managers> …<property functions> … activate helper functions … account helper functions … feature-x helper functions … helper’s helper functions class Employee(db.Model): …<field definitions> …<managers> …<property functions> … activate helper functions … account helper functions … feature-x helper functions … helper’s helper functions class Employee(db.Model): …<field definitions> …<managers> …<property functions> … activate helper functions … account helper functions … feature-x helper functions … helper’s helper functions fat-models.py
  • 12. © 2016 Rocketrip, Inc. Confidential Problems with Big Fat Django Models ✓ Everything is in one place. This is easier at first, but as your software’s complexity increases, the contextual overload for the engineering also increases exponentially. ✓ Data model and functionality is mixed. This marriage of data with functionality makes sense if your application stays fairly simple and small, but over time it becomes harder to refactor and understand. ✓ Easier to leak business logic into views, because it feels like views are boilerplate using functions defined in your models. ✓ Your code structure does not distinguish features and functionality of business systems. This adds translation complexity.
  • 13. © 2016 Rocketrip, Inc. Confidential Feature/Domain/Services Example Django Slim Model Suggestion class Employee(db.Model): …<field definitions> …<managers> employee_account.py …<related property functions> … activate_account … deactivate_account … invite_user employee_communication.py …<related property functions> … send_email … send_txt_msg
 … get_recent_messages class Employee(db.Model): …<field definitions> …<managers> …<property functions> … activate helper functions … account helper functions … feature-x helper functions … helper’s helper functions employee_account_test.py … test_activate_account … test_deactivate_account … test_invite_user employee_communication_t est.py … test_send_email … test_send_txt_msg employee_common.py …<related property functions> … helper functions employee_common_test.py … test_common_func1
  • 14. © 2016 Rocketrip, Inc. Confidential Scalable Code : Human vs Automan ✓ Engineers can quickly conceptualize what the code is doing • Readability ( Structure, Comments, Documentation, Convention ) • Discoverability and inference ( Structure and Convention ) • Code can be reasoned about ✓ Engineers can evolve the system • Refactor • Visibility ( See the impact of their changes ) • Testability ( Validate assumptions for known states ) • Lose coupling, and grouping of logically related code
  • 15. © 2016 Rocketrip, Inc. Confidential Django x RT Stack - Future - Microservices and beyond Django x Services Django x Celery Mysql App Redis External APIs SPAAPI Resources