What terminology describes a method that modifies the internal data of its implicit parameter?

The idea behind Object Oriented paradigm is to "treat" the software is composed of .. well "objects". Objects in real world have properties, for instance if you have an Employee, the employee has a name, an employee id, a position, he belongs to a department etc. etc.

The object also know how to deal with its attributes and perform some operations on them. Let say if we want to know what an employee is doing right now we would ask him.

employe whatAreYouDoing.

That "whatAreYouDoing" is a "message" sent to the object. The object knows how to answer to that questions, it is said it has a "method" to resolve the question.

So, the way objects have to expose its behavior are called methods. Methods thus are the artifact object have to "do" something.

Other possible methods are

employee whatIsYourName employee whatIsYourDepartmentsName

etc.

Functions in the other hand are ways a programming language has to compute some data, for instance you might have the function addValues( 8 , 8 ) that returns 16

// pseudo-code function addValues( int x, int y ) return x + y // call it result = addValues( 8,8 ) print result // output is 16...

Since first popular programming languages ( such as fortran, c, pascal ) didn't cover the OO paradigm, they only call to these artifacts "functions".

for instance the previous function in C would be:

int addValues( int x, int y ) { return x + y; }

It is not "natural" to say an object has a "function" to perform some action, because functions are more related to mathematical stuff while an Employee has little mathematic on it, but you can have methods that do exactly the same as functions, for instance in Java this would be the equivalent addValues function.

public static int addValues( int x, int y ) { return x + y; }

Looks familiar? That´s because Java have its roots on C++ and C++ on C.

At the end is just a concept, in implementation they might look the same, but in the OO documentation these are called method.

Here´s an example of the previously Employee object in Java.

public class Employee { Department department; String name; public String whatsYourName(){ return this.name; } public String whatsYourDeparmentsName(){ return this.department.name(); } public String whatAreYouDoing(){ return "nothing"; } // Ignore the following, only set here for completness public Employee( String name ) { this.name = name; } } // Usage sample. Employee employee = new Employee( "John" ); // Creates an employee called John // If I want to display what is this employee doing I could use its methods. // to know it. String name = employee.whatIsYourName(): String doingWhat = employee.whatAreYouDoint(); // Print the info to the console. System.out.printf("Employee %s is doing: %s", name, doingWhat ); Output: Employee John is doing nothing.

The difference then, is on the "domain" where it is applied.

AppleScript have the idea of "natural language" matphor , that at some point OO had. For instance Smalltalk. I hope it may be reasonable easier for you to understand methods in objects after reading this.

NOTE: The code is not to be compiled, just to serve as an example. Feel free to modify the post and add Python example.


Page 2

Here is some explanation for method vs. function using JavaScript examples:

test(20, 50); is function define and use to run some steps or return something back that can be stored/used somewhere.

You can reuse code: Define the code once and use it many times.

You can use the same code many times with different arguments, to produce different results.

var x = myFunction(4, 3); // Function is called, return value will end up in x function myFunction(a, b) { return a * b; // Function returns the product of a and b }

var test = something.test(); here test() can be a method of some object or custom defined a prototype for inbuilt objects, here is more explanation:

JavaScript methods are the actions that can be performed on objects.

A JavaScript method is a property containing a function definition.

Built-in property/method for strings in javascript:

var message = "Hello world!"; var x = message.toUpperCase(); //Output: HELLO WORLD!

Custom example:

function person(firstName, lastName, age, eyeColor) { this.firstName = firstName; this.lastName = lastName; this.age = age; this.eyeColor = eyeColor; this.changeName = function (name) { this.lastName = name; }; } something.changeName("SomeName"); //This will change 'something' objject's name to 'SomeName'

You can define properties for String, Array, etc as well for example

String.prototype.distance = function (char) { var index = this.indexOf(char); if (index === -1) { console.log(char + " does not appear in " + this); } else { console.log(char + " is " + (this.length - index) + " characters from the end of the string!"); } }; var something = "ThisIsSomeString" // now use distance like this, run and check console log something.distance("m");

Some references: Javascript Object Method, Functions, More info on prototype

Chapter12Assignment(Spring2021).doc

Screenshot_20220409-112546_OneDrive.jpg

Thesis_Week 6_ Final Project.docx

Madi Dunn Protein lab.docx

Raisa Figueroa pre approval.pdf

12. REI ch. 9_debate 3 AFTA_fall_2022_External.pdf

film studies essay 1.docx