SlideShare una empresa de Scribd logo
1 de 36
Creating a reasonable
project boilerplate
A walking skeleton for development;
About me
● Graduated Software Engineering in Sofia University
● Working professionally as a Software Engineer for 13 years
● Specialize in Backend development
● I work as a Software Architect in the last 1 year
● Interested in
○ High-quality work and code
○ Best practices
○ Design Patterns
○ Simplicity and elegance
○ Principles and concepts
Ice Breaker
Silicon Valley video
Ice Breaker
Vi(m) vs Emacs
Java vs .Net
Intellij IDEA vs Eclipse vs Netbeans vs Visual Studio vs VS code vs Sublime vs ...
OOP vs FP
Javascript vs Typescript
Python CPython vs Jython vs IronPython vs PyPy vs more
Ice Breaker
● What is boilerplate?
● Common setup steps
● Common build steps
● Practices to ensure efficient
development
● Tools
● Python demo
Agenda
● Common practices used in
local development
environment.
● Unit testing
● Compare dev tools between
Python, Java, Javascript
● Demo python backend project
● Brief PyCharm/Intellij Ultimate
IDE setup
In scope
● Version control system
○ Branching strategy
● Continuous Integration (CI)
● Continuous Deployment (CD)
● Code review process
● Infrastructure setup - DBs, In-
memory caches, etc.
● Higher-level tests - functional
testing, load/stress testing,
penetration testing
● Authentication & Authorization
● Monitoring, profiling, tracing
● Logging
● Security scanning
Out of scope
What is boilerplate?
In Information Technology, a boilerplate is a unit of writing that can be reused
over and over without change. By extension, the idea is sometimes applied to
reusable programming, as in “boilerplate code.” (by Meet Zaveri)
Disclaimer
There are tens of thousands of project boilerplates out there.
I present my own preference for a good project boilerplate.
Initial project directory structure
├───scripts
├───src
├───tests
├───.gitignore
└───README.md
- Contain build scripts
- Contain main code
- Contain test code (src/test in Java)
Install necessary SDKs
Python Java Javascript
Python Interpreter JDK NodeJS
What if you need to have different versions for a particular SDK on your PC?
Python Java Javascript
pyenv ● Env vars with
symlinks
● SDKMan
NVM
Install IDE
Install IDE
Python Java Javascript
● PyCharm / Intellij IDEA
Ultimate
● VS Code
● Intellij IDEA
● VS Code
● Webstorm / Intellij IDEA
Ultimate
● VS Code
Project dependency management
source
Project dependency management
by xkcd
Project dependency management
Python Java Javascript
● pip & venv
● pipenv
● poetry
● conda
● Maven
● Gradle
● npm
● yarn
Responsibility of a dependency management tool:
1. Install missing dependencies.
2. Install transitive dependencies.
3. Add/remove/update a dependency.
4. Automatic version conflict resolution for the shared dependencies.
Project build orchestration tool
Python Java Javascript
● GNU make
● pypyr
● Maven
● Gradle
● npm
● yarn
Responsibility of a build orchestration tool:
1. Convenient shortcut for triggering a build step.
2. Run multiple steps in sequence (task chaining).
Follow coding standards and guidelines
Python Java Javascript
● PEP 8
● Google Guide
Google Java Style Guide ● Airbnb JS style guide
● Google JS style guide
Follow coding standards and guidelines
Python Java Javascript
● Pylint
● Flake8
● Sonarlint / Sonarqube
● SpotBugs (earlier
FindBugs)
● PMD
● CheckStyle
● ErrorProne
● Sonarlint / Sonarqube
● ESLint
● Sonarlint / Sonarqube
Linter - A tool that automatically checks for compliance with the coding standards, style guides,
naming conventions, indentation and spacing aka Static Code Analysis.
Bonus features - detect code smells, unused vars/imports, dead code, common bugs
Ensure consistent code formatting
Python Java Javascript
isort
black
Google yapf
Google code formatter (in and
out of IDE)
● eslint
● prettier
Strong type checks
Python Java Javascript
mypy Java compiler ● Flow
● Hegel
Unit Testing framework and runner
Python Java Javascript
Pytest + unittest.mock Junit + Mockito / PowerMock /
EasyMock / jMock / jMockIt
● Jest
● Jasmine / Karma
● Mocha
● Cypress
Code coverage
Python Java Javascript
Coverage.py (or pytest-cov
plugin)
Jacoco (other tools) Jest
Pre-commit hook
● Make your modified files to conform to the project standards
○ Format changes.
○ Runs static code analysis.
○ Runs strong type checks.
○ Runs unit tests and ensure reasonable coverage percentage (>= 100%)
● If some of the checks fails, you cannot commit and you are forced to fix your code.
● Disadvantage 1 - pre-commit hook can be skipped easily. That’s why we need to run
the same checks on the CI server once the code has been pushed. Pull request is a
good phase to run such checks.
● Disadvantage 2 - pre-commit hook can slow down your (work)flow. (resource)
Pre-commit hook implementation
● Use pre-commit framework (supported languages & libraries) - does not integrate well
in monorepo setup.
● Implement your own pre-commit script - stick to Posix standard to ensure your pre-
commit works on all platforms - Windows, Linux distro, Mac OSx
Configuration injection
Python Java Javascript
python-dotenv
environs
pydantic
dotenv-java dotenv
Resource:
● The 12 factor app - Config
Containerization
1. Single docker container - docker run
2. Docker compose
3. Docker swarm
4. Kubernetes
...
source
Demo
Python boilerplate setup
SDK pyenv-win
IDE Intellij Ultimate
Dependency Management poetry
Build orchestration make
Linter pylint, isort, black
Code formatter isort, black
Type checker mypy
Unit testing pytest + unittest.mock
Coverage pytest-cov (wrapper of
Coverage.py)
Python boilerplate setup
Configuration Injection pydantic
Containerization Single docker container
The demo project can be seen in https://github.com/stapetro/demo-tpl-py repo.
Python boilerplate the right way to do it
● If you are sure that all existing Python project templates are not that good or don’t fit your
neeed, then you can create your own project template.
● If you do a cool project template, please share it with the community - open source it.
● Many python practitioners adopted cookiecutter for creating and using project
templates.
● My linkedin profile -
https://www.linkedin.com/in/stani
slav-petrov-8b07a117/
● Twitter - sipetrov
● Personal blog -
https://stapetro.github.io/
● Email -
stanislav.i.petrov@gmail.com
Contacts
● Seek first for well-known and
proved existing project boilerplate
● Design your directory layout
● Identify software tools
○ IDE
○ SDK
○ OS
● Define your build steps
○ Dependency Management
○ Coding Standards & Guidelines
○ Code formatting
○ Static Code Analysis (linter)
○ Type checking (for dynamic langs)
○ Run / Debug code
○ Configuration Injection
○ Containerization
● There are many other aspects -
Auth&Auth, logging, monitoring, ...
Wrap-up
Resources
● Understenad Python best practices by evaluating project templates
● My Ideas are inspired by FastApi Project Generation - Template (thx to tiangolo)
● The Twelve-Factor app
Review
Questions?
Answers.

