Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #3410
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Object oriented programming? |
| References | <ko5341$heu$1@news.albasani.net> <bfd5b1e4-31d5-4673-8058-38ba3fec9817@k3g2000vbn.googlegroups.com> |
| Message-ID | <xW4rt.49439$cs.48412@newsfe03.iad> (permalink) |
| Date | 2013-06-03 11:06 -0700 |
On 6/2/13 1:11 PM, Paul N 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. > > The examples you've given don't really lend themselves to OOP in my > humble opinion, but I couldn't think of any better examples. > > However, an example of a useful object did occur to me. Dates. Suppose > you are writing a program that involves dates in some way. One > function could pass a date to another simply as a set of three > numbers. But if you create a Date class, it means you can pass a date > as a single value. Plus you can include routines within the object for > checking whether the three values do indeed form a valid date or not. > And if you wanted to get fancy, you could use operator overloading to > add a number to a date to get x days later than it, or subtract two > dates to get the number of days between them.Once you've written this > stuff, the code which uses the dates will (hopefully!) be much > clearer. And if you want to introduce a new date format, you only need > to write it in one place. > A Date class isn't a bad idea for an abstraction, but it is an unfortunate idea for a teaching exercise. The generic concept of a date is an extremely irregular concept, as evidenced by the JDK having multiple flawed ways to interact with Dates. Many implementations store dates as time-units-since-absolute-epoch. Even this implementation is somewhat flawed, though easier to work with than using 3 numbers. <rant> Another thing that has always bothered me is the lack of distinction between absolute units and relative units. Angles for example. You can perform multiplication and addition of Relative Angles, but for absolute angles, these are nonsensical operations. If you don't believe me, than what is the double of "North"? or "North plus East". If you just use the numeric representation of those direction, then you've unwittingly tied yourself to an orientation. </rant>
Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll 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