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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
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%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs