Consider some things around you. Literally objects, like chairs, lamps, and pencils. Each has attributes, like weight, color, dimensions. Each has things your can do with them and possibly different ways of interacting with each other, or rules that protect them from misuse.
Object oriented programming is making computer data and process representation of these objects. You can have activities like “turn on” that make sense for lamps, but not chairs. Or maybe the is a chair where “turn on” makes sense, like a vibrating lounger. The size or color or uselessness of an object may be useful in parts of a program as the use of an object is attempted.
By making programs that understand these activities and different sets of attributes, we can create varieties of these data objects, and then treat them appropriately at the right time.
In real computing examples, you probably don’t have such diverse objects interacting. You’re probably going deal with them more abstractly. A store may sell chairs and lamps and pencils, but they don’t really turn them on our write with them. That’s information to share, not activity to perform. The dimensions and descriptions are more important.
In a game kind of programming, the myriad objects probably do get used more. A player might try to interact with an object. The lamp can inform that it can be turned on, the chair that it can be sat in, and the pencil that it can be used for writing or whatever. The things are a little “aware” of their capabilities, and can inform the uses when necessary.
Latest Answers