Philosophical Programmin Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dracolytch

    Philosophical Programmin Question

    Alright, this is a controvercial question for my fellow gurus: Why do
    we bother with Object-Oriented programming in a web environment?

    The web, by nature, is a stateless environment. Web-based applications
    are, on the whole, fairly uncomplicated things. Objects are, generally,
    conceptually thought of as entities that have a lifespan. Having an
    object survive for longer than the execution of a single page can be a
    pain. Having an object only survive for one page hardly seems worth the
    trouble.

    Encapsulation, the grouping of like concepts, can be done with a well
    thought-out library, or even file naming structure.
    I don't think I have ever used inhertiance or true polymorphism in any
    web project, ever.

    So what gives? Why are people using mysql_fetch_obj ect instead of
    mysql_fetch_arr ay? Is it habit? Is it what we're taught? Do we percieve
    some additional value?

    ~D

  • DJ Craig

    #2
    Re: Philosophical Programmin Question

    dracolytch wrote:[color=blue]
    > Alright, this is a controvercial question for my fellow gurus: Why do
    > we bother with Object-Oriented programming in a web environment?
    >
    > The web, by nature, is a stateless environment. Web-based applications
    > are, on the whole, fairly uncomplicated things. Objects are, generally,
    > conceptually thought of as entities that have a lifespan. Having an
    > object survive for longer than the execution of a single page can be a
    > pain. Having an object only survive for one page hardly seems worth the
    > trouble.
    >
    > Encapsulation, the grouping of like concepts, can be done with a well
    > thought-out library, or even file naming structure.
    > I don't think I have ever used inhertiance or true polymorphism in any
    > web project, ever.
    >
    > So what gives? Why are people using mysql_fetch_obj ect instead of
    > mysql_fetch_arr ay? Is it habit? Is it what we're taught? Do we percieve
    > some additional value?
    >
    > ~D[/color]

    I agree.

    Comment

    • Scott Auge

      #3
      Re: Philosophical Programmin Question

      In article <1121777730.300 672.138240@g47g 2000cwa.googleg roups.com>,
      "dracolytch " <dracolytch@gma il.com> wrote:
      [color=blue]
      > Alright, this is a controvercial question for my fellow gurus: Why do
      > we bother with Object-Oriented programming in a web environment?
      >
      > The web, by nature, is a stateless environment. Web-based applications
      > are, on the whole, fairly uncomplicated things. Objects are, generally,
      > conceptually thought of as entities that have a lifespan. Having an
      > object survive for longer than the execution of a single page can be a
      > pain. Having an object only survive for one page hardly seems worth the
      > trouble.
      >
      > Encapsulation, the grouping of like concepts, can be done with a well
      > thought-out library, or even file naming structure.
      > I don't think I have ever used inhertiance or true polymorphism in any
      > web project, ever.
      >
      > So what gives? Why are people using mysql_fetch_obj ect instead of
      > mysql_fetch_arr ay? Is it habit? Is it what we're taught? Do we percieve
      > some additional value?
      >
      > ~D[/color]

      1)

      Well, I would disagree with the idea of Web based applications are
      fairly uncomplicated things. Explain that to salesforce.com or the
      multitude of other web based app servers popping up.

      If anything, web apps are becoming more and more complicated every year.

      2)

      OOP is an application design method. If you like:

      Note_Add()
      Note_Delete()
      Note_Update()

      and it works for you - that is fine and dandy. People have been doing
      that for years and years.

      Personally I like the level of encapsulation of data and level of
      abstraction OOP can provide.

      Comment

      • dracolytch

        #4
        Re: Philosophical Programmin Question

        There are some highly complicated web based applications. Amazon and
        Google do some stuff that is simply amazing. Generally speaking though,
        web-based applications are just not that complicated. We're not writing
        advanced AI systems, creating evolutionary computing algorithms, or
        doing multibody physics engines.

        I do not like Note_Add() Note_Delete() Note_Update.

        note_add.php
        note_insert.php
        note_delete.php

        Makes a lot more sense though. This separates your presentation code
        from your application logic. It also promotes reuse (Pass info to
        note_insert via various means), and will allow you to do exception
        handling gracefully.

        ~D

        Comment

        • DJ Craig

          #5
          Re: Philosophical Programmin Question

          In a language like PHP, I don't see any advantage to OOP even in
          complex web applications. The only time I could see an advantage is if
          the application is being created by a large team of programmers, as
          would be the case with Google or SalesForce. In client-side languages,
          OOP is most useful for defining UI objects. PHP doesn't create the UI
          of a web application; HTML, CSS, Javascript, etc, create the UI.

          What is Note_Add(), Note_Delete(), and Note_Update()? I looked up
          these functions on the PHP function index and they weren't on there.
          Couldn't find anything on Google either.

          Comment

          • dracolytch

            #6
            Re: Philosophical Programmin Question

            They're theoretical functions...

            So, instead of having Note.add() (Where the add method is part of a
            class) you'd have note_add() (Where the add function is part of a
            library). I tend to use note-add.php, where the behavior is part of an
            application.

            ~D

            Comment

            • JDS

              #7
              Re: Philosophical Programmin Question

              On Tue, 19 Jul 2005 07:49:02 -0700, dracolytch wrote:
              [color=blue]
              > Generally speaking though,
              > web-based applications are just not that complicated.[/color]

              What? how can you generalize like this?

              --
              JDS | jeffrey@example .invalid
              | http://www.newtnotes.com
              DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

              Comment

              • dracolytch

                #8
                Re: Philosophical Programmin Question

                Easy, I've done physics simulations, game design, evolutionary
                computation, artificial intelligences, written compilers, and created
                web-based applications. It is easy for a web-based application to get
                ~large~, but it's rare that they ever get terribly ~complicated~.

                The web is ill-suited for lots of high-end persistant computing. Facial
                recognition, natural language processing, and other ~complicated~
                systems don't exist as web-based applications. The few that have a web
                interface are just that... An underlying application with a web
                interface.

                ~D

                Comment

                • JDS

                  #9
                  Re: Philosophical Programmin Question

                  On Tue, 19 Jul 2005 09:02:58 -0700, dracolytch wrote:
                  [color=blue]
                  > It is easy for a web-based application to get
                  > ~large~, but it's rare that they ever get terribly ~complicated~.[/color]

                  Allrighty. Distinction taken.

                  --
                  JDS | jeffrey@example .invalid
                  | http://www.newtnotes.com
                  DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

                  Comment

                  • Scott Auge

                    #10
                    Re: Philosophical Programmin Question

                    In article <1121786906.757 926.111780@g43g 2000cwa.googleg roups.com>,
                    "DJ Craig" <spit@djtriciti es.com> wrote:
                    [color=blue]
                    > In a language like PHP, I don't see any advantage to OOP even in
                    > complex web applications. The only time I could see an advantage is if
                    > the application is being created by a large team of programmers, as
                    > would be the case with Google or SalesForce. In client-side languages,
                    > OOP is most useful for defining UI objects. PHP doesn't create the UI
                    > of a web application; HTML, CSS, Javascript, etc, create the UI.[/color]

                    A lot of people put OOP into the box of UI.

                    I use OOP for business logic and IMHO that is where it really starts to
                    shine. Basically make a method for every "event" that happens in a
                    business process for a given "thing."

                    Lets say our business process is:

                    Take Order -> Credit Check -> Inventory Check -> Ship

                    Well, what can you do with an order? You can _create_ one, _look up
                    one_, _change_ one, or _delete_ one. On an order you can _add item_,
                    _delete item_ or _update item_.

                    So it would seem that the object representing an order would have:

                    Order::New
                    Order::DeleteBy RecID
                    Order::DeleteBy OrderNum
                    Order::Update
                    Order::AddItem
                    Order::ChangeIt em
                    Order::DeleteIt em

                    to handle the Take Order step...

                    Order::CheckCre dit

                    to handle the Credit Check step...

                    Next the Inventory step comes up - do we have stock? Do we need a
                    purchase order? Do we need a factory order? This will probably be
                    answered in a background process or the like that allocates inventory to
                    a shipment, creates a factory order, and/or creates a purchase order.

                    Of course, there will be a Shipment, FactoryOrder, and PurchaseOrder
                    object with the various business events that change into invocations of
                    the various methods for a given object.

                    All this stuff can be done on a web page or PHP background process.

                    Since the object is abstracted out, I can use them in a PHP background
                    process or a WWW front end without modification to the object.
                    [color=blue]
                    >
                    > What is Note_Add(), Note_Delete(), and Note_Update()? I looked up
                    > these functions on the PHP function index and they weren't on there.
                    > Couldn't find anything on Google either.[/color]

                    Answered by another...

                    Comment

                    • Peter Fox

                      #11
                      Re: Philosophical Programmin Question

                      Following on from dracolytch's message. . .[color=blue]
                      >Easy, I've done physics simulations, game design, evolutionary
                      >computation, artificial intelligences, written compilers, and created
                      >web-based applications. It is easy for a web-based application to get
                      >~large~, but it's rare that they ever get terribly ~complicated~.[/color]
                      Twaddle.
                      Your world view is obviously very narrow.
                      Of course the WWW is not stateless!


                      An object is just a tool - Want to make a hole, pick up a drill. Want
                      to put a screw in it - pick up a screwdriver. You might carry a
                      screwdriver around in your toolbox for a week then only use if for a
                      minute. You can hand your screwdriver to a mate to use without having
                      to give them an instruction manual and if you have a particular task you
                      can get a particular screwdriver to fit - you know almost instantly when
                      looking in the shop what screwdriver will have the right characteristics
                      because you _understand how to use it_.

                      The OO paradigm allows reliable tools to be developed and then applied
                      quickly. And reapplied quickly. And revised quickly.

                      To me the classic PHP application of OO which refutes all your original
                      statements is generating and sending emails. It is complicated (lots of
                      RFCs) and it is a transient object created for building purposes only
                      then destroyed after use. I haven't done emailing for six months but in
                      1 minute I can be up to speed and in another decided if I should use it
                      as-is or add special functionality, and if so where in the class tree
                      would be a good place to add it.

                      I've wrapped the database I use all the time in an object. If somebody
                      insists on using another then I can accommodate that quickly and
                      reliably. It also means I can enrich the functionality to suit - for
                      example to optimise certain functions.

                      So to conclude. It is about the efficient application brain cells not
                      bits. The internet only works because the interfaces between the many
                      many bits are clear. It _is_ hugely complicated.

                      Who cares if you destroy an object just moments after creating it? It
                      is about building intelligence (your intelligence) into system
                      components and developing those designs in the light of experience. All
                      product lines are continuously being modified and computer systems are
                      no different. All my customers benefit from the work done on all the
                      other's.

                      (I think you may be assuming 'complexity' means 'processor-intensive
                      algorithms'.)

                      --
                      PETER FOX Not the same since the bridge building business collapsed
                      peterfox@eminen t.demon.co.uk.n ot.this.bit.no. html
                      2 Tees Close, Witham, Essex.
                      Gravity beer in Essex <http://www.eminent.dem on.co.uk>

                      Comment

                      • Chung Leong

                        #12
                        Re: Philosophical Programmin Question

                        dracolytch wrote:[color=blue]
                        > Alright, this is a controvercial question for my fellow gurus: Why do
                        > we bother with Object-Oriented programming in a web environment?[/color]

                        I don't.
                        [color=blue]
                        > The web, by nature, is a stateless environment. Web-based applications
                        > are, on the whole, fairly uncomplicated things.[/color]

                        Web-based application can get fairly complicated. The complexity is
                        largely horizontal though, meaning you have a lot of pages. OOP is
                        better suited where an application has many layers.

                        Web applications also use a very sophisticated way of dealing with
                        state--namely SQL databases.
                        [color=blue]
                        > Encapsulation, the grouping of like concepts, can be done with a well
                        > thought-out library, or even file naming structure.
                        > I don't think I have ever used inhertiance or true polymorphism in any
                        > web project, ever.[/color]

                        Encapsulation is not necessarily a virtue in web-programming because of
                        heighten security concern. Most of the time I want to know exactly what
                        a piece of code does.

                        Comment

                        • Dave Moore

                          #13
                          Re: Philosophical Programming Question


                          "DJ Craig" <spit@djtriciti es.com> wrote in message
                          news:1121786906 .757926.111780@ g43g2000cwa.goo glegroups.com.. .[color=blue]
                          > In a language like PHP, I don't see any advantage to OOP even in
                          > complex web applications.[/color]

                          These are the words of someone who has never written or had to maintain a
                          large software 'system'. OO is all about software management and developing
                          architectures to help the programmer use simple interfaces to complex pieces
                          of code. Whether you need it depends on the complexity of your development
                          and the size of the brains of the people working on it. Usually, dealing
                          with objects/classes is easier than with functional code in my experience.







                          Comment

                          • NC

                            #14
                            Re: Philosophical Programmin Question

                            dracolytch wrote:[color=blue]
                            >
                            > Alright, this is a controvercial question for my fellow gurus:
                            > Why do we bother with Object-Oriented programming in a web
                            > environment?[/color]

                            Because some languages do not provide an alternative. Consider
                            Java, for example...
                            [color=blue]
                            > So what gives? Why are people using mysql_fetch_obj ect instead of
                            > mysql_fetch_arr ay? Is it habit? Is it what we're taught? Do we percieve
                            > some additional value?[/color]

                            Marketers say that every product has two sets of characteristics ,
                            utilitarian and value-expressive. Utilitarian characteristics
                            define the product's usefulness. Value-expressive characteristics
                            define the product's "coolness". OOP is reasonably useful and
                            believed by many to be "cool". Procedural programming, while
                            equally useful, is often perceived as old-fashioned and therefore
                            "uncool". Given that programming is a profession dominated by
                            young males, "coolness", not usefulness, becomes the decisive
                            factor...

                            Cheers,
                            NC

                            Comment

                            • Scott Auge

                              #15
                              Re: Philosophical Programmin Question

                              In article <1121875433.364 871.269970@g14g 2000cwa.googleg roups.com>,
                              "NC" <nc@iname.com > wrote:
                              [color=blue]
                              > dracolytch wrote:[color=green]
                              > >
                              > > Alright, this is a controvercial question for my fellow gurus:
                              > > Why do we bother with Object-Oriented programming in a web
                              > > environment?[/color]
                              >
                              > Because some languages do not provide an alternative. Consider
                              > Java, for example...
                              >[color=green]
                              > > So what gives? Why are people using mysql_fetch_obj ect instead of
                              > > mysql_fetch_arr ay? Is it habit? Is it what we're taught? Do we percieve
                              > > some additional value?[/color]
                              >
                              > Marketers say that every product has two sets of characteristics ,
                              > utilitarian and value-expressive. Utilitarian characteristics
                              > define the product's usefulness. Value-expressive characteristics
                              > define the product's "coolness". OOP is reasonably useful and
                              > believed by many to be "cool". Procedural programming, while
                              > equally useful, is often perceived as old-fashioned and therefore
                              > "uncool". Given that programming is a profession dominated by
                              > young males, "coolness", not usefulness, becomes the decisive
                              > factor...
                              >
                              > Cheers,
                              > NC[/color]

                              Maybe we should say PHP is the latest "cool" language LOL!

                              I have been programming for 25+ years. I am getting a little sick of
                              rewriting stuff in the latest language.

                              When there is a paradigm shift - like going from green screens to GUI,
                              GUI to Web - I can handle that and am into it.

                              But to shift to a different language simply to rewrite how to put some
                              words, pictures, and boxes on a screen - that grates me a little.

                              Don't get me wrong, some languages are appropriate for various tasks - I
                              will freely mix PHP and C (and a couple other languages) to match what
                              is going on. But to simply rewrite something for the sake of the latest
                              cool language - bah!

                              Comment

                              Working...