Is there something wrong with me?

Started by
82 comments, last by MSW 21 years, 6 months ago
quote:Original post by MSW
WOW! I never expected thie sort of response...

I think I''ll stick with procedural stuff for now...at least I know what I''m doing with it, and have no trouble understanding it...OO looks way to fractured and unintelligable...I meen you guys can''t seem to even agree on what works, how it should be done correctly...kinda defeats the purpose then don''t it?


Heh! I''ve thought the same thing! But, really, despite whatever quibbles people have over "the way things should be," I really do recommend that you give OO a serious shot. Every tool has it''s place, and OO is just one tool, but, fact is, it is a very useful tool. Also, OO is a slightly different way to think about program design. And experimenting with new ways of thinking is ALWAYS a good thing!
Advertisement
quote:Original post by MSW
I think I''ll stick with procedural stuff for now...

"Procedural" and "OO" are orthogonal concepts. The "opposite" (as it were) to procedural would probably be "functional".

quote:at least I know what I''m doing with it, and have no trouble understanding it...OO looks way to fractured and unintelligable...

And we''re meant to think you''re not trolling why?

quote:I meen you guys can''t seem to even agree on what works, how it should be done correctly...

Have you been reading the same thread as everyone else? The primary source of disagreement seems to be coming from someone whose only desire is to troll the thread.

quote:kinda defeats the purpose then don''t it?

Er, no. Good code is good code even if some ignorant fuckwit says "OMG FIFTY LINES FOR A RECTANGLE CLASS OMG OO IS SUCK".

char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;}  /*** drpizza@battleaxe.net ***/
Ok. This seems like a good place to ask a couple questions that have been plaguing me about OOP in C++ specificly.


  • The whole thing with Get/Set pairs. If you have Get/Set pairs on your data, what is the point of making that data private?
  • Constructor initializer lists. I see them a lot now and have read about them, but I don''t unserstand what purpose they serve and why they are used.


Seems like there are some on-the-ball folks watching this thread, maybe they can answer?

Also, to the OP... Objects are not the be all and end all of programming. Eventually there will be a new paradigm and those folks will look upon OOP like we look at spaghetti code. They are amazingly useful when used properly, although not EVERYTHING needs or even lends itself towards object use. That is my main gripe with Java.


God was my co-pilot but we crashed in the mountains and I had to eat him...
Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.
Accessing private class data via functions is more controlled, it also can save you time in bigger projects where you would need to use get/set code many times.
quote:Original post by Landsknecht

  • The whole thing with Get/Set pairs. If you have Get/Set pairs on your data, what is the point of making that data private?


Look at Gorg's and MadKeithV's posts on the previous page. They covered this pretty well.

