SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 49 of 49
  1. #26
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: oop

    In fact please read my post on this very thing. I am really looking for some example code. http://www.sitepoint.com/forums/showthread.php?t=426306

  2. #27
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A class can be a collection of functions, therefore, you are still passing to a function whether it is in a class or not. Speaking of databases, what if you ever had to switch from Access to MS SQL? If the database items had been implemented in a class, you could easily change between database types. Not only that, but if you were a software company you could provide your software to many different database platforms with very little coding.

    While providing new functionality, OOP also enhances readability. Compare a 10,000 line OOP program vs a 10,000 line functional one and you'll see a huge difference. If you ever have to read someone else's spaghetti code, you'll understand.

    As far as examples to an online database, google has a pretty large one hehe. Look at Google Suggest which uses ajax and provides suggestions as you start typing in the search field:
    http://www.google.com/webhp?complete=1&hl=en

    Also, have you ever sold an item to ebay? They use ajax when selecting categories of an item you are trying to sell. You select from a high level category (sports), then a new dropdown is prefilled based on what you chose(football, basketball...), and then based on that dropdown, yet another dropdown is prefilled (high school, college, professional) based on what you chose there and so on.

    For code examples, just google "ajax suggest" and you'll get a lot of hits.

  3. #28
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An object encapsulates the methods (functions) and data within itself. Maybe this simple program (tested with PHP 4.4.1) with comments may answer the question of how classes pass data back and forth between methods (functions in procedural languages). Stepping through the code, comments and running it should clarify a few things up. Again, this is very simple, the real power, lays in creating abastract classes and polymorphism.

    PHP Code:
    <?php 

    class pet {

    var 
    $pets_name;
    var 
    $preferred_food;
    var 
    $pet_type;

        function 
    pet($pets_name,$pet_type,$food_type){
        
           
    $this->set_pets_name($pets_name); 
           
           
    $this->set_pet_type($pet_type);
          
           
    $this->set_food_type($food_type); 
        
        }
        
        function 
    set_pets_name($newpetsname){
        
          
    $this->pets_name $newpetsname;
          
        }
        
        function 
    set_pet_type($newpettype){
        
          
    $this->pet_type $newpettype;
          
        }
        
        
        function 
    set_food_type($newfoodtype){
        
          
    $this->preferred_food $newfoodtype;
          
        }
        
        function 
    show_the_pet(){
        
           echo 
    $this->pets_name " is a " $this->pet_type " and perefers to eat " $this->preferred_food "\r\n";
        
        }

    }




    class 
    fish extends pet {

    var 
    $PH;

        function 
    fish($fishname,$foodtype,$PH){
        
        
    // calls the inheretied pet() method to set name, pet type and food type
        // to set the name of the pet and preferred food type
        
         
    parent::pet($fishname,"Fish",$foodtype);  // calls pet() from the pet class with 2 arguments
         
          
    $this->set_PH($PH);
        
        }
        
        function 
    set_PH($PH){
        
          
    $this->PH $PH;
        
        }
        
        function 
    show_the_pet() {
        
         
    parent::show_the_pet(); // calls the show_the_pet method from the inherited pet class which displays the pets name, type and food type
         
          // the only thing we need to add is output about the PH
         // for the fish

         
    echo $this->pets_name " has a PH Balance of $this->PH  \r\n";    // remember pets_name is inherited from the pet class
         
        
    }

    }

    // we create instances of a couple of pets

    $cat = new pet("Puffy","Cat","9 Lives");
    $dog = new pet("Bopper","Dog","Gravy Train");

    // display the info about the pets

    $cat->show_the_pet(); // displays "Puffy is a cat and eats 9 Lives";
    $dog->show_the_pet(); // displays "Bopper is a dog and eats Gravy Train";

    // Uh oh, the vet puts Bopper on a diet!
    // now displays "Bopper is a dog and eats Diet Doggie Crunch";

    $dog->set_food_type("Diet Doggie Crunch");
    $dog->show_the_pet();


    // Uh, Oh, the pet shop owner wants to add fish with a PH data field.
    // Well, makes no sense to add it to pets, since a dog or cat doesn't need PH
    // so, we will create a new class called fish, which inherits all the data
    // fields and methods (functions) from pet, then add the PH field to the
    // fish class.


    // displays "Bubbles eats Sparkle Flakes" and also displays "Bubbles has a PH Balance of 1.4

    $PH "1.4";
    $fish1 = new fish("Bubbles","Sparkle Flakes",$PH);
    $fish1->show_the_pet(); 



    ?>
    intragenesis, llc professional web & graphic design

  4. #29
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re:oop

    Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.

    Read this post carefully: http://www.sitepoint.com/forums/showthread.php?t=426306 , it exlpains what I'm trying to accomplish in a web database. If oop is so good how come no one can answer the really hard questions? That google thing still don't come close to what I'm trying to do. Simply have a text box to enter a search string, i.e., wh. Hit a enter or go button and have the dropdown filled with all occurrences of wh -- white freight, whitman trucking, etc. But at the same time after selecting whitman trucking, have their phone and fax filled. And if that's not enough, have other fields -- load number, etc on this same page. Then a final submit button to send this info to database. There are shipper and receiver filds also. Now I bet the google thing don't do anything this advanced. But I am going to check anyway.

  5. #30
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you're asking for in that other thread is more ajax-related than it is oop. There are tons of sites out there with examples of everything you want to do.

    http://www.w3schools.com/ajax/default.asp

    Here's something sort of similar to what you were wanting, click on the links towards the top to expand the different samples, for instance "Drop Downs & Form Handling".
    http://www.clearnova.com/ajax/

  6. #31
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim9
    Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.

    Read this post carefully: http://www.sitepoint.com/forums/showthread.php?t=426306 , it exlpains what I'm trying to accomplish in a web database. If oop is so good how come no one can answer the really hard questions? That google thing still don't come close to what I'm trying to do. Simply have a text box to enter a search string, i.e., wh. Hit a enter or go button and have the dropdown filled with all occurrences of wh -- white freight, whitman trucking, etc. But at the same time after selecting whitman trucking, have their phone and fax filled. And if that's not enough, have other fields -- load number, etc on this same page. Then a final submit button to send this info to database. There are shipper and receiver filds also. Now I bet the google thing don't do anything this advanced. But I am going to check anyway.
    Yeah, you are consistently mixing up two totally different discussions; OOP and AJAX. I think everyone has provided very detailed explanations about what OOP is; what exactly aren't you getting? OOP has nothing to do with your autocomplete functionality. That is AJAX, and is not that difficult.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  7. #32
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by jim9
    If oop is so good how come no one can answer the really hard questions? .
    Because convincing people OOP is good is painful. It's paradigm shift and your not just going to pick it up. Your going to have to invest abit of thought and time into it. Also, your arguments are both old and common and there has been discussion after discussion about this for many years. And frankly, you should be grateful people are going out of their way to help you understand.
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  8. #33
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    re: Grateful

    I do thank you for replying. Actually the post I referred people to is php related. I am trying to implement some ajax within php programming. If you read the post, I'm not after auto complete. I'm after something like http://www-128.ibm.com/developerwork...ro2/index.html. But instead of entering a phone number, I want to select from a dropdown.
    But first narrow the dropdown results from a "enter search string box". I realize until recently this type of stuff wasn't done on the web, it's new technology. Does anyone have actual code examples I could download of this. The IBM example is close, but there is a missing link that I need to learn. I have actually worked with there example and got it working.

  9. #34
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post in the javascript forum and you should be able to get a response.

    You just need an onchange event in the search string box to dynamically update a select menu using ajax.

  10. #35
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim9
    Don't even go there with pets. I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web). And I have programmed an access frontend to sql server and mysql. I am still learning php, and only been involved in web databases (learning) for a few months. In past it was all networked applications. So after 100,000 post, someone above answered the question: Functions are used in oop.
    Well according to your other question :

    Quote Originally Posted by jim9
    Still not properly answered: What's the difference of passing to a function verses passing or calling or whatever it is you do to a class library?
    That is what I answered for you in the pets, "Don't even go there with pets". No, there are no functions in OOP, they are called methods and methods behave and handle data differently than "functions."

    Quote Originally Posted by jim9
    I have programmed a pedigree program that most programmers wouldn't have a clue how to program (desktop version not web).
    Why add insult to injury? Do you think you are the only one here that has written desktop apps? I've been custom writing desktop apps since 1986 going from C/ C++, Pascal, x86 assembly, system 36 with Cobol/RPG, PHP, Perl, and so forth, and getting paid to write them.

    Don't brag on how "great" your programming skills are for desktop applications when you are clearly wanting to learn how to write server side applications.

    Were here to try and help you with your questions, I think you have been provided with more than enough to answer your questions...and if not, do a search in the forums. So, why don't you review what everyone has posted, buy a book, RTFM, and get your feet wet by actually doing some server side coding.

    If you have a problem with some code, that is cool, throw the question out there and I think many folks will help you out!
    intragenesis, llc professional web & graphic design

  11. #36
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.clearnova.com/ajax/ was a good example, thanks

  12. #37
    SitePoint Enthusiast
    Join Date
    Sep 2005
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim9
    Sure, now-a-days you have a lot of flash and non-sence on web sites. But you know something, all the extra bull isn't really needed to simply pull records from a database, edit records, add records, etc. You take a large warehouse that ships 50 to 100 truck loads a day, if they use php as a frontend to their backend database weather oracle or mysql, or whatever, they want one thing. And that is to pull up that order, load that truck, and press on. They don't need a cute little flash movie, or something bouncing across a screen.
    Quote Originally Posted by jim9
    http://www.clearnova.com/ajax/ was a good example, thanks
    ok, so you quite clearly hate flashy stuff on a screen, yet you want AJAX?

    as for this:
    Quote Originally Posted by jim9
    Here's my point: People cannot leave well enough alone. Why can't they get something that works well and leave it alone for at least several years?
    come on, thats just ridiculous.
    with that attitude, 99% of the stuff we use today, that people have created and invented, would not exist.
    i could go on forever:
    why create the car, when we had a bike?


    in this case, though;

    Quote Originally Posted by jim9
    They need to search for load number 125576-5, get the info, and load the freakin truck.
    im struggling to get what your 'point' is exactly; do you think the end user CGAS whether or not the language version being used to search for his 'load number 125576-5' is PHP 4 or PHP 5? i see you're saying that 'if it aint broke, dont fix it' - but PHP 5 doesnt 'break it'. the programmer breaks it with crap code - something which you've obviously encountered yourself (miaow! )

    the thing is, common sense would tell you that if there is two options in anything, the one with more features, more mature, better tested, and has better testimonials (which you can take as pretty much everyone in this thread telling you PHP 5 is better) - you go with the best option available - in this case, PHP 5 applies.

    as for the OOP argument that seemed to crop up out of nowhere (why, i dont know, as you seem to be looking for basic AJAX examples) - the argument is ancient. if you ask me, some people just simply dont have the capacity to pick it up. though people say its a paradigm shift; in some ways it is, in physical coding terms - but in psychological terms, no shift has taken place; it was always there, it just needed something to kick it into action, something to spark it off (displayed by the classic 'a-ha!' moment ) - the OO way of thinking is a general principle that you can apply to life, and many people do.
    however, for the unfortunate few, they will never experience this, and will happily trudge through with things 'getting by, because it works' - never striving to do better, to find a better way.

  13. #38
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My point is this, php4 is on most hosted servers in the world. There's already talk of a php6 coming out. Now to add 2 + 2 for you, before php5 is even out widespread there will be a php6. My point is exactly that, they aren't even going to let the php5 you like so much become an aldult. Use your brain, I don't mean never come up with new stuff, but good grief, let it have a life before you replace it. I would probably like php5 if it was more backwards compatable to php4. Case in point:Microsoft is real bad about that. They were coming up with new versions of access just when the current version became stabe with all the updates. But do you realize how many developers still develop in one of the older versions due to stability? Man let's progress, but let's enjoy and take a breath along the way. The way you sound, you'd build a house, live in it a week, tear it down for a bigger upgrade. Me, I'd at least live in the house for a few years first.

  14. #39
    SitePoint Member jasrags's Avatar
    Join Date
    Apr 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jim9
    would probably like php5 if it was more backwards compatable to php4.
    There were very few Backward incompatable changes relating to non-OO related programming from php4 to php5. Also have you even looked into what the changes php6 includes? The major thing is unicode support, it's not a complete rewrite as you seem to think it is.

  15. #40
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, the timeframe between PHP4 and PHP5, I believe, was the largest time difference of any two previous PHP versions. PHP/FI in 1995; PHP/FI 2 in 1997; PHP 3 in 1998, PHP 4 in 2000, PHP 5 in 2004. From the start, PHP seems to have had a tendency to release a major version every 2 years or so. Further, 2 years (how long PHP5 has been out) is plenty of time for people to migrate, IMNSHO.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd

  16. #41
    SitePoint Guru rockit's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    637
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP 5 all the way.

  17. #42
    ********* Victim lastcraft's Avatar
    Join Date
    Apr 2003
    Location
    London
    Posts
    2,423
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi...

    Quote Originally Posted by jim9
    Thanks for wasting my time on one of the lamest articles I've ever read .

    Quote Originally Posted by jim9
    Sounds like oop is nothing more than a common stored procedure, ie., IsPageLoaded type thing. Or an include used over and over again.
    What text did you read that makes it "Sound like" a stored proc or include (two very different things)? Was it the "Beginners guide to Assembly" from the same author as above? OO has nothing to do with either of these. It's a layer of abstraction above (two if you count closures) that makes things easy to change and easy to work in the language of the domain.

    What do you think polymorphism is?

    Quote Originally Posted by jim9
    OOP is only in your mind, it doesn't exist, it's a term being thrown around.
    I don't understand why you post on forums? Your attitude is pretty much going to guarantee that you drive away anybody who would be willing to help you. A shame given the quality of this forum.

    You are obviously not going to make the effort to learn OO until you see a need. While you are slapping front ends on relational data, you won't. Fair enough.

    You might start to see the point when you are dealing with non-tabular data, fuzzy data, or any system that has to evolve, or is poorly defined to begin with, a project with a large number of developers or one that has to be very flexible or configurable. That's normally anything that's new.

    yours, Marcus
    Marcus Baker
    Testing: SimpleTest, Cgreen, Fakemail
    Other: Phemto dependency injector
    Books: PHP in Action, 97 things

  18. #43
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rockit
    PHP 5 all the way.

    jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates -- with the buzz word "PHP5 installed."

    I run php5 on my local machine for development, but, before launch, I fire the sites up under php4 to make sure my code still runs under php4. I do a lot of OOP programming with PHP, but, at the moment I make sure that I don't code PHP5 specific.

    In regards to PHP 6, again, jim9 brought up a good argument -- php5 has not been fully adopted across the web, php 4 is still the major installed version. If it weren't, we would be knocking php5 and talking about php6 and you would have to really dig through old threads for info on php4 specifics.
    intragenesis, llc professional web & graphic design

  19. #44
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by holmescreek
    jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates -- with the buzz word "PHP5 installed."
    I hate to quote DHH but how many hosts do you need? You don't need a thousand hosts. You only need one or two. So, if there are only 10 or 20 to choose from thats not really a big deal. Also companies to follow technology generally better companies and in the end hosting is dirt cheap.
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  20. #45
    SitePoint Wizard dreamscape's Avatar
    Join Date
    Aug 2005
    Posts
    1,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by holmescreek
    jim9 does have a good point. most hosting companies, even large companies, are still running php4. The only companies I really see running (and supporting) PHP 5 are those with pricey, dedicated servers, or $el-Cheap-O companies reselling, resold, refried, resold, then resold again beaner hosting plans at those notorious great $4.95/month rates
    Where are you pulling this information from? It is simply not true anymore. Many hosts now offer either dual PHP 4/PHP 5 setups or give customers the option of PHP 4 or PHP 5.

    All it takes is a few moments and your favorite search engine to realize that PHP 5 hosts are no longer a rarity. And every day more and more hosts are upgrading to PHP 5.

    It is true that there are more PHP 4 hosts than PHP 5 hosts, but it is just simply not true that PHP 5 hosts don't exist or are hard to find. Just not true.
    <.smarter.web.development.>
    PHP Stuff: Plexus | Chocolate (BDD Framework... coming soon)
    Graphite

  21. #46
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by The New Guy
    I hate to quote DHH but how many hosts do you need? You don't need a thousand hosts. You only need one or two. So, if there are only 10 or 20 to choose from thats not really a big deal. Also companies to follow technology generally better companies and in the end hosting is dirt cheap.

    I only need one. It took several years of dealing with "big-name" hosting companies, (10 years to be exact), going from what the hosting reviews said was the best, etc, etc, to finally get to a company that I've actually been with for about 3 years. Before that, I've dealt with a lot of companies that start off with great support -- but, when things "break" -- crap support, no support answer, tech support with no phone number, and the infamous "fill out a ticket."

    It is good to see competition blooming, the industry is now reaching a point where they are learning how to keep customers; they have to answer the phone 24/7, without a 45 minute que, without having to go through level 1, 2, 3 support talking to someone in India with a thick accent -- then finally transferring your call back to the US to talk to "top level" support -- where finally you can describe the problem and its fixed in about two minutes.


    So, I agree -- somewhat, I don't think its the companies that follow technology, because as you can see, beyond the long distance call, the 3 step ticket system, talking to Ali-Babbi in India, then having your phone call finally transferred back to the US when you can ask the question and get the answer in 2 minutes or less -- great technology <not> --
    intragenesis, llc professional web & graphic design

  22. #47
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dreamscape
    but it is just simply not true that PHP 5 hosts don't exist or are hard to find. Just not true.
    Of course there are PHP 5 hosts out there, and yeah, if you do a search, in the search engine of your choice, as you suggest, you will find a lot.

    Just saying its hard enough to find a good host period -- and to find a good host that fully supports PHP5 is even harder.

    WHen I state "good" host, it means that I've got 80+ clients that rely on my company to keep their small business to fortune 1000 company online. Clients that rely on my judgment to determine the hosting company that is reliable.
    intragenesis, llc professional web & graphic design

  23. #48
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    If you have 80+ clients its time to stop buying shared hosting and get a dedicated server and start putting on whatever you damn well please
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  24. #49
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for me the same concept. Php4 and php 4 hoster....more reliable for my clients!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •