 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Lee Gobroski Guest
|
Posted: Tue Mar 29, 2005 8:04 am Post subject: To OOPs or not to OOPs!?!?!?!? |
|
|
Hello all,
I have been struggling with objects and what not for some time now. I was
wondering what the purpose of classes are when you have a function that will
do the same thing, and don't need to be instantiated. Are they really
faster, and better?
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
I know with my last little program, I had to use the TStringList object, but
I still don't really understand the need...
Thanks
Lee
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Mar 29, 2005 8:28 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Lee Gobroski wrote:
| Quote: | I have been struggling with objects and what not for some time now.
I was wondering what the purpose of classes are when you have a
function that will do the same thing, and don't need to be
instantiated.
|
None whatsoever.
Objects are useful when there is a collection of related functions that
manipulate or rely on state information. IOW if the functions need to
have some 'behind the scenes' intelligence.
They are also useful when you need to be able to create a generic
'thing' and then derive specialisations from that without the owner
knowing about it.
| Quote: | I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
|
You won't find a definitive way to program either. OOP is a complex
paradigm and all you can do is read text books, articles, discuss
models and generally form an opinion. Even then your opinion may quite
legitimately differ from other developers.
| Quote: | I know with my last little program, I had to use the TStringList
object, but I still don't really understand the need...
|
TStringList object is a single object that makes storing and
manipulating string lists very easy. It takes care of the memory usage
and data representation. It provides methods to load and save the
string list from memory. It takes care of growing and shrinking the
list. it provides mechanisms to assist in creating alternate copies of
the list and to resolve ownership symantics.
You have to ask yourself "how would you store a list of strings if you
didn't use TStringList?".
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Lee Gobroski Guest
|
Posted: Tue Mar 29, 2005 11:02 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Andrue,
Thank you for your answer. In my CS 110 class they pressed us pretty hard
on the importance of classes and objects, and then we were using Java. Man
did I hate that class. I guess that is why I am no longer a CS major. Your
reply cleared up some of my confusion. Thanks again.
lee
"Andrue Cope [TeamB]" <no.spam (AT) not (DOT) a.valid.address> wrote
| Quote: | Lee Gobroski wrote:
I have been struggling with objects and what not for some time now.
I was wondering what the purpose of classes are when you have a
function that will do the same thing, and don't need to be
instantiated.
None whatsoever.
Objects are useful when there is a collection of related functions that
manipulate or rely on state information. IOW if the functions need to
have some 'behind the scenes' intelligence.
They are also useful when you need to be able to create a generic
'thing' and then derive specialisations from that without the owner
knowing about it.
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
You won't find a definitive way to program either. OOP is a complex
paradigm and all you can do is read text books, articles, discuss
models and generally form an opinion. Even then your opinion may quite
legitimately differ from other developers.
I know with my last little program, I had to use the TStringList
object, but I still don't really understand the need...
TStringList object is a single object that makes storing and
manipulating string lists very easy. It takes care of the memory usage
and data representation. It provides methods to load and save the
string list from memory. It takes care of growing and shrinking the
list. it provides mechanisms to assist in creating alternate copies of
the list and to resolve ownership symantics.
You have to ask yourself "how would you store a list of strings if you
didn't use TStringList?".
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
|
| Back to top |
|
 |
Lee Gobroski Guest
|
Posted: Tue Mar 29, 2005 11:05 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Andrue,
and to answer you question about how I would handle the string list with out
objects, well, I would have no idea where to start. Thank goodness for the
Borland team that made that object...
Lee
"Andrue Cope [TeamB]" <no.spam (AT) not (DOT) a.valid.address> wrote
| Quote: | Lee Gobroski wrote:
I have been struggling with objects and what not for some time now.
I was wondering what the purpose of classes are when you have a
function that will do the same thing, and don't need to be
instantiated.
None whatsoever.
Objects are useful when there is a collection of related functions that
manipulate or rely on state information. IOW if the functions need to
have some 'behind the scenes' intelligence.
They are also useful when you need to be able to create a generic
'thing' and then derive specialisations from that without the owner
knowing about it.
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
You won't find a definitive way to program either. OOP is a complex
paradigm and all you can do is read text books, articles, discuss
models and generally form an opinion. Even then your opinion may quite
legitimately differ from other developers.
I know with my last little program, I had to use the TStringList
object, but I still don't really understand the need...
TStringList object is a single object that makes storing and
manipulating string lists very easy. It takes care of the memory usage
and data representation. It provides methods to load and save the
string list from memory. It takes care of growing and shrinking the
list. it provides mechanisms to assist in creating alternate copies of
the list and to resolve ownership symantics.
You have to ask yourself "how would you store a list of strings if you
didn't use TStringList?".
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Mar 29, 2005 11:11 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Lee Gobroski wrote:
| Quote: | Thank goodness for the
Borland team that made that object...
|
Oh yes. You'll be especially grateful any time you need to load a text
file from disk:
std::auto_ptr<TStringList> sl( new TStringList() );
sl->LoadFromFile( "textfile.txt" );
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Chris Uzdavinis (TeamB) Guest
|
Posted: Tue Mar 29, 2005 2:46 pm Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> writes:
| Quote: | Hello all,
I have been struggling with objects and what not for some time now. I was
wondering what the purpose of classes are when you have a function that will
do the same thing, and don't need to be instantiated. Are they really
faster, and better?
|
A class is more than just a function. A class is the bundling of
"state" plus "behavior". A class exposes an interface to allow you to
modify the state it represents, and with access restrictions, you can
have implementation details remain unusable to outside code.
Objects are good at encapsulating data, hiding implementation details,
decreasing dependencies between code, and (through polymorphism)
allowing immense amounts of code reuse.
--
Chris (TeamB);
|
|
| Back to top |
|
 |
