Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #3392

Re: Object oriented programming?

From root <NoEMail@home.org>
Newsgroups comp.programming
Subject Re: Object oriented programming?
Date 2013-05-30 14:07 +0000
Organization Linux Advocacy
Message-ID <ko7mf9$qq8$3@news.albasani.net> (permalink)
References <ko5341$heu$1@news.albasani.net> <d63ebecf-90b4-407d-9d81-d9b5ff54d505@s8g2000vbw.googlegroups.com>

Show all headers | View raw


James Harris <james.harris.1@gmail.com> wrote:
> On May 29, 3:25 pm, root <NoEM...@home.org> wrote:
>> My programming experience began before the advent of Object Oriented
>> Programming so the concepts are vague to me. It would help if
>> someone could sketch out how OOP would enter into some of tasks
>> I have done.
>>
>> I have written my own text editor, the general structure is:
>>
>> Initialize stuff
>> read in any starting text
>>
>> while(1)
>>         display text
>>         accept user command
>>         process user command
>>
>> If one were to use OOP concepts and start writing a new text
>> editor, how would objects change this picture?
> 
> Be careful not to mix up event-driven processing and OOP. From what
> you have described it seems you might be thinking of the processing
> model.
> 
> You can think of OO programming as bundling data and code together.
> With OOP for a text editor you might define an object type (i.e. a
> class) to represent the document and add to it functions (i.e.
> methods) to process the text.

In the case of a text editor, the data is simply a collection of
characters. Even characterizing it as a document implies more
structure than is justified. If the there are line feeds in
the data, then one might consider it as a series of lines.
If there are spaces, then one might consider the data to
be composed of words. Really it is only characters. The
number of potential operations which might be performed on the
data is unlimited. 

> 
> You could then set up instances of (i.e. instantiate) different
> documents, each of which would use the same common code.
> 
> If the code had a method to save the file to disk and you had two
> documents, doc1 and doc2, you could save then with calls such as
> 
>   doc1.save()
>   doc2.save()
> 
> There would be just one save() method and it would know which instance
> to save.

As I said above, the number of operations is unlimited. Consider
that in doc1 you want to change some occurences of THIS to THAT,
while in doc2 you want simply to delete any reference to THIS.
You use a text editor, think about all the different things you
have done and translate those into some OOP model.
>>
>> Simpler programs, such as filters look like:
>>
>> read stream
>> filter stream
>> output filtered stream
>>
>> How do OOP concepts come into such program design.
> 
> I don't know that I would use OO for such a filter, unless forced. You
> could but it might not help much. Again, you may have the wrong basic
> ideas about OOP.

What types of programs lend themselves to OOP and what don't?
> 

I am sure I don't grasp OOP, that is why I ask.
> James

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Object oriented programming? root <NoEMail@home.org> - 2013-05-29 14:25 +0000
  Re: Object oriented programming? Melzzzzz <mel@zzzzz.com> - 2013-05-29 18:19 +0200
    Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-30 13:51 +0000
      Re: Object oriented programming? Melzzzzz <mel@zzzzz.com> - 2013-05-30 19:48 +0200
  Re: Object oriented programming? Patricia Shanahan <pats@acm.org> - 2013-05-29 09:21 -0700
    Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-30 13:56 +0000
  Re: Object oriented programming? James Harris <james.harris.1@gmail.com> - 2013-05-29 13:05 -0700
    Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-30 14:07 +0000
      Re: Object oriented programming? "osmium" <r124c4u102@comcast.net> - 2013-05-30 10:49 -0500
      Re: Object oriented programming? James Harris <james.harris.1@gmail.com> - 2013-06-01 12:18 -0700
  Re: Object oriented programming? Kicer <a@b.c> - 2013-05-29 22:13 +0200
    Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-30 14:22 +0000
      Re: Object oriented programming? Kicer <a@b.c> - 2013-06-01 02:54 +0200
        Re: Object oriented programming? Patricia Shanahan <pats@acm.org> - 2013-06-01 07:43 -0700
          Re: Object oriented programming? Kicer <a@b.c> - 2013-06-05 18:16 +0200
  Re: Object oriented programming? rugxulo@gmail.com - 2013-05-30 22:22 -0700
    Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-31 14:05 +0000
      Re: Object oriented programming? "Charles Hottel" <chottel@earthlink.net> - 2013-05-31 12:12 -0400
        Re: Object oriented programming? root <NoEMail@home.org> - 2013-05-31 20:31 +0000
          Re: Object oriented programming? "BartC" <bc@freeuk.com> - 2013-06-01 00:59 +0100
  Re: Object oriented programming? Willem <willem@turtle.stack.nl> - 2013-06-01 07:54 +0000
    Re: Object oriented programming? Jongware <jongware@no-spam.plz> - 2013-06-07 11:05 +0200
  Re: Object oriented programming? Paul N <gw7rib@aol.com> - 2013-06-02 13:11 -0700
    Re: Object oriented programming? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-06-03 11:06 -0700

csiph-web