class10 Notes

class10 Notes - 1 1 IST 240 Thu (2/14) Ch 5: More classes...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 1 IST 240 Thu (2/14) Ch 5: More classes In-class exercise Done via extreme programming method Hwk #5 Ch 5: due Wed 2/20 at 11:59pm Ex 5.1, 5.3, 5.11, 5.13 PP 5.5 Tue (2/19) UML Introduction + more classes Thu (2/21) Ch 6: Introduction to Graphical User Interfaces (GUIs) 2 5.3 Encapsulation We can take one of two views of an object internal - the details of the variables and methods of the class that defines it external - the services that an object provides and how the object interacts with the rest of the system From the external view, an object is an encapsulated entity, providing a set of specific services These services define the interface to the object 2 3 5.3 Encapsulation One object (called the client ) may use another object for the services it provides The client of an object may request its services (call its methods), but it should not have to be aware of how those services are accomplished Any changes to the object's state (its variables) should be made by that object's methods We should make it difficult, if not impossible, for a client to access an objects variables directly That is, an object should be self-governing 4 5.3 Encapsulation An encapsulated object can be thought of as a black box its inner workings are hidden from the client The client invokes the interface methods of the object, which manages the instance data Methods Data Client 3 5 5.3 Visibility Modifiers In Java, we accomplish encapsulation through the appropriate use of visibility modifiers A modifier is a Java reserved word that specifies particular characteristics of a method or data We've used the final modifier to define constants Java has three visibility modifiers: public , protected , and private The protected modifier involves inheritance, which we will discuss later 6 5.3 Visibility Modifiers public private Variables Methods Provide services to clients Support other methods in the class Enforce encapsulation Violate encapsulation 4 7 5.3 Accessors and Mutators Because instance data is private, a class usually provides...
View Full Document

Page1 / 12

class10 Notes - 1 1 IST 240 Thu (2/14) Ch 5: More classes...

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

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