Bruce Salzman Guest
|
Posted: Tue Mar 29, 2005 5:42 pm Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Well designed encapsulation frees you to think about what an object
does rather than how it does it. Classes hide the details that you
should ignore when dealing with an object as a logical entity. If done
right, your design can elegantly handle complexity that is an order of
magnitude greater than it might otherwise. Of course, a poorly
designed set of classes can negate any benefit.
The most amazing thing in my experience is making some major
modifications to a base class that many other classes derive from,
recompiling everything, and having it all work! No, really! Sometime
it does! ;^) Try that with procedural programming...
Regards,
Bruce
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Wed Mar 30, 2005 8:09 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? |
|
|
Bruce Salzman wrote:
| Quote: | The most amazing thing in my experience is making some major
modifications to a base class that many other classes derive from,
recompiling everything, and having it all work!
|
Oh yes - what I call 'join the dots' programming. You realise you need
one of these to talk to one of these to talk to one of these and it all
works.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Lee Gobroski Guest
|
Posted: Wed Mar 30, 2005 9:09 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? (thanks) |
|
|
HI all...
Thanks for all your insight... I will learn how to use classes / objects,
but for what I do now I don't think I need them. I like the idea of connect
the dot programming, and all that reusability that objects are so good at.
I think this weekend I will play a little with how to make a class, does any
one have a good site that could provide a tutorial, I have the book teach
your self BCB in 21 days, and the subject it mentioned in that... so I am
just looking for anything that would help to solidify the information, and
more specific to BCB 6.0
Lee
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote
| Quote: | Hello all,
I have been struggling with objects and what not for some time now. I was
wondering what the purpose of classes are when you have a function that
will do the same thing, and don't need to be instantiated. Are they
really faster, and better?
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
I know with my last little program, I had to use the TStringList object,
but I still don't really understand the need...
Thanks
Lee
|
|
|
| Back to top |
|
 |
Brent Guest
|
Posted: Fri Apr 01, 2005 4:55 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? (thanks) |
|
|
There is an interesting article at this website on developing a datetime
object in C++. It explains the differences between low level programming
(developing the object) and application programming (using the object). Its
a 3 part series that was published in February, April and July of 2004.
Well worth a look.
Brent
http://bcbjournal.org/volume8.php
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote
| Quote: | HI all...
Thanks for all your insight... I will learn how to use classes / objects,
but for what I do now I don't think I need them. I like the idea of
connect
the dot programming, and all that reusability that objects are so good at.
I think this weekend I will play a little with how to make a class, does
any
one have a good site that could provide a tutorial, I have the book teach
your self BCB in 21 days, and the subject it mentioned in that... so I am
just looking for anything that would help to solidify the information, and
more specific to BCB 6.0
Lee
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote in message
news:42490c04 (AT) newsgroups (DOT) borland.com...
Hello all,
I have been struggling with objects and what not for some time now. I
was
wondering what the purpose of classes are when you have a function that
will do the same thing, and don't need to be instantiated. Are they
really faster, and better?
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
I know with my last little program, I had to use the TStringList object,
but I still don't really understand the need...
Thanks
Lee
|
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Fri Apr 01, 2005 7:58 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? (thanks) |
|
|
Brent wrote:
| Quote: | "Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote in message
|
Could you trim your quoting, please, Brent?
Thanks.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Lee Gobroski Guest
|
Posted: Sun Apr 03, 2005 7:53 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? (thanks) |
|
|
Thanks Brent once I get some money I going to pay for a subscription..
"Brent" <nospam (AT) nospam (DOT) com> wrote
| Quote: | There is an interesting article at this website on developing a datetime
object in C++. It explains the differences between low level programming
(developing the object) and application programming (using the object).
Its
a 3 part series that was published in February, April and July of 2004.
Well worth a look.
Brent
http://bcbjournal.org/volume8.php
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote in message
news:424a6cc2 (AT) newsgroups (DOT) borland.com...
HI all...
Thanks for all your insight... I will learn how to use classes /
objects,
but for what I do now I don't think I need them. I like the idea of
connect
the dot programming, and all that reusability that objects are so good
at.
I think this weekend I will play a little with how to make a class, does
any
one have a good site that could provide a tutorial, I have the book teach
your self BCB in 21 days, and the subject it mentioned in that... so I
am
just looking for anything that would help to solidify the information,
and
more specific to BCB 6.0
Lee
"Lee Gobroski" <gobroski (AT) oddlee (DOT) net> wrote in message
news:42490c04 (AT) newsgroups (DOT) borland.com...
Hello all,
I have been struggling with objects and what not for some time now. I
was
wondering what the purpose of classes are when you have a function that
will do the same thing, and don't need to be instantiated. Are they
really faster, and better?
I have been looking through all my books, and I can not really find a
definitive way of implementing classes/objects in C++ Builder.
I know with my last little program, I had to use the TStringList
object,
but I still don't really understand the need...
Thanks
Lee
|
|
|
| Back to top |
|
 |
Thomas Maeder [TeamB] Guest
|
Posted: Sun Apr 03, 2005 11:28 am Post subject: Re: To OOPs or not to OOPs!?!?!?!? (thanks) |
|
|
Please direct your browser at http://info.borland.com/newsgroups/ and
read the newsgroup guidelines. One of them asks us not to quote entire
posts we are following up to; instead, please trim the quotes to the
parts relevant for your reply. Thanks!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|