Thursday, 23 January 2014
Week 3 - Object Oriented Programming: From Words to Code
Going from a problem written in words to a solution written in code is the goal for all programmers. Object oriented programming is one way to do just this, focusing on key words, typically nouns, and turning them into "objects", custom classes featuring their own constructors and any other attributes you choose to define for them. They can interact with other objects and preform functions defined for them, usually by verbs in the original problem.
The usefulness of objects and object oriented programming is clear, simplifying problems into a series of statements which define which objects are to be created, what they should look like, what they should be able to do and how they should interact with other objects. Other than just making problems more comprehensible, I believe that the real power of object oriented programming is that it makes code more readable and closer to actual language. It's not so hard to see how,"The dog played with the toy." can become Dog.play(Toy), where dog and toy, two nouns, become objects, and play, a method. This makes it feel less like coding and more like communicating with the computer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment