Merken

Write more decorators (and fewer classes)

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Beta
Erkannte Entitäten
Sprachtranskript
well thank you very much for coming my name is
Antonio I'm suffering itself I work metric scene are so what I currently do use of working on observability real-time metrics and of time processing your Commission I that the is
to connect people agree club of businesses we have more than 127 million reviews no website and leverage every moment we do the 26 million unique mobile devices accesses are getting yelled for about an 84 4 million unique visitors to the best of our the best of website we have offices all over the world and we are more than 4 under the age in years working both on the product and the infrastructure so doing selection for to start the stalk has been inspired by seeing the talks stalled writing classes by check the other each player recommend you to watch the fork is great and by the book close the controller pottery awful another Objective Oriented heresy by the gain great book was highly recommended all the code that you can see in this presentation and trust me is going to be quite a lot of what is available on github at that you're all so all the code runs in this test the 2 grown eat and play with it it's for you now I'd like to start from the very end of the talk with the main choose takeaways are so dating might make little sense to you at the moment but keep that in mind maybe again there will be like you know cool ideas and you can use in your day-to-day job so the first one is let users to utilize all peaches instead of just inheritance and the 2nd 1 is a goal for the greatest when your classes and only 1 meter and the associated only once right so what is all about Maria well this is the reason how
many of you have ever used celery quite a few nice nice all so there is think has a job queue based on this the message passing it is focus a real-time operation of also scattering is kind of stuff so the way you define a task and celery is defining an up using this area PI and then calling to decorate was task and yup object just created in order to the great your task function so this is the 1st example on the website and this is the pottery than anger not show you today this but that is very very common I actually and is used by a lot of the frameworks of for example you know flask right and uh flask a micro framework for web development and the way you define logic for your routine flask is exactly the same as you define task and so you define flask up and then I you call the roots the great or hold up object you just created in which some foreign leaders in this case the URL you want a function to be executed for and then you just the the the function this can encapsulate the logic you want to execute is a very concerned about the for our frameworks in fact also the frameworks use it in order to refine views which have basically the same concept of roots in class as you can see just called the at you configure the great or you post the bus and some arguments and then the function decorated is going be the logic that is going be executed but these a game the 1st example on the website now what about classes as you
is the name the thought his bright more the greater loss and fewer classes
so if you ever try to write a custom and it's highly likely that you have read about the test unit test is now in the summer the beam pipe and 3 so I guess is the recommended way right testing pythons and the way you do it is to define a class of inheriting from our unit test test case and you define some test methods the again I have your assertions in order to understand if your call this the right fingers with trees with respect and in case you want to execute some sort of which allow methods what you do is that you override immediatly with a specific signature in this case it's about and you're you may do all your stuff logic in this case for example with the example and by dentition noise is an associated a widget objects and the touching it on the fly to discuss now us which use an alternative framework to write avoid the usage of classes in that are substituting them with the decorator so if you use the tightest of picture the greater in order to decorate your setup logic then it is a constant war and in order to access the object these with Tom by your set up cooks use subset of function what you do is that you pass the name of the function to your test functions and it works magical so as you can see the interface is much what you know that you can use all the function of the concept from functional programming of everything and well again they just short of so that school a place like
think so I wanted to understand how you implement this stuff like out the right he's the greatest in order to avoid using classes for to be of clean interfaces well what you do when you want stand how some code words belonging covering the source like so I went to that by
this project and that this was the result of it is an and the complicated so I say to myself well paid this there's a lot of magic maybe pyruvate is going to be easier on you the it was you know divorce maybe but yeah gagging by and it is a mature framework and there's a lot of business logic and and was a lot of you know corner cases so the salaries and was seen for right you know said it was the worst of all like as you can see it's a wall codes I have no idea how to put all this code for a because they wanted to underlie the current cases and so my reaction after seeing the salary implementation was these 1
I and they say to myself the
greatest so hot and use them so will be the sensors to at no 1 has this school at school or maybe someone in there
well it's actually not entirely correct a few months later I look more into how the greatest works
Python and basically the way the work is that you define a function which receives as an argument of the function you want to decorate
and the result of the regret of function is assigned to the function name that's pretty is you're right and in case you want to pass arguments to your decorator the weight works is that greater function is gonna be called me the arguments before and then the result is going to use is used as a decorator and we have just seen and any case you have more than 1 the greater the way to get execute is that the closest 1 to the function that you want to decorate gets executed 1st and the also gets lost to their of his opera level so actually I change my stance of that and so is
a bigger are out pretty easy to use but mainly adjust part 2 right well is not entirely true as well
so these is the simplest greater ever made I guess but as you can see what it does is just when degrading the function it brings the greater function reviews of us but it's the greater and it works in fact if we executed in the Python interpreter as where we get the 1st finally import the function that greater function is going to be executed and the grating function is going to be there is gonna be on the out and then every time we execute the function often happens just execute the neighborhood function so after
these maybe you can think the decorators I did to right the game that is not entirely true the so in case you
want to implement a greater we documents as we saw before the way you do it is on defining and Nina function in your decorator functions and the initial function is going to be very uh the greater the 1 we saw before so they were receiving the function as 1st argument why the stuff that you can use the high arguments that you've lost your idea in any other part of the function itself so the way words for these a greater implemented of the year is that when the function gets important it brings the gradient function we bar and bars which of the 2 arguments to foster the and then when the function runs the function runs without any modification all now if you want to do something more useful we or the greatest like for example changing the way the function is called or saving the resulting a cash and that kind of stuff we need a proper function as well there's going to be in defining inside the function and discover functions receive that argument for arguments the arguments of the function you want to decorate so piece of advice if you want to write code of these reusable just use arts and quot so you need to care about what the function of the the greatest speaking this the and the way we are just a greater function works is that a game when executed in interpreter it degrades the function and the time it brings the grating function and now every time we call the function decoded we written in the proper function inside the crater function is going to be executed before the function this for real now with that in
mind my sense in the greater is that they're only that easy or or not just to tedious to write is seen by the U. corner cases to remember what once you know how to write them once you have these the example in front of you but it's kind of OK and doesn't take much time and in fact if we look a flask framework which is a great piece of software in my opinion this is the way
they implement the degree to which is not much different who we saw before and it's much much simpler than all the others the greater received so far out so basically in the flask class which is the 1 we used to associate gap object we define ever to good which takes some foreign media's and his greater that takes some parameters we need an a function and is even a function of gap decorator in the actually greater what class because it is the finding and point out using the options parameter that we provided and an undergraduate for that and point to the other 2 types of function and the constant of function so my talk was closest all year to finish here but then in disabled to 45 minutes slot instead of a 15 minutes slots so I decided to go for a real life
example and so basically we're not gonna see the greatest for a while we're going do is looking at the class based interface that these examples implements and then we're going to look and how we can write in decorators so example I wanna take his stuff most
stop class there is a real internal
framework that we use at Yale to extract real-time metrics of the blogs where lots of just staying events and there is no more important for the presentation
is you much more context so so are the ways of course words sees that consumes lot from a much up which is this using platform usually used to you know Our would floor like carried on grounds of your infrastructure and then it does some custom logic which is implemented by the users PI and EPI and any semantics this you know that's which she's our 3rd party services that we use in order to visualize and analyze metrics and highest in the which is a foster stability scalable times used other base on top of the sum of other women to internally
so to reiterate keep inputs force that most of logs and the out of action metrics this is an example of what's the most and I was so in this example we see that the input is a log line which is Jason promoted with some information than some user code gets executed insights of most of this stuff Malta subcosta emits a tiny metrics so this is just you know I mean the result of a function some senior which has a name and a timestamp the values and the dictionary over attributes that we call dimensions matrix would now let's look at the metrics interface and the medusae interface
states composed by freeze little piece is the first one is an unknown defining the you kind of metrics that you can nominate which originally just counters in August Comte events and kind of time them then we at metacognition username toppled here and a metric as we say as always a timestamp about you are dictionary of task which we call dimensions and the type and at the very end we define 2 Kamali functions in order to that argued the use of force in the eastern state counter and the timer without providing type using partial the guy so let's look at the input
interfaces status of the longest so this
is where it is where the class is already come way basically the way a low class is defined Hazem the finding of a coder functions which is gonna used in order to decode neural blind in this case we provide Jason decoding and as the fault but you can just right these people just setting your customer and decoding function as a class tribute and then the base class which seen the moment justifying decoder class means which is going to be used to decode log line and the 2nd thing is the name of the lot source depositaries either non-existent so the weight towards the just inspectorates runtime all the classes defined in the framework and the checks for those name field and it just scales from Kafka out all the logs name these weights so if we want to implement a lot in status of forces to log for me a so we do it is pretty easy it's reasonable our so we just subclass the lock base class and just like in in this case the lines now in case you want to provide your custom decoding function and the way you do it is just if you define your function in the very beginning and then you set up the decoding function as a class attribute log now let's look at the stuff
most interface so carrier proteins the subclassing test space is based on the concept of 3 year at 3 there is a class which encapsulates the logic of that metrics from logs and this is the basic of class
it is very few things so the first one is defining goners for intriguer so we always know which genes responsible which logic and uh what he does a certain the owner and then the scale this can be a list of strings there is no way for us to encode this information fighting and so we decided to start writing a little bit of a torial so people could read and I you know I understand what the cost function to the to the class and then every triggered needs to implement it I just need to digest needed is what is used a lot to transform the decoded log line into metrics actually in that it's supposed to be a generator and the speed and and for as well so this is a course of course is all the logic that really mothers and as a process function that receive the log we're consuming from the line we just consumed and then each iterates over all the triggers and he tries to yield from the I just called on the entry so that the codebook line and in case of an exception he sends an e-mail to the owners the now this is the way a user basically our instruments of Mostar to consume lot and then it will need some metrics elderly so as you can see you 1st define the logarithm so before then you define the bonus for your trigger in this case just me and then you define your digest function you digest needed what it does decrease with the figure is just yielding a counter saying we so an event with these timestamp and we just count 1 yeah it is another example you defining the resource usage log talked you define a trigger with released of owners and then in the they just needed here we loop all their just the custom of assignment you time and we need to timing matrix based on the content of the of the log line so this all worked fine of the
publisher tutorial and we start with some users but then we realize that our users and not just regular users they are engineers and you know what the problem geniuses right if you give them a leg sets and then in building a flying that's part of the so the 1st question we got
as soon as we reduce the tutorial and some foster out remarried from a baseball class well I didn't think about it
so uh I answer
well let's us do so so you define and module starting underscore and here you define your base low class in this case with the basin of class doing is basically providing cauda for Apache of lines and now i got uh with a bit of
magic we tell stuff most of not to look for these underscore prefixes models so we don't start consuming lots of Don exists OK that's cool so that
so we use this kind of base classes in your regular model adjusting for them and use of the name of lock you want consume the the the the the the toil and we thought we were OK well it was wrong because there's is updated tutorial we got these other
question of linear the base class because now I so you might Original class I want triggered classes as well right didn't find didn't think about it in the
and so what we decide to do was basically using the same
pattern so in use the same underscore module you define your pastry their wits some logic In this case for example you the ask the user to set the magic came in the end points that are retained a lot as class subsidies and then you also asking to implementing Europe get additional dimensions metric and needed for example where you can actually the matrix you can meet and then you provide a digest function the does some logic and calls they get additional conventionally built and use is the end points and the metric name that you define this concept of it and at the end of the field counter so whatever the
magic we say just a small so regaining just don't look for underscore modules were treated as well and that's the way you use
them so you just import them and then you just set those owners and point symmetric came up to his for them it's a cost and then you implement get additional dimensions in order to customize semantics and that's it it works so again we updated tutorial is thought to be a bit long but users where people bright 24 hours a
because then I got this question all the narrator from true trigger process at the same time yeah well
and I don't think about it there by you know quite a supports will to Americans so we started to look at around it and our answer was
you just don't so let's keep things simple you
implement your base class some logic and then you inherit from me in your other base class and you define some other Logic and then you know what you do is that define another race class list eliminate from it and you define some other logical and then in URI old module you just subclass from both of them and provide them the same parameters as myself its so I get it is not ideal but as long as documented is gonna be a playwright but then after moralist all week we did the 1st for viewing for adding a new trigger and this is the 1st
question we got but I'll do it less likely that class because you want to write tests right well yes what the spammer was
prepared I remember quite side
so they will you can test history there is just defined patient titus when you retire on the sensation of the trigger you want to test and then what you do are you call to digest don't on the tree here and you test certain metrics easy it's in the result of that I just need be easy 1 minute after he asked me but how do we best
might basically the so right was to be
friends I don't understand then ball if you look at these class the
denarius from service based figure and service wasting their needs in it of serious to derived class define a metric learning and the same time so the denarius from 3 yeah which is any a serious but he defines worse as well shown you can't really as it because the assertions can fail I
was very puzzled by this can I stayed 1 day thinking about this even under the shower I didn't find any good solutions but a colleague of mine who came up with a very good idea it let's use in the by the
picture the type of function of migrants provide so we type function you can eastern ciate a subclass of a certain class i th runtime and also you can provide your class attribute as a that or at and we have this tutorial is such a be long enough that people didn't want to read it and yes I guess it's OK but so let's try to make things better right
so and and demonstrate you that might face using the greater was these
1 and after switching to the greater base interface the changed that to these 1
so looking back and supports a
model we got a lots as input and metrics is out so what's missing here what is missing it's a trigger what is a trigger so we say that trigger it's a class that encapsulates the logic to transform logs 2 metrics well just get rid of it it doesn't have any actual reference the your model just an abstraction constructed ourselves why do we in the 1st place no idea so let's remove it and and let's not force people to utilize just invariants for the interface let's give them the power to use all the features that Python provides so in the new interface the medics interphase
stays exactly the same no modifications the logs interfaces
started the change of it so instead of
using classes only the some crossings we decided to give the user the ability to just use classes either work as they were meant to be used by Python so you can see state your class this time and you plus the name of the law and the decoder function as para meters of the the to and no more session of and to decode class needed now became a simple me don't the only real difference from before is that now every low class defines an empty set of functions those functions are what i'm going up our are basically the equivalence of 3 years in the new interface that now this is the way you define a logged in user foster just is the costs that's the newly defined for each lot just you associated with the name and it works and in case you want to senior on the could function just called the glass and you pass a parameter get sick it's a much cleaner but now as
CA-DB interface so 1st of
all the process function stayed exactly the same but became imated of the log class and the game was the only thing we did was substituting the tree there with the functions set that these as possible class that now this is the way we wanted the user to utilize the new interface the way you define some logic in order to transform your blocks to metrics is now importing neurological of object to be created somewhere else and then now calling a decorative metode on top of the object also using another the greater to passing the oldest middle of the function and discussed define the function of the function is exactly the died a suite of the 1st legally so without any modification you just remove all that costs thinking and I basically the way did the current is implemented it's the simplest the greater or yeah what he does he just we see the function as an argument and just adds a to the 2nd that is already attached to the log class that said the now it is even simpler than flask the and in case we want to provide some more helpful and the greatest like for example this 1 which makes you able to register the same function for multiple lots of the same time what we can do is implemented a greater with arguments and the arguments is that this release of locks and are in this case what we need is just an inner function where we eateries over the log and we call the reduced cemented once again because remember it's the greater the same time it's needed and in case we want to implement these orders the greater to keep some metadata the function of what we do is exactly the same as before we basically and letters as the parameters of the function and we just attached on the fly the end there's 2 the function because every function might and is also an object so I know that some people are we opposed to these so in case you don't want to monkey but your function you can always define a dictionary as a global and then use it uh in the closure of the upper function it works itself using now this is the way the user some registered the greater is used as you can see we import you logs and we passed you logs to the greater and actually I also want to point out that the order steak greater removes these and be greedy about all these Dionysus adjust orders the orders of the substrings like if you want to pass more orders you just passing more arguments and the might interpret the is gonna check that for us as we don't need more sessions because the fighting temper the at input time is gonna jet that we created that you logs we want to reduce the function for the goal of the function once again is just that I just the on 1 to greater will before now let's go back to
the questions we got so how do merit from a base law class my
phase if you want to subclass your a low class you can
but if your idea is just passing according functions and then avoiding to pass it over and over and over what you do is just use partial and then you says the new using the results of Marshall it next question how do inherit
from base figure class well no more
base classes no more assertions
what we do assist the finding a simple function we define a function and yielding some metrics and adding some attributes as the absence of the class before as parameters in this case the endpoints and even the additional dimensions metode is now just the parameters for the function not recorded messages so we just field from the function we've been our you on logic and this what we do we don't even need metode Sweden it's of classes we don't need to remember to us Ceret for such reviews it's all done by the interpreter for us for free yeah the the but all
the notes from Trudy the classes double
about is 1 in what you do is just
you define 2 functions is use of the digest me go the 1st together we sold our when we so the example of the move to disease the exactly the same code of the 2nd trigger the we saw before he just call them both union the task to score functions the now
let's go back to test other wikis might trigger class now is used before even
easier you don't even need that my description anymore just a function you call it that the and I will do it this way
bases the class that's the
thing I'm most happy about but it's be another
function just calling to gain and the way you mock yourself passing from strings like for example test despite meters you don't need to use the type a function of size and provide you the need to remember about inheritance and everything just passing instinct it so
not removed all sessions how they make sure that all functions have owners
well we write the best with a test does these calling to collect function which is the 1 used by Mr. to collect run-time all the logs we iterate over the logs we just check that they have the on of to be upset still well that's even better than before because we transformed the runtime error or to a test that could fail before we even pollution some function we don't corners in production
so it's everything we indeed this or implementing the steak or a torus and changing a bit interface only for user sake no actually form and the ball slot those same fish eaters because you remember they talked a lot about the input system stopped most of the thing that makes up most understand which log things to consume beat classes in is to execute the kind stuff well I didn't understand the code but this is the
input system in the new stuff to most just look at it and compare it with the old 1 it doesn't fit in his life and actually disease are version of arity them seeks so it's much more complicated the by 10 to the 7 version that we used and that makes me Barry
theory at B is now closing
up the main takeaways The told where let user utilize my them future instead of just inheritance as we so and go for the greatest when your classes have only 1 metered for example the trigger class has only that I just needed and their associated only once actually we never have an even associated trigger class ourselves the framework was doing that for us and now instead what you do is you Eastern ch role class whenever you want even want to surpass if you're free to do it you know 1 2 don't do it and all the teachers disappeared they're just functions so just to clarify I'm not saying that we should move entirely out of classes from the system use classes when they're useful in this case the low class system the class because there's some states and there's some the idea and it's used as class are supposed to be used in Python not only for Americans so we make sense go for the greater when he makes sense of for classes and that's the end of the cold uh remember that we are hiring
especially for our office in London the number of so if you want to work which might and and only go real-time processing streams and stuff just comfortable clear to us that would proof testing the Beagle and don't forget
to fall was on every social network possible Facebook tree and eat up yes nowadays because the social network and I please read or engineering blog where a lot of smart engineers quite better than we are and speak about all the cool stuff that we build every day
questions few
decades and rooms and
remote done fall through presents ch questions thank it hi it right did you run into
any a specific situations where uh switching to using the corridors made it hard and practice to the but certain problems so where the decorator obscure the actual problem that you were trying to get the that that's very good question actually so
that you may have used to create or cause they're very complicated like to do a lot of stuff and there then very difficult the body because the change the way the function is executed and then you got these weird stuff trees and you really understand what's going on well matches saints of these is that as in any type of act while always writing code you want to keep it simple so my 2 cents is decorators should always the function and touch is like the function should be able to be called without using the they crater and the crater should stay really small so the frameworks that I showed you before and very complex they greatest but they are very much a framework of we you know good offices community and a lot of teachers just came into it so much a sense especially for your on now production Kodosky this keep you the greater and the boy to do a lot of stuff to them tell your plans for submission more questions to entorno no we think you from doing of representation you have had a
Klasse <Mathematik>
Web Site
Momentenproblem
Klasse <Mathematik>
Kombinatorische Gruppentheorie
Code
Computeranimation
Demoszene <Programmierung>
Intel
Prozess <Informatik>
Code
Gamecontroller
Objektorientierte Programmiersprache
Trennschärfe <Statistik>
Vererbungshierarchie
Meter
Luenberger-Beobachter
Softwaretest
Linienelement
Vererbungshierarchie
Eindeutigkeit
Mobiles Internet
Biprodukt
Objektklasse
Office-Paket
Software
Echtzeitsystem
Gamecontroller
Facebook
Lineares Funktional
Parametersystem
Einfügungsdämpfung
Web Site
Sichtenkonzept
Klasse <Mathematik>
Objektklasse
Mathematische Logik
Framework <Informatik>
Computeranimation
Task
Objekt <Kategorie>
Echtzeitsystem
Flächeninhalt
Spieltheorie
Prozess <Informatik>
Bus <Informatik>
Web-Designer
Warteschlange
Wurzel <Mathematik>
Ordnung <Mathematik>
Message-Passing
Softwaretest
Lineares Funktional
Komponententest
Distributionenraum
Klasse <Mathematik>
Systemaufruf
Geräusch
Elektronische Unterschrift
Mathematische Logik
Code
Quick-Sort
Framework <Informatik>
Computeranimation
Netzwerktopologie
Konstante
Objekt <Kategorie>
Teilmenge
Rechter Winkel
Widget
Wort <Informatik>
Ordnung <Mathematik>
Funktionale Programmiersprache
Schnittstelle
Resultante
Rechter Winkel
Implementierung
Maschinensprache
Mathematische Logik
Framework <Informatik>
Code
Computeranimation
Resultante
Lineares Funktional
Parametersystem
Gewicht <Mathematik>
Besprechung/Interview
Computeranimation
Übergang
Nachbarschaft <Mathematik>
Lineares Funktional
Interpretierer
Mereologie
Computeranimation
Parametersystem
Interpretierer
Lineares Funktional
Spieltheorie
Mereologie
Wort <Informatik>
Sprachsynthese
Eigentliche Abbildung
Code
Computeranimation
Gradient
Assoziativgesetz
Lineares Funktional
Videospiel
Parametersystem
Punkt
Klasse <Mathematik>
Framework <Informatik>
Computeranimation
Konfiguration <Informatik>
Objekt <Kategorie>
Minimalgrad
Software
Datentyp
Hypermedia
Framework <Informatik>
Linienelement
Web log
Klasse <Mathematik>
Kombinatorische Gruppentheorie
Ereignishorizont
Framework <Informatik>
Computeranimation
Schnittstelle
Resultante
Matrizenrechnung
Stabilitätstheorie <Logik>
Gewichtete Summe
Hausdorff-Dimension
Gruppenoperation
Mathematische Logik
Systemplattform
Login
Code
Computeranimation
Formale Semantik
Skalierbarkeit
Code
Zeitstempel
Drei
Gerade
Schnittstelle
Attributierte Grammatik
Lineares Funktional
Linienelement
Kontextbezogenes System
Ein-Ausgabe
Dienst <Informatik>
Wort <Informatik>
Information
Ordnung <Mathematik>
Lineares Funktional
Linienelement
Hausdorff-Dimension
Gefrieren
Ein-Ausgabe
Ereignishorizont
Computeranimation
Task
Forcing
Datentyp
Zeitstempel
Ordnung <Mathematik>
Schnittstelle
Aggregatzustand
Softwaretest
Zentrische Streckung
Lineares Funktional
Mathematische Logik
Gewicht <Mathematik>
Linienelement
Freier Ladungsträger
Momentenproblem
Klasse <Mathematik>
Rechenzeit
Quellcode
Mathematische Logik
Login
Raum-Zeit
Framework <Informatik>
Computeranimation
Datenfeld
Forcing
Existenzsatz
Vererbungshierarchie
Decodierung
Ordnung <Mathematik>
Gerade
Attributierte Grammatik
Codebuch
Zentrische Streckung
Lineares Funktional
Matrizenrechnung
Bit
Prozess <Physik>
Linienelement
Klasse <Mathematik>
Iteration
Mailing-Liste
Ausnahmebehandlung
Mathematische Logik
Ereignishorizont
Computeranimation
Loop
Logarithmus
Menge
Kostenfunktion
Mereologie
Information
Zeitstempel
Inhalt <Mathematik>
E-Mail
Figurierte Zahl
Gerade
Zeichenkette
Vererbungshierarchie
Klasse <Mathematik>
Gerade
Computeranimation
Informationsmodellierung
Vererbungshierarchie
Computeranimation
Lineares Funktional
Matrizenrechnung
Addition
Datenfeld
Linienelement
Vererbungshierarchie
Hausdorff-Dimension
Mustersprache
Klasse <Mathematik>
Vererbungshierarchie
Mathematische Logik
Modul
Computeranimation
Addition
Bit
Punkt
Hausdorff-Dimension
Ordnung <Mathematik>
Modul
Symmetrische Matrix
Computeranimation
Formale Semantik
Parametersystem
Prozess <Physik>
Vererbungshierarchie
Klasse <Mathematik>
Vererbungshierarchie
Mailing-Liste
Dienst <Informatik>
Eliminationsverfahren
Objektklasse
Mathematische Logik
Modul
Computeranimation
Netzwerktopologie
Softwaretest
Linienelement
Klasse <Mathematik>
Computeranimation
Dienst <Informatik>
Klasse <Mathematik>
Figurierte Zahl
Computeranimation
Lineares Funktional
Rechter Winkel
Klasse <Mathematik>
Datentyp
Vererbungshierarchie
Rechenzeit
Computeranimation
Attributierte Grammatik
Data Mining
Informationsmodellierung
Linienelement
Invarianz
Vererbungshierarchie
Abstraktionsebene
Klasse <Mathematik>
Ein-Ausgabe
Mathematische Logik
Login
Computeranimation
Leistung <Physik>
Schnittstelle
Lineares Funktional
Parametersystem
Subtraktion
Mathematisierung
Klasse <Mathematik>
Äquivalenzklasse
Login
Gesetz <Physik>
Computeranimation
Web log
Menge
Meter
Schnittstelle
Aggregatzustand
Algebraisch abgeschlossener Körper
Suite <Programmpaket>
Lineares Funktional
Parametersystem
Prozess <Physik>
Linienelement
Hardy-Raum
Klasse <Mathematik>
p-Block
Ein-Ausgabe
Login
Mathematische Logik
Computeranimation
Netzwerktopologie
Objekt <Kategorie>
Metadaten
Multiplikation
Spieltheorie
Ordnung <Mathematik>
Schnittstelle
Resultante
Lineares Funktional
Vererbungshierarchie
Klasse <Mathematik>
Figurierte Zahl
Gesetz <Physik>
Phasenumwandlung
Computeranimation
Parametersystem
Interpretierer
Lineares Funktional
Datenfeld
Linienelement
Hausdorff-Dimension
Klasse <Mathematik>
Vererbungshierarchie
Mathematische Logik
Message-Passing
Computeranimation
Attributierte Grammatik
Task
Lineares Funktional
Vererbungshierarchie
Klasse <Mathematik>
Objektklasse
Code
Computeranimation
Softwaretest
Lineares Funktional
Deskriptive Statistik
Datentyp
Klasse <Mathematik>
Meter
Vererbungshierarchie
Stützpunkt <Mathematik>
Wiki
Computeranimation
Zeichenkette
Softwaretest
Lineares Funktional
Funktion <Mathematik>
Rechenzeit
Biprodukt
Login
Computeranimation
Videospiel
Bit
Klasse <Mathematik>
Versionsverwaltung
Physikalisches System
Ein-Ausgabe
Code
Computeranimation
Physikalisches System
Bildschirmmaske
Torus
Schnittstelle
Fitnessfunktion
Lineares Funktional
Vererbungshierarchie
Klasse <Mathematik>
Vererbungshierarchie
Physikalisches System
Objektklasse
Framework <Informatik>
Physikalische Theorie
Computeranimation
Aggregatzustand
Netzwerktopologie
Streaming <Kommunikationstechnik>
Facebook
Echtzeitsystem
Prozess <Physik>
Web log
Beweistheorie
Zahlenbereich
Computeranimation
Chipkarte
Office-Paket
Kombinatorische Gruppentheorie
Computeranimation
Lineares Funktional
Maschinenschreiben
Güte der Anpassung
Selbstrepräsentation
Mathematisierung
Besprechung/Interview
Automatische Handlungsplanung
Biprodukt
Framework <Informatik>
Code
Computeranimation
Office-Paket
Netzwerktopologie
Datentyp

