Hey codeCademy!
I had a few general questions to ask about the code in relationship to objects, properties, and getters. I write within the "General Programming" forum as I would like to know if their is a relation which exhists across multiple languages (Right now, I assume it could just be a JavaScript example due to the way the language has been designed, however I was wondering if other languages include these questions listed below):
Questions:
-
If the object can contain a method where we pass code within the property, could a function store an object which stores another function? in addition, If we were to manipulate the object within the function… would we do so by utilizing the .method (getters/setters) outside of the function by calling the object and using this method to re-define its parametres? If we know functions are always calling the constant of the “rules” in which we have defined withing them… could calling theFunction + theChange help produce a different output?
-
If so… is it quicker to code this way?
→ Create the objects you want the function to store… Add their properties… and then create an overall functioning of the objects. Once made we can edit objects using the .method approach where we can use Getters and Setters to define the values of each property? That way we can easily update and change the functions when we like. -
For the coding languages in general is their an approach which will help us shorten the lines of code the computer needs to process for a more efficent processing speed? would creating functions which run intended opperations and then just having a program which calls each condensed function be a practical approach?
For Example; a non complex decision based game made up of 11 functions: 10 which hold 10 characters and all of their attributes and then an 11th function determines how the 10 functions would interact with one another based on the players decsions. IF/Else statements would be used to define which of the 10 fucntions create this dynamic. Do you think this approach would be possible to make something that can run with the simple coding between 11 different words and their 10^11 combinations?
Hope this makes sense!
Thanks,
Bello