Objects


Premium Content - Free Preview

The previous module discussed the basics of programming, but it didn't go into details of how code is structured. In the early days of programming, people wrote programs which were executed linearly from top-to-bottom, and the most structure they had was separation of code into different tasks.

You saw simple examples of this in the algorithm flowcharts, and in the code you've programmed. This type of linear programming can work well for small pieces of code, but it becomes more difficult when projects grow in size. Complex applications cannot be modeled well with long linear code, so a more-structured approach to programming is needed.

Objects

Java enforces a programming methodology known as Object-Oriented Programming (OOP). OOP is inspired by the real world, where people interact with different objects to do different tasks. An Object has behaviors that it does, and it has a current state that its in. For example, a car might have the following behaviors:

  • accelerate
  • brake
  • brighten Lights

while its current state might be:


End of Free Content Preview. Please Sign in or Sign up to buy premium content.

Comments

  • I think it would be good if pictures with schemes could be zoomed

  • OK you can click on the pictures for larger ones. Code can be disorganized without objects, objects let code be organized into components that communicate with each other.

All Node Comments
Contact Us
Sign in or email us at [email protected]