Home arrow Java & J2EE arrow Page 2 - Java and Object-Oriented Programming

How State and Behavior Affect One Another - Java

In the olden days, not only did we have to walk a mile in the chilling winds of a snowstorm to get to school (hey our grandparents had it rougher; they had to do it to get to day care), we also had to make programs without buttons and scrollbars. Now, of course, we have object-oriented programming. This article will introduce you to the most important concepts as they relate to Java.

TABLE OF CONTENTS:
  1. Java and Object-Oriented Programming
  2. How State and Behavior Affect One Another
  3. Class, Inheritance and Interface
  4. All About Variables
By: James Payne
Rating: starstarstarstarstar / 15
September 19, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Simply put, when you change the state of an object, you ask it to perform a behavior. An object stores its states in a field (commonly referred to as variables, which will be discussed in further depth later) and demonstrates its behaviors through methods (known as functions, also covered later).

When you press the power button on your computer, it places it in the On state. Because we have changed the state of the computer (from Off to On), we have also initiated certain behaviors from the computer. In this case, the power comes on, the fans within the computer turn on, and the system bios, followed the hard drive, etc. all become active.

Note that an object can only have the states and behaviors you place upon it. I cannot press the on button of my computer and receive a bologna sandwich unless the programmer coded that in. (Note to self: add bologna sandwich dispenser to computer).

Benefits of Objects

Aside from being shiny and fun to look at, objects within a program offer several benefits.

  1. Modularity: You can write the code for the object within the object itself, keeping it separate from other coding, while still being able to call upon it at any time.

  2. Hiding Information: Planting your code within your object makes it less visible to the user.

  3. Reuseability: Once created, an object can be copied and used again and again without having to go through the process of remaking it.

  4. Debugging Made Simple: Objects make debugging easier in some instances. If you track the problem to a button within your application, you can simply remove the button and remake it, instead of having to delve into your main code.



 
 
>>> More Java & J2EE Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: