473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Classes

I'm new. All of my books when talking about classes always use some
sort of "database" example, e.g. tracking stock, tracking baseball
stats, etc.

I'm trying to think OOP and wonder is there are uses for classes for ME
to use within my program. In other words a class of ? to help me to do
?. I can't see that this would be different than a function, or am I
completely missing it.

Any comments, ideas or short examples would be appreciated.

Nov 22 '05 #1
6 1529
In article <11**********************@g47g2000cwa.googlegroups .com>,
arganx <ar*******@yahoo.com> wrote:
I'm new. All of my books when talking about classes always use some
sort of "database" example, e.g. tracking stock, tracking baseball
stats, etc.

I'm trying to think OOP and wonder is there are uses for classes for ME
to use within my program. In other words a class of ? to help me to do
?. I can't see that this would be different than a function, or am I
completely missing it.

Any comments, ideas or short examples would be appreciated.


In many cases you actually _do_ just want a function.
Note that that focuses often on solely an perspective
that is algorithmic, simple, and perhaps only a uni-operation.
Classes tend to focus on types, subsystems, and relationships
up and down related types, along with their usually
multiple operations. The question isn't solely just
can't I just use functions to code up my problems,
because obviously computer languages have been around
for a while, and people have been able to provide fairly
elaborate applications even though those lanuages did not
directly support OOP. The issue is more of how we can break
down problems, spell out the interaction and operations
which need to occur, and best design and model the task at hand.

Unfortunately, we cannot do your question justice in a NG, however,
I know you express what many folks wonder, and go through.
For well thought out ideas, etc I would suggest getting
the below two books in addition to your current ones.

I would get Stroustrup's The C++ Programming Language
(3rd or special edition) and have a look at Chapter 2, 1,
23, 24, 25. These are issues pretty much never ever discussed
in many so-called beginner [C++] books, and yet they are
exactly about what most of it's all about. It's ok if
you don't get everything on your first read because you
will have this book for a long time. Better yet, get
two copies and wallpaper the room with it.

Similarly, get Koenig and Moo's Accelerated C++. It tends
to reverse the normal introductory progression from the
random low-level hen-pecking solutions looking for problems
approach and throws you right into what it's all about
such as abstraction, problem solving, class design, etc.

These two texts are authoritative, to the point, insightful,
and then some. Neither is particularly an easy read for
everybody, however, they are spot on where you need to be.

See http://www.comeaucomputing.com/booklist for isbn info, etc.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Nov 22 '05 #2
"arganx" writes:
I'm new. All of my books when talking about classes always use some
sort of "database" example, e.g. tracking stock, tracking baseball
stats, etc.

I'm trying to think OOP and wonder is there are uses for classes for ME
to use within my program. In other words a class of ? to help me to do
?. I can't see that this would be different than a function, or am I
completely missing it.

Any comments, ideas or short examples would be appreciated.


That is, indeed, a significant problem It might help if we knew what field
you were in. If you are an old-timey programmer, think of a stack, a linked
list, a tree, a string as a nice repository of handy tools you can pick up
and use.

A person who writes simulators could have a random number class that
provides, a bunch of different distributions. Uniform, Gaussian, Poisson,
.... and a selection of generators of varying qualities.

If you are into statistics, you could have classes that do some of the
common things, standard deviation, chi-square, ... in classes.

If you are into math you could have a matrix class. And of course, most
everyone in any of the sciences can use the complex class, which is, more or
less, built in, to C++.

I would think an architect could use a window (NOT tm) class, a door class,
an elevator class.

Another approach, it may be helpful to think of a class as a mini program
with a, possibly, very rich interface.
Nov 22 '05 #3
"osmium" wrote:

<snippage>
That is, indeed, a significant problem It might help if we knew what
field you were in. If you are an old-timey programmer, think of a stack,
a linked list, a tree, a string as a nice repository of handy tools you
can pick up and use.


One thing I forgot to mention. There are a lot of people who will go to
great lengths to use classes, even when, IMO, the payback is actually
negative. I think OOP has been grossly oversold, and I wish someone had told
me that many years ago. I had to figure it out for myself.

The attitude of many seems to be "I have this great new hammer and I'll be
damned if I am going to let it just rust away in the toolbox...." OOP and
classes are far from a silver bullet.
Nov 22 '05 #4
arganx wrote:
I'm new. All of my books when talking about classes always use some
sort of "database" example, e.g. tracking stock, tracking baseball
stats, etc.

I'm trying to think OOP and wonder is there are uses for classes for ME
to use within my program. In other words a class of ? to help me to do
?. I can't see that this would be different than a function, or am I
completely missing it.

Any comments, ideas or short examples would be appreciated.


Don't think of "objects" as physical objects. Often, it is ideal, but
often it will lead you astray.

A class is used to encapsulate some data along with operations on that
data. You can use it to abstract the implementation of a concept; that
concept could be anything, but usually it involves state (stored in the
data, and operated on by the methods).

As you gain experience with programming you will (hopefully!) learn to
think in terms of abstractions of concepts - the rest is relatively easy.

Ben Pope
Nov 22 '05 #5
Thank you all for your comments. It has given me ideas to think about
and other references to study.

Nov 22 '05 #6
osmium (r1********@comcast.net) wrote:
: "osmium" wrote:

: <snippage>

: > That is, indeed, a significant problem It might help if we knew what
: > field you were in. If you are an old-timey programmer, think of a stack,
: > a linked list, a tree, a string as a nice repository of handy tools you
: > can pick up and use.

: One thing I forgot to mention. There are a lot of people who will go to
: great lengths to use classes, even when, IMO, the payback is actually
: negative. I think OOP has been grossly oversold, and I wish someone had told
: me that many years ago. I had to figure it out for myself.

I agree. I was taught top-down structured programming (Dijkstra et. al.)
25-30 years ago and have had a difficult time re-thinking in OOP.
Object-oriented design is fine, but my OOP tends to go back to the old way
of thinking to the point I said the heck with it.

I think if you can come up with (a) data structure(s) that can handle your
application, then the code will come out of that (i.e. think data first
and code second and your OO approach tends to fall into place).

: The attitude of many seems to be "I have this great new hammer and I'll be
: damned if I am going to let it just rust away in the toolbox...." OOP and
: classes are far from a silver bullet.

Agreed.

Eric
Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
9
by: Jack | last post by:
Hello I have a library of calculationally intensive classes that is used both by a GUI based authoring application and by a simpler non-interactive rendering application. Both of these...
9
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to...
12
by: Langy | last post by:
Hello I'm fairly new to C++ but have programmed several other languages and found most of c++ fairly easy (so far!). I've come to a tutorial on classes, could someone please tell me why you...
4
by: john townsley | last post by:
do people prefer to design classes for the particular job or for a rangle of tasks they might encounter now and in the future. i am doing some simple win32 apps and picking classes is simple, but...
2
by: joye | last post by:
Hello, My question is how to use C# to call the existing libraries containing unmanaged C++ classes directly, but not use C# or managed C++ wrappers unmanaged C++ classes? Does anyone know how...
18
by: Edward Diener | last post by:
Is the packing alignment of __nogc classes stored as part of the assembly ? I think it must as the compiler, when referencing the assembly, could not know how the original data is packed otherwise....
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
0
by: ivan.leben | last post by:
I am writing this in a new thread to alert that I found a solution to the problem mentioned here: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/7970afaa089fd5b8 and to avoid...
2
by: Amu | last post by:
i have a dll ( template class) ready which is written in VC++6. But presently i need to inherit its classes into my new C#.net project.so if there is some better solution with u then please give me...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.