Re: trouble creating array of objects
From: Gavin Deane (deane_gavin_at_hotmail.com)
Date: 12/05/03
- Next message: Karl Heinz Buchegger: "Re: writing to a string"
- Previous message: Karl Heinz Buchegger: "Re: <ctype.h> toLower()"
- In reply to: Jumbo: "Re: trouble creating array of objects"
- Next in thread: Jumbo: "Re: trouble creating array of objects"
- Reply: Jumbo: "Re: trouble creating array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Dec 2003 04:33:36 -0800
"Jumbo" <pcrcutitout1000011@uko2.co.uk> wrote in message news:<1070567051.579443@news.minx.net.uk>...
> "Gavin Deane" <deane_gavin@hotmail.com> wrote in message
> news:6d8002d0.0312041056.4bc555bf@posting.google.com...
> > "Jumbo" <pcrcutitout1000011@uko2.co.uk> wrote in message
> news:<1070456535.760343@news.minx.net.uk>...
> > > "Gavin Deane" <deane_gavin@hotmail.com> wrote in message
> > > news:6d8002d0.0312030426.6c2da3ce@posting.google.com...
> > > > "Jumbo" <pcrcutitout1000011@uko2.co.uk> wrote in message
> news:<1070368078.78862@news.minx.net.uk>...
> > I'd also be interested to know _why_ efficiency is such a concern. If
> > you personally enjoy the challenge of absolutely maximising runtime
> > efficiency then that's obviously your choice. But that approach often
> > won't be relevant to other people learning the language, unless they
> > happen to be learning because they enjoy the same challenge.
>
> It's not so much that it is of so much concern it's more a point of
> awareness.
> I can appreciate the view that vectors are an ease to use I just don't see
> the point in introducing them unecessarily as this is their only benefit (
> ease of use ) and it does not give the person who is learning any more
> understanding of dynamically allocated 2D Arrays.
Depending on your objective, ease of use (including the fact that the
library does not need to be re-debugged every time you use it) might
be the most important criterion. Professionally, it almost always will
be. How quickly you can write clear, maintainable, correct source code
is what it's all about. Someone learning towards a career in
programming would want to take that approach. Someone learning for any
other reason could have completely different priorities. But a common
desire is to spend as little as possible time debugging, by getting as
much right in the first place. The standard library can help you do
that.
> > For someone learning C++ to program professionally, the sooner they
> > understand that runtime efficiency should rarely be a major concern,
> > the better off they will be. And many people programming as a hobby
> > are more interested in getting correct programs up and running as
> > quickly as possible, to get a feeling of making progress. For anyone
> > falling into either of these groups, your argument about needing to
> > know how a vector works simply doesn't apply. That is why people in
> > this newsgroup are at pains to point out that your concerns about
> > vectors (and the standard library in general) may well not translate
> > to other people's requirements.
>
> You shouldn't be programming professionally if you are using STL without
> understanding templates.
I'm considering someone learning _towards_ a career in programming.
Learning how to use of the library will be a priority, so I believe
there is benefit in simply stating that you declare a vector of ints
as vector<int> early on and leaving it at that. What the <int> syntax
really means can come in a later lesson. How to write template classes
(as well as how to declare and use dynamically allocated arrays and
how to avoid shooting yourself in the foot with them) will come later
still.
Even when you get your first programming job, there will hopefully be
more experienced programmers around you. Your skills in using the
library will be more immediately important than whether you are able
to reimplement it if you choose to. If that does become necessary, the
nature of the task means it will not be given to someone very junior
and inexperienced without careful oversight and guidance. Modern
commercial C++ (that's pure C++, not C++ "as a better C") programs do
not often contain explicit arrays (multidimensional or otherwise).
> And if your programming purely as an interest then there no need to get
> involved with advanced STL classes whilst going through your learning curve
> until you have reached the point where you are ready to learn templates.
Again, depending on your viewpoint and objectives, you could equally
well argue that there is no immediate need to get involved with
advanced explicit memory management and the issues that surround it,
when the library provides a way to hide the detail and the problems
from you and get your programs working quickly and easily.
There is no need to think of the language and the library as separate
entities. If a feature is implemented in the library rather than the
language, that in now way implies that it is necessary to understand
all the core language features used to implement that library feature
before you use it. That's why the library was invented. It's not just
for experienced programmers, everyone can use it straight out of the
box. And it allows to you program at a higher, more abstract level.
You worry about the fact that you're trying to store and retrieve
entries in a phone book for example, without being concerned about
_how_ the computer actually does any of that. (OK maybe a list or a
map might be more appropriate than a vector for a phone book, but I
hope you get the idea).
It takes experience (and the ability to use a profiler) to correctly
identify those situations where the implementation of the standard
library is not suitable for your needs. So there needn't be any hurry
to teach how it works internally.
> I
> say advanced template classes but I mean that the use of cout and cin for
> example is necessary to aid learning but they do not use explicit template
> initialisation, the moment you introduce explicit template initialisation
> syntax the programmer is going to want to understand what this is all about,
> otherwise they will be confused by it.
I think you need to change "will be confused" to "might be confused".
Many people will be quite happy (or, at least, content enough to
continue with the course) to be told "When you want a vector of ints,
you write vector<int>. Why you do that is a bit complex, but we will
be covering it later in the course. For now, you can just use it and
it works". After all, they've probably already taken things like
#include and using namespace std; on faith.
> To learn from the ground up is conventional learning and works well why
> change it ?
Learning can be very different for different people. That is why
teaching is so hard and a good teacher is invaluable.
-- GJD
- Next message: Karl Heinz Buchegger: "Re: writing to a string"
- Previous message: Karl Heinz Buchegger: "Re: <ctype.h> toLower()"
- In reply to: Jumbo: "Re: trouble creating array of objects"
- Next in thread: Jumbo: "Re: trouble creating array of objects"
- Reply: Jumbo: "Re: trouble creating array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|