Metadaten

Formale Metadaten

Titel Write more decorators (and fewer classes)
Serientitel EuroPython 2017
Autor Verardi, Antonio
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/33685
Herausgeber EuroPython
Erscheinungsjahr 2017
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Write more decorators (and fewer classes) [EuroPython 2017 - Talk - 2017-07-11 - Anfiteatro 2] [Rimini, Italy] In the wake of famous talk “Stop Writing Classes” by Jack Diederich (https://www.youtube.com/watch?v=o9pEzgHorH0), I’d like to present a pattern that can be used to design clean and pythonic interfaces for programmers based on replacing single-method classes with decorated functions. This pattern is already used by some famous frameworks and libraries, like Pyramid (https://trypyramid.com/), but I believe it isn’t that well-known to many (even experienced) Python developers and is not as widely used as it deserves. I’ll show how this pattern can be employed to improve a programming interface which is used by an internal log processing framework at Yelp. This will demonstrate how a more functional approach, leveraging the power of Python decorators, can lead to simpler, more beautiful and easier to understand code. However, this talk doesn’t suggest giving up classes altogether, but making use of them only when they are truly useful. In fact, the use-case I’m going to analyze will combine classes, functions, and decorators to make the best out of these tools. Given that the presentation is going to be very code-oriented, the talk is intended for an audience of developers who are already familiar with most Python constructs, including decorators, even though the concept will be briefly introduced at the beginning of the talk. But, if you are one of these people, I promise you that the code will speak for itself

Ähnliche Filme

Loading...