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
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
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