Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3
This is the forum to discuss the Wrox book Beginning C# 3.0 : An Introduction to Object Oriented Programming by Jack Purdum; ISBN: 9780470261293
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 8th, 2011, 07:35 AM
Registered User
 
Join Date: Aug 2011
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default a basic question

Dear Dr. Jack Purdum,
I really appreciate your devotion on this excellent book Beginning C# 3.0.

I’m a complete novice at programming. I understand the analogy between a cookie cutter and a class, but the terms “class, object, and variable” are confusing me.

For example, on page 27, you say that “…The purpose of the myFriend variable is to tell us where to find the data associated with the myFriend object.”

Could you please give me clear insight into the definition and relation of class, object, and variable?

Thank you

Kind regards,
Howard
Reply With Quote
  #2 (permalink)  
Old August 11th, 2011, 09:44 AM
Friend of Wrox
Points: 1,104, Level: 13
Points: 1,104, Level: 13 Points: 1,104, Level: 13 Points: 1,104, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 224
Thanks: 0
Thanked 30 Times in 29 Posts
Default Class vs Object vs Variable

A class is the formal definition of an object. Just like blueprints can define a building or a recipe can define a cake, a class tells you how to model or construct an object. I do like the cookie cutter analogy for a class. If the details tell you to "bend" the metal a certain way, you end up with a Christmas tree. If the details tell you to bend the edges a different way, you end up with a Star. The class defines how the object will look and what it can do. When you are done defining a class, you know exactly how it will look and act.

An object is the existence of a class. If you have a cookie cutter (as defined by the class details), but no cookie dough into which to press the cookie cutter, you don't have a cookie (an object of the class). An object is created (instantiated) when you take the cookie cutter (i.e., the class definition), press it into the dough (memory), and extract the resulting piece of dough (the object of the class). Now you are free to use the object (i.e., the cookie) as you see fit (e.g., bake it, eat it, put sprinkles on it, coat it with frosting, whatever).

A variable is really nothing more than some bytes in memory that have a name. For example, if you define an integer as:

int myVar;

the operating system (Windows) sets aside four bytes of memory and refers to it as myVar. The exact location of where myVar resides in memory is myVar's lvalue. The data stored in those four bytes of memory is myVar's rvalue. You have the ability to change myVar's rvalue through as assignment, but only the operating system can change it's lvalue.

I hope this helps.
__________________
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)
Reply With Quote
The Following User Says Thank You to DrPurdum For This Useful Post:
Howard Pai (August 14th, 2011)
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
A basic assembly question Aiolia Lee BOOK: Professional Assembly Language 3 December 25th, 2012 06:29 AM
Please HELP Very Basic Question jkoe578 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 18th, 2006 09:06 AM
basic xslt Question abhishek verma XSLT 4 January 24th, 2006 04:35 AM
basic question but..... Adam H-W Javascript How-To 2 February 10th, 2004 12:24 PM



All times are GMT -4. The time now is 11:54 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.