Java Programming

Only available on StudyMode
  • Download(s) : 142
  • Published : April 9, 2013
Open Document
Text Preview
ISM 6259 - Fall, 2012

Business Programming
Fall, 2012 Lecture Notes

ISM 6259

©2012 by Dave Small, all rights reserved

This document and its contents may NOT be redistributed NOR posted online (in whole or in part) without Dave Small's specific written permission

-1-

Lecture 01

ISM 6259 — Lectures #1 — 201208.21
©2012 by Dave Small, all rights reserved

Welcome!
Hi, I’m Dave!

Characteristics of Object-Orientation Encapsulation
grouping related ideas into a single unit that can be referred to by a single name ° Method (subroutine) encapsulates the steps of a process - saves human memory (chunking) - saves computer memory (don’t need to replicate code) ° Object-oriented encapsulation the packaging of operations and attributes (which represent state) into an object type so that an objects state will be accessed/modified only via the interface provided by the encapsulation.

Information/implementation hiding
the use of encapsulation to restrict the visibility of certain information and implementation decision that are internal to the encapsulation structure. ° Methods - hide individual statements - hide local data ° Objects - private methods - instance variables Allows us to separate an abstraction from a(n internal) representation The type used for a method’s return value can differ from the type used to represent the value internally. ° ex: complex numbers - real & imaginary component (e.g., −23.4 + 4i) - rho (magnitude) & theta (angle) ← describe a vector As a ComplexNumber class client (i.e., user), I do not care which technique - 2 (1 / 5) it uses to represent the values internally, only that externally it appears to uses

- rho (magnitude) & theta (angle) ← describe a vector
Lecture 01

As a ComplexNumber class client (i.e., user), I do not care which technique it uses to represent the values internally, only that externally it appears to uses the technique I’m expecting. ° ex: a robot that moves orthogonally on the Cartesian plane - direction can be represented by ’n’, ‘e’, ’s’, ‘w’ “north”, “east”, “south”, “west” 90, 0, 270, 180 (0,+1), (+1,0), (0,-1), (-1,0) 1, 2, 3, 4 0, 0.25, 0.50, 0.75 enumerated data-type Software requirements change over the program’s lifetime.

Benefits of info/implementation hiding
Localizes design decisions * private decisions have little (if any) impact on the system [not talking efficiency here, but usability] * modules can be modified with minimal fuss - avoids a cascade of required software changes when a module’s implementation is modified. * decouples the content (abstraction) from the representation Attribute is an externally visible property of an object - may correspond to an instance variable (no requirement) ex: consider a class TimeInterval which has three attributes - start time - stop time - duration all three of the attributes can be maintained using only two instance variables since given any two, the third can be derived. Operation an abstract behavior — a method is a specific implementation of a behavior ex: consider toString() - you override the default behavior so that it provides useful info about - 2 (2 / 5) your object.

Lecture 01 ex: consider toString() - you override the default behavior so that it provides useful info about your object.

toString()’s abstract behavior (i.e., the operation toString()) is “return a String describing this Object” — we provide a specific implementation (method) to do so in a way that is class appropriate.

State retention
° an object’s internal state is the set of values currently held in its instance variables ° an object’s extenal state is the set of values that it’s attributes currently have A module in a traditional procedural language has no memory of prior executions int plus1() { int i = 0; i = i + 1; return i; }

no matter how many times the procedure is called, it will always return 1 The workarounds are either: ° make i a global variable - there is only one copy and anything can mess...
tracking img