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


Groups > comp.programming > #3404

Re: Object oriented programming?

From Kicer <a@b.c>
Newsgroups comp.programming
Subject Re: Object oriented programming?
Date 2013-06-01 02:54 +0200
Organization Aioe.org NNTP Server
Message-ID <kobgp1$njj$1@speranza.aioe.org> (permalink)
References <ko5341$heu$1@news.albasani.net> <ko5nhc$6th$1@speranza.aioe.org> <ko7nbe$qq8$4@news.albasani.net>

Show all headers | View raw


root wrote:

> Kicer <a@b.c> wrote:
>> root wrote:
> 
> I have done so, in fact I am watching a lecture series on the
> subject. Examples in texts such as a payroll program are not
> easily translated into the types of programs I have worked
> on. My text editor example seems completely unrelated to a
> payroll program.

I don't know which programming language do you use, but maybe start with 
more basic examples.


> 
>> In short: you hide implementation behind interface.
> 
> OK, I take that the "hide" part is to hide how something is done
> from the rest of the program, not from the user. I take that
> as dictated more from a program maintenance standpoint than any
> other reason.
> 

yeah ok, but there is more than one definition of hiding (which are somehow 
connected).

Consider a c/c++ program where you have .c and .h file.

.h is your interface to real stuff closed in .c/.cpp file. Your goal is to 
hide as much as possible in .c/.cpp file.

You can do the same with classes. You can prepare an abstract class which 
cannot be instantiated but which define a set of functions which will be 
provided by "implementation" class. This abstract class is an interface 
(like .h file) and the "implementation" class which will inherite from this 
interface is an "implementation".

> 
> 
> 
>> Example: your editor's engine should get constructed objects (look for
>> builder or factory patterns) as an abstract interface.
> 
> I don't understand what builder or factory patterns are.

then read about them :) For sure you will automatically get some examples 
about interface and implementation classes.

> 
>> There should be at least 3 objects and 3 interfaces: one pair for
>> display, one for communication with user and one for command processor.
> 
> Well, how is this for the display pair, the object is the block of text
> which can fit into the current display, and the display object is the
> screen?

no I rather meant it the way I described above.

> 
> Can I say that a user object is a string of characters defining
> operations to be performed?

I don't know what do you mean by "user object". You can use anything as you 
want for your list of operations to be performed but I believe that a list 
of classes describing operations would be better :)

> 
> The command processor is the real stumbling block for me. I can parse the
> user command string for a sequence of operations, but these operations
> themselves seem to define objects unique to the operations. Sometimes
> the operations work on characters, sometimes lines, sometimes on the
> whole block of text.

then You need to introduce an interface for commands and keep list of items 
which will be inheriting from this interface. Then you can close 
implementation of proper operation in a various classes inheriting from this 
interface.

Another way is to use visitor pattern (read about it:) ) which will match 
better here I think.

> 
>> 
>> As your engine will use abstract interfaces for this 3 roles and you can
>> (in your factory/builder) use various implementations and switch them
>> according to situation (text/graphical user interface (or a fake one -
>> for testing)).
>> 
>> regards
> 
> Thanks for responding.
>>

regards :)


-- 
MichaƂ Walenciak
gmail.com kicer86
http://kicer.sileman.net.pl
gg: 3729519

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