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

Classes

A class is an abstraction describing the common features of all members in a group of similar objects. For example, a class called 'Student' could be used to describe all student objects recognized by the Student Registration System.

A class defines:

  • The data structure (names and types of attributes) needed to define an object belonging to that class.
  • The operations (methods) to be performed by such objects: specifically, what these operations are, how an object belonging to that class is formally called upon to perform them, and what 'behind the scenes' things an object has to do to actually carry them out.
For example, the Student class might be defined to have the following nine attributes:

Student class attributes

which means that each and every Student object must have these same nine attributes. Note that many of the attributes can be represented by data types built into a programming language (e.g. String, Float, and Date) but that a few — advisor, courseLoad, and transcript — are too complex for a built-in data type to handle; we'll learn how to tackle such attributes a bit later on.

In terms of operations, the Student class might define five methods as follows:

  • registerForCourse
  • dropCourse
  • chooseMajor
  • changeAdvisor
  • printTranscript
Note that an object can only do those things for which methods have been defined by the object's class. In that respect, an object is like an appliance: it can do whatever it was designed to do (a VCR provides buttons to play, pause, stop, rewind, and record movies), and nothing more (you cannot ask a VCR to toast a bagel — at least not with much chance of success!). So, an important aspect of successfully designing an object is making sure to anticipate all of the behaviors it will need in order to carry out its 'mission' within the system. We'll learn how to determine what an object's mission, data structure, and behaviors should be, based on the requirements for a system, in Part 2 of the book.

The term feature is used to refer interchangeably to either an attribute or a method of a class. Features are the building blocks of a class: virtually everything found within a class definition is either an attribute or a method of the class.

In the Java language, several other types of things wind up getting included within the boundaries of a class definition, but we won't worry about these until we get to Part 3 of the book. Conceptually, it is perfectly appropriate to think of an object as consisting only of attributes and methods at this point in time.
A Note Regarding Naming Conventions

It is recommended practice to name classes starting with an upper case letter, but to use mixed case for the name overall: Student, Course, Professor, and so on. When the name of a class would ideally be stated as a multi-word phrase, such as 'course catalog', start each word with a capital letter, and concatenate the words without using spaces, dashes, or underscores to separate them: for example, 'CourseCatalog'.

Method and attribute names use the same mixed-case concatenation convention, except that they start with a lower case letter. Example method names could be 'getName' and 'registerForCourse', with 'name', 'studentId', or 'courseLoad' as attribute names.




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