Más contenido relacionado

La actualidad más candente

It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecGiulio De Donato
 
Behaviour Driven Development Hands-on
Behaviour Driven Development Hands-onBehaviour Driven Development Hands-on
Behaviour Driven Development Hands-onHemmerling
 
Test Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellTest Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellHemmerling
 
Testing cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestTesting cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestMicael Gallego
 
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOpsBaruch Sadogursky
 
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Baruch Sadogursky
 
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...DevOpsDays Riga
 
vodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As codevodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As codevodQA
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y GradleAntonio Mas
 
Simple Pure Java
Simple Pure JavaSimple Pure Java
Simple Pure JavaAnton Keks
 
Introduction to Spock: A Unit Testing Framework
Introduction to Spock: A Unit Testing FrameworkIntroduction to Spock: A Unit Testing Framework
Introduction to Spock: A Unit Testing FrameworkKnoldus Inc.
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabRon Munitz
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.aviSeongJae Park
 
Trunk-Based Development
Trunk-Based DevelopmentTrunk-Based Development
Trunk-Based DevelopmentBryan Liu
 
TDD with Python and App Engine
TDD with Python and App EngineTDD with Python and App Engine
TDD with Python and App EngineRicardo Bánffy
 
Open Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up IntroOpen Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up IntroSkills Matter
 
Test Engineering on Mobage
Test Engineering on MobageTest Engineering on Mobage
Test Engineering on MobageMasaki Nakagawa
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsPerforce
 

La actualidad más candente (20)

It's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspecIt's all about behaviour, also in php - phpspec
It's all about behaviour, also in php - phpspec
 
Behaviour Driven Development Hands-on
Behaviour Driven Development Hands-onBehaviour Driven Development Hands-on
Behaviour Driven Development Hands-on
 
Test Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShellTest Driven Development (TDD) with Windows PowerShell
Test Driven Development (TDD) with Windows PowerShell
 
Testing cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTestTesting cloud and kubernetes applications - ElasTest
Testing cloud and kubernetes applications - ElasTest
 
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
[Webinar] The Frog And The Butler: CI Pipelines For Modern DevOps
 
Automatic Test 2019-07-25
Automatic Test 2019-07-25Automatic Test 2019-07-25
Automatic Test 2019-07-25
 
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
Patterns and antipatterns in Docker image lifecycle as was presented at DC Do...
 
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...
DevOpsDaysRiga 2018: Neil Crawford - Trunk based development, continuous depl...
 
vodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As codevodQA Pune (2019) - Jenkins pipeline As code
vodQA Pune (2019) - Jenkins pipeline As code
 
Spring-batch Groovy y Gradle
Spring-batch Groovy y GradleSpring-batch Groovy y Gradle
Spring-batch Groovy y Gradle
 
Simple Pure Java
Simple Pure JavaSimple Pure Java
Simple Pure Java
 
Introduction to Spock: A Unit Testing Framework
Introduction to Spock: A Unit Testing FrameworkIntroduction to Spock: A Unit Testing Framework
Introduction to Spock: A Unit Testing Framework
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
Kshitij
KshitijKshitij
Kshitij
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
 
Trunk-Based Development
Trunk-Based DevelopmentTrunk-Based Development
Trunk-Based Development
 
TDD with Python and App Engine
TDD with Python and App EngineTDD with Python and App Engine
TDD with Python and App Engine
 
Open Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up IntroOpen Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up Intro
 
Test Engineering on Mobage
Test Engineering on MobageTest Engineering on Mobage
Test Engineering on Mobage
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and Economics
 

Similar a Creating a reasonable project boilerplate

Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodeKris Buytaert
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTWaqqas Jabbar
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development PipelineGlobalLogic Ukraine
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeWaqqas Jabbar
 
Complete python toolbox for modern developers
Complete python toolbox for modern developersComplete python toolbox for modern developers
Complete python toolbox for modern developersJan Giacomelli
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHPRogério Vicente
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integrationhaochenglee
 
Making your app soar without a container manifest
Making your app soar without a container manifestMaking your app soar without a container manifest
Making your app soar without a container manifestLibbySchulze
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinatingAntonio Goncalves
 
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...MarcinStachniuk
 
Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Lorna Mitchell
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering TeamsLars Thorup
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet codewzzrd
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Борис Зора
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with DjangoRoger Barnes
 

Similar a Creating a reasonable project boilerplate (20)

Pipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as CodePipeline as code for your infrastructure as Code
Pipeline as code for your infrastructure as Code
 
Introduction to react native @ TIC NUST
Introduction to react native @ TIC NUSTIntroduction to react native @ TIC NUST
Introduction to react native @ TIC NUST
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
 
Complete python toolbox for modern developers
Complete python toolbox for modern developersComplete python toolbox for modern developers
Complete python toolbox for modern developers
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
Test Driven Development with PHP
Test Driven Development with PHPTest Driven Development with PHP
Test Driven Development with PHP
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
 
Making your app soar without a container manifest
Making your app soar without a container manifestMaking your app soar without a container manifest
Making your app soar without a container manifest
 
