R Object: S3 vs S4 (Assignment 7)
Greetings Professor,
In this assignment #7, I used the Object Oriented Systems S3 and S4 for completing this assignment. I created a new dataset by taking your example as an reference. And also answered the questions for the datasets S3 and S4.
1.S3 implements a generic function OO and it is different from many other programming languages like Java, C++, C, these implements message-passing using OO. In the other programming languages, by calling methods to the objects and these objects determines which has to be called. This process is called "method call". But S3 is totally different by calling the methods via a special type of function called a 'generic function' and this decides which function has be to called. S4 and S3 works similarly by few differences. S4 have special functions to call or to define the generic functions and methods. And also it can pick methods based on number of arguments.
2. To determine the base type(like integer or list) of an object 'typeof()' function is used in the input.
3. A generic function is the function where it is applicable to different types of inputs and gives the output by type of input which we given. R has 3 OO systems: S3, S4, R5 and these all works based on the conpects of class and methods. And also S3 have many generic functions compare to the S4.
4. The differences between S3 and S4 datasets are:
a. In dataset for S3 the objects are created by using list() function and dataset for S4 the objects are created by using new() function.
b. In dataset S3 the objects are not declared but in dataset S4 objects are declared as "student".
c. In dataset S3 there's no object creation so we need to give the print() function and in S4 we donot need to give the print() function as the objects are created. Simply, S4 is equal to S3 print() function in this function.
5. In Github, I created datasets by using both S3 and S4 OO systems and I uploaded the file with code and the results in my GitHub repository. This is my GitHub repository link attached below:
https://github.com/Jahnavi193/Assignment7#assignment7
And also I am attaching the code pictures below professor. Thank you.
Comments
Post a Comment