Programming in Java on Your Computer
- Classes and Objects in BlueJ
- Trying out Code in BlueJ
- The Code for Creating and Using Objects
- Source Code and Methods
- Accessors and Mutators
- Constructor Code
- Class Code
- Simple Debugging
- Interactive Picture
- Refactoring Code with Inheritance
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.
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:
- brighten Lights
while its current state might be:
End of Free Content Preview. Please Sign in or Sign up to buy premium content.
caloJan 14, 4:31 PM
I think it would be good if pictures with schemes could be zoomed
LearnerooSep 24, 1:18 PM
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.