Inspired by David Bordeynik’s lecture on PyWeb-IL meetup.
So what is the meaning of the definition "Ten-X Developer"!?
This term used to describe a developer that is 10 times more productive then his colleagues in his sphere.
In this article I will drop light on 3 fundamentals of programming and show how a ten-x developer would act.
Let's start from organization.
Keep an environment for each project.Usage of virtual environments will help you avoid conflicts between the libraries versions. At the example we can see that installation of a package from specific version cause removal of the existing one.
There is an example for a usage of virual environments when each project has it's separate environment with a right lib version.
Command Line Arguments
Under this topic I will present a module called argparse. This module will make your life easier received and parsing user input from a command line.
As it presented at the example above, it is possible to pess arguments type, name and description as the argument will described as --help command used(example bellow).
Lock Requirements Versions
Always lock you project requirements versions so they will be the same as at the production environment.It will make your life much easier debugging bugs on production.
Now to the second topic which will be Syntax..(Disclaimer!: It will be sweet)
Keyword Arguments And Documentation
Keep your code clean, document each function, add meaning in your variables names and use keyword argument when invoking functions.
One of the most popular use case for a with statement is file management. Using with statement you can prevent situations in which you leave your files open.
Another use case is suppressing exceptions without try/except statements.
Decorators allow adding new functionality to a function without modifying it's structure.
Here is an example:
At the example exception handling added to function without modifying it.
And the last but not the least will be performance improvement.
Using logging module over regular print will cut the run time.
Another advantage of the logging module is the ability to avoid usage of unnecessary requirements.
And finally logging module providing the ability to filter the logging on a production environment.
I will explain you the generator concept on a practical example(os.listdir() and os.scandir()).
- os.listdir is an iterator what which means that all the file paths will be loaded to the memory.
- os.scandir will load one file at a time what will save our program from crashing when accessing a directory with large amount of files.
- Generator returns an iterator object with one value at a time.
And here is a simple generator implementer by me:
In-memory files will help you avoid accessing physical paths, what will secure you from permission problems and more.
Here is in example:
And it is time to summarise:
- A Ten-x developer is an individual who is thought to be as productive as 10 others in his or her field.
- Use different interpreter for each project.
- Lock your requirements version.
- Keep your code understandable and document it.
- Use logging module instead of printing, it will improve the performance and will give you more control on your logging.
Thank you for reading!