Classes - CS 1054 Rationale for Classes Classes 1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 1054 Classes Intro to Object-Oriented Dev I Computer Science Dept Va Tech Jan. 2006 ©2006 Barnette, ND 1 Rationale for Classes s Advantages of user-defined classes Avoids complexity through decomposition Allows programs to be designed as interactions/ collaborating objects Enables the programmer to create new types that can be used as conveniently as the built-in types. Allows problems to be modeled closely by abstracting real world problem entities. A program that provides types/classes that closely match the concepts of the application tends to be easier to understand and to modify than a program that does not. Allows easier testing of large programs through class/unit testing . Classes Intro to Object-Oriented Dev I Computer Science Dept Va Tech Jan. 2006 ©2006 Barnette, ND 2 Java Class construct s A Class is a template for instantiating objects s Classes contain instance (and constant) s Classes provide an encapsulation mechanism for restricting access to its contents s Classes allow for the abstraction and modeling of entities in problems s Attributes are represented by class variables The values of class variables give the state of an object s Behaviors are modeled by the class methods Methods represent the services offered by the object s Constructors are executed when an object is created The primary purpose of constructors is to initialize the object variables. Constructors ensure that an object is
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/30/2011 for the course ART 3514 taught by Professor Dhbannan during the Summer '03 term at Virginia Tech.

Page1 / 4

Classes - CS 1054 Rationale for Classes Classes 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online