advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement


Reviews : Java Books :
Beginning Java Objects : Chapters 2 and 3

Title: Beginning Java Objects
ISBN: 1861004176
US Price: $ 39.99
Canadian Price:
C$ 59.95
UK Price: £ 28.99
Publication Date: November 2000
Pages: 800
© Wrox Press Limited, US and UK.

Beginning Java Objects: Chapter 3
Objects and Classes

Composite Classes

Whenever we have a class, such as Student or Professor, in which one or more of the attributes are themselves references to other objects, we refer to the class as a composite class. The number of levels to which objects can be conceptually bundled inside one another is endless, and so composite classes enable us to model very sophisticated real world concepts. As it turns out, most 'interesting' classes are composite classes.

image 20

With composite class instances, it appears as though we are nesting objects one inside the other:

Object nesting does indeed sometimes make sense: namely, if an object 'A' doesn't have a life of its own, and only exists for the purpose of serving enclosing object 'B'.

  • Think of your brain, for example, as an object that exists only within the context of your body (another object).
  • As an example of object nesting relevant to the SRS, let's consider a grade book used to track student performance in a particular course. If we were to define a GradeBook class, and then create GradeBook objects as attributes — one per Course object — then it might be reasonable for each GradeBook object to exist wholly within its associated Course object. No other objects would need to communicate with the GradeBook directly; if a Student object wished to ask a Course object what grade the Student has earned, the Course object might internally consult its embedded GradeBook object, and simply hand a letter grade back to the Student.

However, as we saw in the sample Student and Professor classes above, we often encounter a situation where an object 'A' needs to refer to an object 'B', object 'B' needs to refer back to 'A', and both objects need to be able to respond to requests independently of each other. In such a case, we cannot physically embed one object wholly inside the other; this would lead to infinitely recursive nesting.

image 21

Handles come to the rescue! In reality, we are typically not storing whole objects as attributes inside of other objects, but rather references to objects. When an attribute of an object 'A' is defined in terms of an object reference 'B', the two objects exist separately in memory, and simply have a convenient way of finding one another whenever it is necessary for them to interact. Think of yourself as an object, and your cellular phone number as your handle. Other people — 'objects' — can reach you to speak with you whenever they need to, even though they don't know where you are physically located, using your phone number.




How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 34
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

IBM Brings Developers Into the Cloud
Apache at 10: You Can't Buy Us
Microsoft's CodePlex Foundation Moving Forward
Apple Claims 100,000 Apps, Google Analyzes Them
Nokia Latest to Play Opera Mobile 10 Browser
PayPal Opens Up Payment Platform to Devs
Ubuntu Linux 9.10 'Karmic Koala' Starts Its Climb
IBM Links Rational Developer Tools, Tivoli Apps
Libraries Give Vista Apps a Windows 7 Look
Ubuntu: The 'Default Alternative' to Windows?

Delivering Web-based Embedded Fonts in CSS 3
Adobe Helps PHP Developers Create Rich Internet Applications
Java Developers Finding a Home at Adobe Flex
Virtualization Delivers a Dynamic Infrastructure
Consuming XML Web Services in iPhone Applications
Build a More Agile Business with IBM
POJO-Based Solutions for LDAP Access: One Good, One Better
IBM Offers Enhanced Measurement and Management for Energy Usage
IBM Helps Transformation to an Information-Based Enterprise
Top Five Touch UI-Related Design Guidelines

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs