Merken

Writing quality code

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
of 1 minute of the completion and I'm from Portland regional city located in the western Poland and much about writing political at the beginning of few words about me I started programming in
Python 2007
and this is the number of in mostly using it for developing web applications and I had a chance to learn and use some of the most popular vitamin frameworks starting with sort of them and for many years has been related with states next item software house located in Poland where I had the chance to the part of project for the banking industry to developing some sites for governmental sites and so this is the beginning of my friends with by Tom I was always trying to improve the cold quality the code quality that I'm writing and say I would like to show some thoughts and ideas about it and in order to make this part of the presentation of used a bit interesting to issues around random facts about me and so what I wrote an application that enables you to write in decision making algorithm that will play poker game and I'm just for fun for holding the colonists internal environment our company but if you're interested you can you can take a look at my itself provides the the decoding so starting with a plan
of my presentation at the beginning I'm gonna tell you will try to define what's called the quality of code can be defined and then will try to find out if it is really important and it's is really wants to take care about it and then we will try to answer as there is in a reasonable way of measuring the quality of schools and demand part of the presentation I will try to and give you some advice is some some conclusions that I that I received a tendency solves I would judge that some useful tools and other things that will help you to improve the cold the quality of your code and at the end there should be a couple of minutes for questions and comments from the audience on a so let's start with the a definition of high quality of gold that and so in fact there is no explicit definition is that it is a rather subjective feeling and many different programmers may have a different opinion on given part of gold it may be based on their experience of 1 on the language data use or the convention that there are using however in his book is called completes Stephen McConnel distinguish between external and internal characteristics of software quality and the external the characteristics models that's the final user is aware of and this is something that the the final user of software product can experience this these or suchlike correctness like usability or efficiency on the other hand there are a so called internal characteristics of of software quality and they are not actually be able for for for the final user this for product but still have a big impact on the process of development of of the software product they are such like maintainability on are of of and so in my opinion I would rather than instantly fired and so I would say that's said the he good gold there can be can be characterized only with 1 word could go into the understandable form that is because and that is because this is so what's according to my observation is the developers usually do in they were they try to understand the cold and a small part of the sources time is spent on modifying existing called are developing a new and actually do this this chart is not a product of any scientific research I took it from just at which block but it's perfectly describes my think about the the developing software OK so now let's try to find out if it's it's really important to care about the stuff from quality of gold it because
sometimes under the pressure of deadlines for all under the the pressure of the project manager and we tend to that satisfies the quality of written color and
then we can use you can use it to take into account and that's technical that that you take in the early stages of development of software product we surely have to be paid back let's they and a look at that chart which presented the dependency no the dependency between cold quality and time spent to develop a new future and in case of that that project that characterizes with a high political at the time of opening the door this is much smaller than than otherwise and so now we
know that that we should think about that rising political because and ways the better quality cold calls and nondestructive final to do this we can actually measure somehow the quality of gold and as I said earlier the
quality of all this is usually subject to think and then according to this funny comments that
you can you can actually be high how seriously distinguish sabbatical from glucose just on your own impressions when you when you read that about fortunately there are some some metrics that let us determine the quality of the more
the means to carry out a try to tell few few words about Starting with psychological plexity
which can be which can be defined as the 1 plus the number of decisions statements and boolean expressions the block of code there are so few of some sort to refine unstable in the food label you can you can find on the net how how would different different statement aspects and uh cyclomatic complexity number which also can be called in my case number and I think and there's another varieties definition of of my case number which says that this is the the number of our independent passed to the block of code that will see it in examples with that thanks if
you're who which does something actually doesn't make and I think sense of the odds of it is just an example so that it can can try to find the money accountants had markets number for it and it this 1 the state this is the same and so you want to and facial the numbers before and we can then can compare it with with the number of spots which is 1 2 3 and 4 so yeah In another metric and another and
in fact it is a set of metrics are a so called cost of metrics and so on there are calculated based on the number of operators and operands in the rebels cult and here's another example and we can begin to count the number of a number of operators which stands for the actions that are applied to operands these are like logic statements mathematical statements anything that that affect the
fall of of the of the of the algorithm on the other hand you got so this is just a number of operators which are usually
variables that constant used to in a in a cold and based on this number of how's that defines a set of metrics and I'm not going to go into the details of all those formulas I'm just mentioned them because they are usually used by automated is software for measuring the cult of quality and uh that constant volume that is also used to account uh another metric that's describes software which is called maintainability index and it is based on both on the cost of volume of the cyclomatic complexity of of stalled and the number of uh that about number of levels of source code not line of number of lines of source and I would like to show you the right tool that's hard to do to calculate the dose matters of for for a cold and with a single comment again and you can you run on a cold and will speech you out the rates for all methods and functions that are defined in the module that you are using it for and transit with latter out in a minute I will tell what what's the latter means uh and the same you can you can count them it in this for a given module it also gives us fast some results and the reference table with the results from page number each each letter is around that tells you how your gold and if you recall this rated with your last that means that perhaps you should take a look at that if there is any place for for simply find here because such such just you may all you to be at higher recall a prominent unstable and answered the same for MRI I results I mean if you're if your
model is ranked with the and that means that it would be quite difficult still Due to maintain and to just simply the
I tried to run the MI metric for some more of the popular vitamin frameworks and then and then the results are pretty good fast even in the trait it's a all the 5 so it is a good in another useful but I would like to mention curious clients which is a static called analogous to and that's it helps you to keep the coding standard but use your project beside it treats the text some errors that can be detected and from from static there and they're called definition so it is usually used as a reference during the help and combined with with and ways it is also find fully customizable and should be easily it should be easy to integrate it with your antique varieties that your users and user uh here's an example of using violence there's another piece of gold which some flaws and defects so we've got some new variables here and we are using the model that we have important and here's the here's the result of running the pilot on the gold and is against the uh at this at this uh warning us with some called style violations it detected the arrow was using the dates time name which is not important anywhere in a modular uh and it gives us give us some warning with you can use the definition with the fusion of unused in the variable names and so it's it also writes a column displays of gold was rated of minus 8 in this case up to 10 so it means that it is that's not a good culture and should be referenced I just think about piece of of so what's the pilings gave us in results due to the to the slide but it gave it if you and eat more than evenly and more results and that's why why I usually use lands and it would recommend you do to the and if you would like to regain some knowledge
about other tools that support quality checking quality of of by the old so I encourage you to go to tomorrow session of 1 a
colleague of mine during the same time and in room barrier I and it now and
just trying to think how can we and improve the quality of cold you're right and I will try to use some some some change on on on it and so in my opinion the most the single most volume label actions that support the
process of developing a software product is a college review and simply because it decreases the number of bytes because with more people can take take to to take a look and said the piece of felt it it's more likely that the error will be fine but also it and forces you to writing need gold because the way of writing the out with knowledge that is someone that opinion you care about what they can do about it you're gonna be programming differently and you will try to avoid simple error and its speed up the learning because it's enables the flow of knowledge between more and and less experienced programmers and in that it enhances the team culture
because it enforces this book in it and courses sorry we enforces rule constructive feedback which is very important for programmers to grow in their adult and if you
if you think of how to do a good review idea at the beginning you should you should really all all the code that this person must branches of never was anything which is not a review and use all the use of dedicated tools to to to to do you focus only on the on the called itself you you won't have to care about the cold so volatile violation because they can be defined the automatically and the 3rd rule is that everyone should be equal and everyone should make and receive calls and speaking about
the tools that supports the process of gold reduced that there are plenty of them involve most of them are really good about for me sufficient is the simplest 1 which is the 9 comments that are aligned along most of the open repositories and lined it up a bit better and this readability have great impact on the understandability of gold so we should also focus to write cultural and pattern
designed to to enable eating rights a clean called however it is just a tool like this is just a language that that used so you should also take care of and I'll try to give you some common rules that will help you to to achieve uh at the beginning
tried to keep it consistent with the coding conventions the project you're writing uses it doesn't have to be that aids cults standards but usually devoted to use it's simply because it is used widely among other other and projects and it is probably a default option in your edit or that will help you to to be consistent with with that uh naming about it's not that easy thing and the at the at the scene so well let's take an example and and
societal final some common rules about naming variables in the beginning it should be descriptive so don't use 1 car of the viable names that don't too general names and this is really something really that because you are overloading can bite library method here and I've seen many times the people use objects or ideas name for a viable which is can be quite dangerous uh on the other hand the length of of variable names should not be too long because 1 of the ones in this unreadable and so it is not it convenient to use it in your about it when you have 2 types of like 15 cars
and say you are some some good examples for the variable name in this example and obligations are of course acceptable entities as far as they are obvious enough uh 1 thing you should also avoid the double negative Boolean logic and in 19 your viable simply because it not natural was with of human understanding and so when you will you will try to make them adaptive that you will have the obligation which is not the tree
had and what about dust strengths and garments them that there is 1 general rule of deference to be valid and should be up-to-date so when you change anything
can called it is so we have to take a look the it didn't break that the don't change governments yeah the same way about common sense 1 more rules use it when when when you can't it avoids the complexity or obscurity of of your culture just don't try to state the obvious thing it doesn't increase the reliability of the boat and went and it is also that make your test clean depicted dumping you should you should take care about them because they also may affect uh the process of increasing the maintainability of the project decided that's you should
also put some individual effort to right to more and more readable code uh you should know by the need there's like in this example where we are and where we using the title move change comparison with more readable than than not using it you should know a
Python standard library functions but also if you want to reply right is more readable code and you should know the light on
the that that will enhance the readability of the occult and by the way this is not a good example to generates a similar anyway but I use it just to show that using the context manager of and and and decorator make this this is called quite clean and 3 From beside it is a tried to do resample not only the Python devoted books but also some languages must because that trees about writing clean coal there are plenty of them you should easily find the 1 that that would be more suitable for you should read out of the presentation of those patterns from the
library has a great documentation with many examples and it will surely help you to to to gain some knowledge about the usage of the standard library models and is a practice of there and so I would like to
show you 1 more thing in the
system I use sometimes to to have a challenge to the false some tasks in in in Python and this is called chick and here's an example of a task that is about finding the
most frequent letter in a piece of text and here is the solution had came up with lots very very readable but at this time I I just thought that it makes what it has to and a I submitted uh this is my solution and then I took a look at the list of who took part in in solving this task and the good good good news is that the solutions are can be rated and commented so it let's take a look at the the piece of gold so all from the 1st place so yes you can you can solve this this this task with just 2 lines of Python code which is great news and give me enough to think about about how to improve the quality of Michael OK thank you for your attention and this is a time for questions of
thank you thank you this was OK so I have a
question about docstring what parts of called in your opinion deserve a docstring because and making them for every function I I think it would be you know too much the it depends on on the
convention that using your called I must admit that I've tried it to the convention was having to at least as small as those that thing for each function that I used and so sometimes I agree that that's the they are not so that's usable it's up to you the bilingual tell you that you have don't have adoption defined for any function but you can of course uh confederates messages any
questions would it be to know much
thank a technology in place
Vervollständigung <Mathematik>
Code
Wort <Informatik>
Baum <Mathematik>
Dialekt
Computeranimation
Subtraktion
Bit
Web Site
Prozess <Physik>
Web-Applikation
Formale Sprache
Programm
Automatische Handlungsplanung
Schreiben <Datenverarbeitung>
Kartesische Koordinaten
Kombinatorische Gruppentheorie
Code
Framework <Informatik>
Informationsmodellierung
Bildschirmmaske
Algorithmus
Software
Spieltheorie
Code
Nichtunterscheidbarkeit
Randomisierung
Luenberger-Beobachter
Vorlesung/Konferenz
Punkt
Softwareentwickler
Benutzerfreundlichkeit
p-Block
Quellcode
Biprodukt
Quick-Sort
Entscheidungstheorie
Softwarewartung
Mereologie
Wort <Informatik>
Projektive Ebene
Charakteristisches Polynom
Ordnung <Mathematik>
Programmierumgebung
Aggregatzustand
Druckverlauf
Software
Digital Rights Management
Projektive Ebene
Softwareentwickler
Computeranimation
Systemaufruf
Computeranimation
Arithmetisches Mittel
Metropolitan area network
Software
Filetransferprotokoll
Linienelement
Wort <Informatik>
Computeranimation
Befehl <Informatik>
Subtraktion
Adressierung
Komplexe Darstellung
Zahlenbereich
p-Block
Extrempunkt
Code
Quick-Sort
Computeranimation
Entscheidungstheorie
Arithmetischer Ausdruck
Boolesche Algebra
Brennen <Datenverarbeitung>
Aggregatzustand
Varietät <Mathematik>
Nichtlinearer Operator
Befehl <Informatik>
Mathematik
Linienelement
Gruppenoperation
Zahlenbereich
Mathematische Logik
Computeranimation
Algorithmus
Menge
Petri-Netz
Personal Area Network
Logik höherer Stufe
Resultante
Lineares Funktional
Linienelement
Indexberechnung
Zahlenbereich
Isochore
Sprachsynthese
Quellcode
Bitrate
Modul
Homepage
Ausdruck <Logik>
Übergang
Arithmetisches Mittel
Softwarewartung
Metropolitan area network
Informationsmodellierung
Variable
Uniforme Struktur
Menge
Automatische Indexierung
Software
Spezifisches Volumen
Gerade
Tabelle <Informatik>
Resultante
Dualitätstheorie
Linienelement
Benutzerfreundlichkeit
Datensichtgerät
Varianz
Variable
Framework <Informatik>
Computeranimation
Rechenschieber
Metropolitan area network
Informationsmodellierung
Client
Variable
Zustandsdichte
Prozessfähigkeit <Qualitätsmanagement>
Total <Mathematik>
Zeitrichtung
Projektive Ebene
p-Block
Hilfesystem
Varietät <Mathematik>
Fehlermeldung
Verschlingung
Code
Gruppenoperation
Spezifisches Volumen
Computeranimation
Data Mining
Feuchteleitung
Konstruktor <Informatik>
Rückkopplung
Prozess <Physik>
Programm
Zahlenbereich
Schlussregel
Datenfluss
Computeranimation
Forcing
Software
Code
Baum <Mathematik>
Fehlermeldung
Peer-to-Peer-Netz
Prozess <Physik>
Dokumentenserver
Code
Mustersprache
Güte der Anpassung
Verzweigendes Programm
Systemaufruf
Schlussregel
Code
Computeranimation
Maschinencode
Formale Sprache
Schlussregel
Objektklasse
Computeranimation
Konfiguration <Informatik>
Demoszene <Programmierung>
Metropolitan area network
Rechter Winkel
Projektive Ebene
Default
Baum <Mathematik>
Standardabweichung
Netzwerktopologie
Teilmenge
Objekt <Kategorie>
Dicke
Variable
Programmbibliothek
Schlussregel
Extrempunkt
Computeranimation
Eins
BEEP
Softwaretest
Softwarewartung
Prozess <Physik>
Mathematisierung
Kontrollstruktur
Projektive Ebene
Schlussregel
Komplex <Algebra>
Computeranimation
Lineares Funktional
Rechter Winkel
Mathematisierung
Programmbibliothek
Paarvergleich
Knoten <Statik>
Code
Standardabweichung
Netzwerktopologie
Informationsmodellierung
Mustersprache
Digital Rights Management
Formale Sprache
Programmbibliothek
Regulärer Ausdruck
Kombinatorische Gruppentheorie
Kontextbezogenes System
Baum <Mathematik>
Computeranimation
Standardabweichung
Task
Physikalisches System
Computeranimation
Task
Metropolitan area network
Mailing-Liste
Baum <Mathematik>
Gerade
Code
Computeranimation
Lineares Funktional
Mereologie
Baum <Mathematik>
Message-Passing
Computeranimation
Roboter
Red Hat
Baum <Mathematik>
Computeranimation

Metadaten

Formale Metadaten

Titel Writing quality code
Serientitel EuroPython 2015
Teil 63
Anzahl der Teile 173
Autor Jankiewicz, Radosław
Lizenz CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
DOI 10.5446/20186
Herausgeber EuroPython
Erscheinungsjahr 2015
Sprache Englisch
Produktionsort Bilbao, Euskadi, Spain

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Radosław Jankiewicz - Writing quality code The quality of written code is an important factor in a final success of a software project. Perhaps there is no universal definition of high quality code, however usually it's characterized as clear and readable, well-designed, well tested and documented, easier to debug, maintain and extend, etc. Python was designed to be a highly readable language that would make it easier to develop high quality code. Nevertheless, programming language is only a tool in a software development process and in the end the quality of code depends mostly on its author's concept and decisions he make. In this talk I would like to present some of ideas, techniques and tools for improving the quality of written code, tried out with a good result in everyday work on developing software in Python.
Schlagwörter EuroPython Conference
EP 2015
EuroPython 2015

Ähnliche Filme

Loading...