quote:
  • Constructor initializer lists. I see them a lot now and have read about them, but I don't unserstand what purpose they serve and why they are used.

  • They mostly provide a convenient way of initializing class members. This:

        class SomeClass{public:   SomeClass( int a, int b ) : m_a( a ), m_b( b )   {;}private:   int m_a;   int m_b;};  


    is almost the same as this:

            class SomeClass{public:   SomeClass( int a, int b )    {      this->m_a = a;      this->m_b = b;   }private:   int m_a;   int m_b;};    

    Notice I said almost - for initializing const members, the second alternative is not an option. In that case, you are required to use the ctor init list.

    quote:
    Also, to the OP... Objects are not the be all and end all of programming. Eventually there will be a new paradigm and those folks will look upon OOP like we look at spaghetti code.

    Haven't you noticed that no paradigm has completely replaced the previous paradigms. As the good doctor(Pizza) has been pointing out lately, procedural and object oriented programming are orthogonal concepts. OOP did not replace procedural - it merely put it into another context.

    quote:
    They are amazingly useful when used properly, although not EVERYTHING needs or even lends itself towards object use.

    I have found that most of the problems I cannot represent in an OO way, are the small, trivial, script-type problems. If the whole problem boils down to less than 100 lines, bringing objects into your code probably isn't worth it. Other than that, it mostly depends on experience and ingenuity to find a way to apply OO in a beneficial way to a problem.

    quote:
    That is my main gripe with Java.

    Java doesn't necessarily force you to do OO. It goes a long way in suggesting that OO is the best way to go(and for the problem domains in which Java currently rules, it probably is) - however, at the end of the day, it is quite possible to write a non-OO program even in Java.


    Faith. n. Belief without evidence in what is told by one who speaks without knowledge, of things without parallel. -- Ambrose Bierce

    [edited by - Arild Fines on October 21, 2002 7:41:06 PM]
    --AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
    How does Java *not* force you to use oop? To do anything in Java requires at least one object. They are even talking about doing away with primitive data types and having ONLY objects in the next release.

    I also realize that no paradigm has wholly replaced a previous one. That is what I said! I am saying that zealots exist and say that oop is the "One True Thing" and that eventually, something else will become the "One True Thing".

    Do you realize that your entire post was pretty much a restatement of my own? It seems you were attempting to argue it and merely restated it in other terms. Odd.



    God was my co-pilot but we crashed in the mountains and I had to eat him...
    Landsknecht
    My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
    But folks whinned and I had to change it.
    A class or two does not an OO program make...
    DrPizza - I started this topic because of a thread in the beginners form. I sometimes post in there in an effort to help people, but lately there has been a whole lot of questions regaurding OO in there...something I lack the knowledge to help people with...and many of those questions turn into more argueing over OO implamentation then much else...I posted in THIS form because I do not feel that I am a beginner in anything except OO. I was hopeing that other experienced programers could give me pointers on how to understand OO (thanks for the book recomendations BTW).

    Honestly, I''m not actively seeking to understand OO...it isn''t my top priotity...this is mainly because of the widely different points of view I see here...plus the fact I already know how to do many things without useing designated OO structures...why re-invent the wheel when my abilites with the current one work just fine, know what I meen?

    I''m only writeing this to explain my possition...If this makes me a "troll" in your eyes...well, so be it...
    Object oriented program was developed from modular programming, which came from procedural programming. The antithesis of functional programming is imperative, and includes procedural, modular, and OO.

    "Design Patterns: Elements of Reusable Software" is a hard source for more OO information. It''s hard in the sense that''s it''s a book, a hardcover, difficult to read, and difficult to understand.

    An important aspect of OO is that you abstract to the invariant, define an interface to transact that behavior, and then use data to handle the variations.

    The best example I''ve read is a small example from making pay-roll software. It starts with one case, where everyone is paid once-a-week. This is easy, but of course is inadequate. The software is updated to handle paying employees bi-weekly (every two weeks). A switch handles the two cases. Then contractors are hired that are paid once-a-month, and some part-timers are hired that are paid on a daily basis, etc...

    The invariant is that employees are paid acording to some schedule. The interface ought to make no assumptions about the frequency, leaving that detail to a sub-class. A sub-class is made for each type of pay-schedule, daily, weekly, bimonthly, etc... When the HR person is presented with a pay schedule, they choose from an enumerated list of options, that uses a Clone (aka Prototype) method to create the correct pay schedule. No where in the code is there a switch statement handling this process, so the addition of more pay-schedules is
    transparent.

    ...
    quote:Original post by Landsknecht
    I also realize that no paradigm has wholly replaced a previous one. That is what I said! I am saying that zealots exist and say that oop is the "One True Thing" and that eventually, something else will become the "One True Thing".

    Yes, like generic-programming you heathen. :0)
    - The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
    I skimmed over the discussion, and wanted to add/discuss an aside:

    Everyone who has worked with .Net knows about properties, right? I didn't use them at all, but just reading about the concept, it seemed rather cool. Basically, if you are going to provide a pair of get/set trivial methods, you should have a public member variable instead. Then, if you ever decided that a SetWidth(x) function was needed because you needed more than width_ = x, you can create the SetWidth() function and "mark" width_ as a property, associated to SetWidth. When myobject.width_ = 30 is written, SetWidth(30) will be called, and you can do stuff like bounds-checking there. You don't have to change the semantic of the call at all, and it's more natural than circle.SetWidth(30).

    ... I hope that this paragraph didn't make sense only to those who already understood how it worked. Did I write anything wrong? If not, then I want properties in regular C++! So much neater. What do you guys think?

    Cédric

    [edited by - cedricl on October 21, 2002 9:16:40 PM]

    This topic is closed to new replies.

    Advertisement