Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
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,
Old August 11th, 2011, 09:44 AM
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 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)
The Following User Says Thank You to DrPurdum For This Useful Post:
Howard Pai (August 14th, 2011)

Similar Threads
Thread Thread Starter Forum Replies Last Post
A basic assembly question Aiolia Lee BOOK: Professional Assembly Language 3 December 25th, 2012 07: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 10:06 AM
basic xslt Question abhishek verma XSLT 4 January 24th, 2006 05:35 AM
basic question but..... Adam H-W Javascript How-To 2 February 10th, 2004 01:24 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.