 Hello, this talk is on flexibility in routines by using S4 classes, calculating habitat conservation status as an example. The focus will be on S4 classes and why and how we use them to develop our package. The main aim of our package is to assess the quality of habitat types by scoring indicators which is based on applying a number of rules on our field data, how this is typically done. Done for four examples, I explain you in this diagram, so on top you have a field data where we start from and then notes and arrows indicate the different steps that have to be taken in each of the examples. With different shapes in the notes, I represent different operations that have to be performed. And actually the sequence of these different operations is important. If the sequence is the same, I filled the notes with the same color. So on the left, the first example is colored in yellow and also the third example is colored in yellow because this sequence of different operations is similar in these two examples. This means that the main code can be applied to derive the scores from the field data. They are more or less the same because they still differ in some parameters that are needed. Of course in the code you can easily tackle this by adding variables. Second example, which is colored in green, is different from these two others because of the second step. And then on the right, the last example is partly colored in yellow and partly in green. The yellow part is the same as the yellow examples, so it has the same sequence of steps but here one additional step is needed, which is indicated in green. In total we have a large set of over 2,000 of these rules. They all have a similar structure except for some variation and in total we have actually 14 different variants whereas we had three in our example. And then as I mentioned, even rules with a similar structure can have different parameters. To develop a package we also had to keep in mind that in future new rules may be added to this set of rules. So the channel schedule is going straight forward. We have a function that takes the field data as a parameter and that gives the result, so the indicator with the scores to tackle the fact that we have a lot of rules. We added an Escalar database internally into the package and of course this database includes these different rules and their parameters. The idea is that the R code only performs a general routine which is looking up the rule in the database and then perform the rule following the information that is in the database. We aim to have one general code without really adding these different content information from these rules because only that can allow us to adopt novel rules without having to change our code. We accomplish this by using S4 classes. So S4 classes are inspired on object oriented programming which you find in languages such as Java and C sharp. Typically objects have properties or attributes which we call slots and functionalities which we call methods. In fact as a first step on an abstract level we define our own class with the necessary properties and functionalities and then later on in our main code make different instances of this class and actually these objects should perform the operations that we need. In our case we made a class analysis object with the slots field data and then these different parameters and as a method we added GIF score. As I showed you in the example GIF score does not have one unique code it can differ between the different examples and that's where inheritance helps us. So we can define a class presented here in yellow which inherits from the class analysis object. This means that all slots and methods that are defined in analysis object are taken over in this yellow class. Of course the yellow class is inspired on our yellow example from the beginning. So here we can give an actual implementation in the method GIF score and we can out here the code that we need to perform these different steps which were colored in yellow. Similarly we can make for our gray example a gray class with the method that we need there added to GIF score. Then remember we also had this mixed class with yellow and green and here we can also make advantage of inheritance. We can make a green class that inherits from the yellow class and then indirectly it also inherits from the class analysis object. So without redefining someone something the green class is exactly the same as the yellow class. We could here just rewrite the method GIF score with some novel code but what we actually did is we call first the method of the yellow class so count the number of species and then actually we add the two steps that were colored in green from our first slide. So we compose in fact our code with the piece of code from the yellow and add the piece of code from the green. As I mentioned in the beginning of this slide in the class analysis object we don't we cannot add an actual implementation for the method GIF score because it's different on the inherited classes and because of that we don't want users to be able to make an instance of the class analysis object. We can do this by defining analysis object as a virtual class. So by doing this we actually force the user to choose between the yellow, the green and the gray class to make an actual object of the he has made an object he can use methods from the virtual class analysis object. So some advantages of SFAR classes it's possible to group different types of information into one object and write specific methods for the class of this object on the whole group of information that is in the object. Inheritance allows to adopt slots and methods from other classes so we don't have to copy pieces of code but just can take them over. Then virtual classes allow to write code that transcends actual implementations which we needed and which was the aim to use these SFAR classes in our case. Which I didn't cover yet in the previous slide is that an object is also validated so when making an object the data types given in the parameters of the object are checked with the data types that are defined in the slots of the classes and only if they meet the object will be created. This means that once an object is created you don't need any checkups in your methods which can save you a lot of coding. This advantage is of course that defining classes with slots and methods requires some specific code and you have to make yourself familiar with it first. Another disadvantage of SFAR classes in R is that methods have to be defined apart from the class with slots in this case. This is actually different from the typical object oriented programming languages where a class including slots and methods has to be defined in one function like block of code. So for SFAR classes this is not the case and it's really recommended for clarity to group the class and method definitions together in wild file. What about user friendliness? Well a developer often writes a constructor which is a regular function that envelopes the making of a new instance of an object. Applying a method on an object of SFAR classes is actually just the same as using a regular function so this means when a constructor is defined from the user perspective working with SFAR classes is exactly the same as working with a regular function so the type of coding that E is used of and in fact as a user you will only notice that you are dealing with SFAR classes if you examine the object itself into detail. By the way actually SFAR classes are more widely used than you may think. Some examples of packages are LME4 matrix TBI and then a lot of packages with spatial objects such as SP and REST. So to sum up you automated the assessment of conservation status by a routine consulting rules in a database and by using SFAR classes. Here defining a class allowed us to group different parameters in one object. Inheritance helped us to deal with variation in structure and the virtual class helped us to integrate these different rules into one workflow. Our package is available on GitHub but it is in Dutch however to allow you to use it as an example we added a vignette in English in which we explain and show how we used these SFAR classes in our package. Thank you for listening and if you have any questions don't hesitate to contact me.