Object-oriented programming (OOP) is a model for programming language centered and modeled around objects and data, rather than actions or logic. Traditionally, a program was seen as just a logical procedure that takes an input data, and after processing it, returns an output data. Furthermore, as stated earlier, object-oriented programming is based on objects. Objects are abstract data types. They are structures that contain data, often known as attributes, and code, known as methods. Additionally they have both a state (data) and behavior (code).
In this type of programming (object-oriented), the programs are designed to interact with one another. While, there are diverse ways of object-oriented programming, most languages are class-based. This means that the objects are instances of classes; this determines their type. Python, C#, C++, Java, Perl, and many other computer languages are significant object-oriented languages. In class, we have been learning object-oriented programming and concepts. Object-oriented programming concepts, then are concepts such concepts as learned in class, such as classes, subclasses (and Inheritance), stacks, queues, and trees.
The concept of data class, makes it possible to define subclasses of data objects, that share some of the main class characteristics or attributes. The process of inheritance, which is crucial to programming subclasses, is a more efficient way of coding, since it reduces time spent programming the same functions as well as ensure a more accurate code. Additionally, the concept of classes allows a programmer to create a new data type not already defined in the language itself. This is useful for many reasons. One of the main reasons, classes are useful and make your code more efficient, is that when implementing classes, the programmer has control over the whole class as well as any subclasses.
Additionally, as when used in Assignment 1, classes can be used to make a general class, with more specific subclasses. In this way, a general class for a game state, can have numerous subclasses for specific games, such as tic-tac-toe, subtract square or even connect 4. While the game state for these games are unique and different in many ways, they do share some similar attributes and are the same "type" of game. They are both 2 player, sequential, zero sum games, and having a general game state to reflect this is quite useful. Using object-oriented programming is very useful and has numerous advantages.
No comments:
Post a Comment