What is dev ops?
What is dev ops?What is dev ops?
What is dev ops?
 
CI
CICI
CI
 
Are app servers still fascinating
Are app servers still fascinatingAre app servers still fascinating
Are app servers still fascinating
 
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...
Java Web Start czyli jak żyć z tą dziwną technologią? & Continuous Delivery w...
 
Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)Passing the Joel Test in the PHP World (phpbnl10)
Passing the Joel Test in the PHP World (phpbnl10)
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
 
Code review and automated testing for Puppet code
Code review and automated testing for Puppet codeCode review and automated testing for Puppet code
Code review and automated testing for Puppet code
 
Continuous testing
Continuous testingContinuous testing
Continuous testing
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
 
Towards Continuous Deployment with Django
Towards Continuous Deployment with DjangoTowards Continuous Deployment with Django
Towards Continuous Deployment with Django
 

Último

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 

Último (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 

Creating a reasonable project boilerplate

  • 1. Creating a reasonable project boilerplate A walking skeleton for development;
  • 2. About me ● Graduated Software Engineering in Sofia University ● Working professionally as a Software Engineer for 13 years ● Specialize in Backend development ● I work as a Software Architect in the last 1 year ● Interested in ○ High-quality work and code ○ Best practices ○ Design Patterns ○ Simplicity and elegance ○ Principles and concepts
  • 4. Ice Breaker Vi(m) vs Emacs Java vs .Net Intellij IDEA vs Eclipse vs Netbeans vs Visual Studio vs VS code vs Sublime vs ... OOP vs FP Javascript vs Typescript Python CPython vs Jython vs IronPython vs PyPy vs more
  • 6. ● What is boilerplate? ● Common setup steps ● Common build steps ● Practices to ensure efficient development ● Tools ● Python demo Agenda
  • 7. ● Common practices used in local development environment. ● Unit testing ● Compare dev tools between Python, Java, Javascript ● Demo python backend project ● Brief PyCharm/Intellij Ultimate IDE setup In scope
  • 8. ● Version control system ○ Branching strategy ● Continuous Integration (CI) ● Continuous Deployment (CD) ● Code review process ● Infrastructure setup - DBs, In- memory caches, etc. ● Higher-level tests - functional testing, load/stress testing, penetration testing ● Authentication & Authorization ● Monitoring, profiling, tracing ● Logging ● Security scanning Out of scope
  • 9. What is boilerplate? In Information Technology, a boilerplate is a unit of writing that can be reused over and over without change. By extension, the idea is sometimes applied to reusable programming, as in “boilerplate code.” (by Meet Zaveri)
  • 10. Disclaimer There are tens of thousands of project boilerplates out there. I present my own preference for a good project boilerplate.
  • 11. Initial project directory structure ├───scripts ├───src ├───tests ├───.gitignore └───README.md - Contain build scripts - Contain main code - Contain test code (src/test in Java)
  • 12. Install necessary SDKs Python Java Javascript Python Interpreter JDK NodeJS What if you need to have different versions for a particular SDK on your PC? Python Java Javascript pyenv ● Env vars with symlinks ● SDKMan NVM
  • 14. Install IDE Python Java Javascript ● PyCharm / Intellij IDEA Ultimate ● VS Code ● Intellij IDEA ● VS Code ● Webstorm / Intellij IDEA Ultimate ● VS Code
  • 17. Project dependency management Python Java Javascript ● pip & venv ● pipenv ● poetry ● conda ● Maven ● Gradle ● npm ● yarn Responsibility of a dependency management tool: 1. Install missing dependencies. 2. Install transitive dependencies. 3. Add/remove/update a dependency. 4. Automatic version conflict resolution for the shared dependencies.
  • 18. Project build orchestration tool Python Java Javascript ● GNU make ● pypyr ● Maven ● Gradle ● npm ● yarn Responsibility of a build orchestration tool: 1. Convenient shortcut for triggering a build step. 2. Run multiple steps in sequence (task chaining).
  • 19. Follow coding standards and guidelines Python Java Javascript ● PEP 8 ● Google Guide Google Java Style Guide ● Airbnb JS style guide ● Google JS style guide
  • 20. Follow coding standards and guidelines Python Java Javascript ● Pylint ● Flake8 ● Sonarlint / Sonarqube ● SpotBugs (earlier FindBugs) ● PMD ● CheckStyle ● ErrorProne ● Sonarlint / Sonarqube ● ESLint ● Sonarlint / Sonarqube Linter - A tool that automatically checks for compliance with the coding standards, style guides, naming conventions, indentation and spacing aka Static Code Analysis. Bonus features - detect code smells, unused vars/imports, dead code, common bugs
  • 21. Ensure consistent code formatting Python Java Javascript isort black Google yapf Google code formatter (in and out of IDE) ● eslint ● prettier
  • 22. Strong type checks Python Java Javascript mypy Java compiler ● Flow ● Hegel
  • 23. Unit Testing framework and runner Python Java Javascript Pytest + unittest.mock Junit + Mockito / PowerMock / EasyMock / jMock / jMockIt ● Jest ● Jasmine / Karma ● Mocha ● Cypress
  • 24. Code coverage Python Java Javascript Coverage.py (or pytest-cov plugin) Jacoco (other tools) Jest
  • 25. Pre-commit hook ● Make your modified files to conform to the project standards ○ Format changes. ○ Runs static code analysis. ○ Runs strong type checks. ○ Runs unit tests and ensure reasonable coverage percentage (>= 100%) ● If some of the checks fails, you cannot commit and you are forced to fix your code. ● Disadvantage 1 - pre-commit hook can be skipped easily. That’s why we need to run the same checks on the CI server once the code has been pushed. Pull request is a good phase to run such checks. ● Disadvantage 2 - pre-commit hook can slow down your (work)flow. (resource)
  • 26. Pre-commit hook implementation ● Use pre-commit framework (supported languages & libraries) - does not integrate well in monorepo setup. ● Implement your own pre-commit script - stick to Posix standard to ensure your pre- commit works on all platforms - Windows, Linux distro, Mac OSx
  • 27. Configuration injection Python Java Javascript python-dotenv environs pydantic dotenv-java dotenv Resource: ● The 12 factor app - Config
  • 28. Containerization 1. Single docker container - docker run 2. Docker compose 3. Docker swarm 4. Kubernetes ... source
  • 29. Demo
  • 30. Python boilerplate setup SDK pyenv-win IDE Intellij Ultimate Dependency Management poetry Build orchestration make Linter pylint, isort, black Code formatter isort, black Type checker mypy Unit testing pytest + unittest.mock Coverage pytest-cov (wrapper of Coverage.py)
  • 31. Python boilerplate setup Configuration Injection pydantic Containerization Single docker container The demo project can be seen in https://github.com/stapetro/demo-tpl-py repo.
  • 32. Python boilerplate the right way to do it ● If you are sure that all existing Python project templates are not that good or don’t fit your neeed, then you can create your own project template. ● If you do a cool project template, please share it with the community - open source it. ● Many python practitioners adopted cookiecutter for creating and using project templates.
  • 33. ● My linkedin profile - https://www.linkedin.com/in/stani slav-petrov-8b07a117/ ● Twitter - sipetrov ● Personal blog - https://stapetro.github.io/ ● Email - stanislav.i.petrov@gmail.com Contacts
  • 34. ● Seek first for well-known and proved existing project boilerplate ● Design your directory layout ● Identify software tools ○ IDE ○ SDK ○ OS ● Define your build steps ○ Dependency Management ○ Coding Standards & Guidelines ○ Code formatting ○ Static Code Analysis (linter) ○ Type checking (for dynamic langs) ○ Run / Debug code ○ Configuration Injection ○ Containerization ● There are many other aspects - Auth&Auth, logging, monitoring, ... Wrap-up
  • 35. Resources ● Understenad Python best practices by evaluating project templates ● My Ideas are inspired by FastApi Project Generation - Template (thx to tiangolo) ● The Twelve-Factor app

Notas del editor

  1. Project smells - production bugs, failed daily builds, buggy tests