Jump to content

I explain objects in coding just as objects in real life, for an example a microwave


G+_James Coleman
 Share

Recommended Posts

I explain objects in coding just as objects in real life, for an example a microwave.

 

When you look at a microwave, you can see it has many functions: you can turn it on for a specific amount of time, you can change the power setting, and you can stop the microwave. These functions are quite useful in code and are easy to write in code when you deal with objects. The microwave object will store state for the current time, when the microwave should stop, if the microwave is currently on, and the current power setting. Functions that would be in the microwave object are start, watch time, and stop. When you call the start function, the microwave object will store the time to stop, start the microwave, and call the watch time function. The watch time function will watch for when we have reached the time to stop and call the stop function. Putting the microwave functions in code would be useful if you were to have a web server object and you wanted to be able to turn on the microwave to warm up your food from a remote location.

Link to comment
Share on other sites

 Share

×
×
  • Create New...