SitePoint Sponsor

User Tag List

Page 5 of 16 FirstFirst 12345678915 ... LastLast
Results 101 to 125 of 386
  1. #101
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Hartmann
    With that being said, will these Language vs. Langauge threads ever stop??
    Not if me and Harry can help it!
    Mattias Johansson
    Short, Swedish, Web Developer

    Buttons and Dog Tags with your custom design:
    FatStatement.com

  2. #102
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by voostind


    That's right, I can't say that. So that's probably why I didn't...
    Sorry, I think there is a lot of misunderstanding going on in this thread
    Ohai!

  3. #103
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Re: Re: Language/technology

    Originally posted by Mincer


    But surely this example shows nothing relative to the php vs .net? I've said it about 10 times (not that anyone seems to notice) that we can't compare application development for standalone deployable binary executables with server-side web development. It's simply not comparing the same thing!
    As far as I understand it, almost anything applicable to general application programming with .NET is applicable to web programming. So what he said applies to web programming and to your issue regarding memory usage.
    Ohai!

  4. #104
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Whoa, this thread is growing at an alarming rate. It's 1:30AM here anyway, so I'm groing to bed. It's been great - goodnight, ya all!
    Mattias Johansson
    Short, Swedish, Web Developer

    Buttons and Dog Tags with your custom design:
    FatStatement.com

  5. #105
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thought I'd re-spam this link here: http://www.tiobe.com/tpci.htm

    Popularity of programming languages based on Google searches.

  6. #106
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright, I don't claim I am all knowing, but I would like to learn. For some reason I am under the impression that their OO isn't as good as say C#'s (or C++'s cauze that's my main language). But, please, if you can show me that OO is better done with PHP than C# I would gladly listen and learn.
    You are right PHP's OO isn't up to much, it does not include support for static members or allow you to control access to members with private/public/protected etc, things which are considered pretty basic and standard in most OO languages. Nor does it include support for multiple inheritence either in the form it takes in C++ or the more limited form through interfaces that Java and C# use.

  7. #107
    .NET inside archigamer's Avatar
    Join Date
    Jan 2002
    Location
    Strongsville OH
    Posts
    1,534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by M. Johansson
    Whoa, this thread is growing at an alarming rate. It's 1:30AM here anyway, so I'm groing to bed. It's been great - goodnight, ya all!
    yes, i can hardly keep up with it. i guess everyone wants to a piece of the beast
    Web Finesse Studios
    Professional, business oriented web hosting and development.

  8. #108
    SitePoint Addict mgkimsal's Avatar
    Join Date
    Sep 1999
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    frameworks

    What framework am I supposed to use with PHP to achieve this? Maybe there is one that I don't know of. Does anybody know?
    http://www.logicreate.com is one. Although it's always under development and improving, it's already in use. A wholeheartedly MS shop needed to do PHP for a client who was insisting on it. They chose LC over about 8 other PHP platforms. The primary developer on the project was quite surprised at how fast and easy it was, given that there was no VS or VS.net equivalent. This shouldn't be a commercial here, but if you're interested, go there and/or contact me off the board.
    Michael Kimsal
    =============================
    groovymag.com - for groovy/grails developers
    jsmag.com - for javascript developers

  9. #109
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Harry: http://www.tiobe.com/tpci.htm

    Basically says, a language that is less than a year old is about to overtake several of the most popular languages in Europe for development... In fact, it's only down by a few percentage points on "the most popular web deve language in the world"... Which has been around for many years.

    Remind me again who's "side" you're on? </tongue in cheek>

    neways, midnight here, so I'm off too
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  10. #110
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically says, a language that is less than a year old is about to overtake several of the most popular languages in Europe for development... In fact, it's only down by a few percentage points on "the most popular web deve language in the world"... Which has been around for many years.

    Remind me again who's "side" you're on?
    It's interesting reading as I said. C# is of course doing well for a young language - it's been hyped and is probably available (via Visual Stoogio) in most MS shops by now.

    Like I've mentioned elsewhere, the real "fight" for .NET is not with PHP (with which is can't really compete anyway, not being cross platform or free to run live) but with Sun: Java/J2EE.

    Right now, as we see, Sun has a massive lead at 34.4 (with bizarrely enough, good old Perl at #2 - please don't tell me about Perl.NET - it ain't gonna fly).

    Below that C and C++ account for a total 49.5 points - these are the guys MS is playing to.

    Basic is riding on 11.8 (that no doubt includes VB, VBScript etc.) which I'd guess will decline a little as people decide to switch to C#.

    PHP is storming up the charts, right now on 8 as is natural the worlds most popular server side scripting language. The big name apart from IBM are still pretending it doesn't exist (Sun and MS in particular) which is quite amusing. For a language with no advertising, no backing etc., it's the fastest growing on this chart after C#.

    C# is currently on on 2.2.

    So which way will things swing? For or against Sun and Java? Would seem to depend on the C and C++ developers - if they like C# then .NET can be a success. If they reject it though...

  11. #111
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Who do I even bother anymore?
    ...

    Anyway,

    You are right PHP's OO isn't up to much, it does not include support for static members or allow you to control access to members with private/public/protected etc, things which are considered pretty basic and standard in most OO languages. Nor does it include support for multiple inheritence either in the form it takes in C++ or the more limited form through interfaces that Java and C# use
    Static members

    Very, very few classes actually need them. So although they aren't in PHP, that's not a major problem. That said, it's very easy to write code that mimics static members.

    Private/Public/Protected

    Just because all member variables are always public, doesn't mean you HAVE to access them that way. By being strict and by having a little disciple, you can easily act as if all member variables are private (which they should be).

    Multiple inheritance

    It is true PHP doesn't support multiple inheritance. Neither does Smalltalk. Or Ruby. I'm glad of it. The amount of junk that's already been written with OO is enormous. By adding multiple inheritance to a language it would only become worse. There are very few reasons for needing multiple inheritance. And if you think you have found one, you are probably wrong.

    Vincent

  12. #112
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By adding multiple inheritance to a language it would only become worse
    Course they're adding it to PHP 4.3 To me, with my limited knowledge of OO, that makes sense.

    Surely if you design your class library correctly, with the right hierarchy, the job children perform should never need to inherit from more than one parent.

    Private and static members variables are also on the feature list of things to come (the best list is here). And coming soon means PHP 4.3 (we're on PHP 4.2.3 right now) so any time now - if we're lucky, by the end of the year.

  13. #113
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by voostind
    Who do I even bother anymore?
    ...
    Static members

    Very, very few classes actually need them. So although they aren't in PHP, that's not a major problem. That said, it's very easy to write code that mimics static members.

    Private/Public/Protected

    Just because all member variables are always public, doesn't mean you HAVE to access them that way. By being strict and by having a little disciple, you can easily act as if all member variables are private (which they should be).

    Multiple inheritance

    It is true PHP doesn't support multiple inheritance. Neither does Smalltalk. Or Ruby. I'm glad of it. The amount of junk that's already been written with OO is enormous. By adding multiple inheritence to a language it would only become worse. There are very few reasons for needing multiple inheritence. And if you think you have found one, you are probably wrong.

    Vincent
    The most widely used OO languages do use some form of multiple inheritence either in it's true form like C++ or with interfaces such as Java, C#, VB.net, Delphi. When it comes to proper multiple inhertence as with C++ I am inclined to agree with you, it often causes more problems than it solves. However this is exactly why Java and the others use the more simple and limited form of it through interfaces. There are reasons to use multiple inheritence, particularly interfaces, I suggest you look at this article for reasons why.

    http://www.javaworld.com/javaworld/j...echniques.html

    If multiple inheritence was of no use why do java and C# even bother with interfaces, why has vb.net introduced interfaces when they did not exist in the old VB, perhaps microsoft and sun are full of idiots that know nothing about programming, in that case I bow to your greater knowledge.

    Yes I agree not having static members is not a major flaw and yes people will not use them in the majority of classes in an application, that said it is still something that is missing from PHP and would be bettter than having to mimic them.

    No I don't have to access members as if they were public, but then following that line, you could simply pass off any deficency in PHP by saying you don't have to use OO, you can just write your code line by line and eventually achieve the same outcome, the point is it is missing and is something that PHP OO lacks, which was the complaint I made not that you can't imitate certain things in PHP with workarounds.

    The fact you can create workarounds for certain things, does not mean they are not needed, PHP does not have any decent error handling for instance the fact you can fudge it, is irrelevent, the fact that most other languages have proper errror handling and that it is in Harrys list of things that are being added, suggests that most programmers want proper error handling and believe it to be an advantage the same applies to static members etc.

  14. #114
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k, I wouldn't consider myself to be an OO guru, but I've never really seen the need for multiple inheritence, as for interfaces, you can easily do something like:

    PHP Code:
    class Person
    {
        function 
    talk() { die('talk() not implemented') };
        function 
    walk() { die('walk() not implemented') };
        function 
    sleep() { die('sleep() not implemented') };

    And classes that extend off that must have those methods. I don't see how the code above is any more complicated then if PHP does happen to support interfaces natively.

    Back to inheritence, for more complicated things, I find it more flexible to use composition anyway, and PHP doesn't need to do anything more to 'support' composition.

    The things above might considered to be 'workarounds', but why would PHP need to do anything more about it if the workaround is simple, and works well already?
    Last edited by Robo; Sep 9, 2002 at 03:29.
    Work smarter, not harder. -Scrooge McDuck

  15. #115
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Robo

    PHP Code:
    class Person
    {
        function 
    talk() { die('talk() not implemented') };
        function 
    walk() { die('walk() not implemented') };
        function 
    sleep() { die('sleep() not implemented') };

    And classes that extend off that must have those methods. I don't see how the code above is any more complicated then if PHP does happen to support interfaces natively.
    That does not really mimic interfaces, you are simply sticking everything in the root class and saying any class that extends that class can use those methods, but that would not solve the problems that interfaces are designed for. If we take the example in the link I gave, you have:

    PHP Code:
    java

    interface 
    Talkative {

        
    void talk();
    }

    abstract class 
    Animal implements Talkative {

        abstract public 
    void talk();
    }

    class 
    Dog extends Animal {

        public 
    void talk() {
            
    System.out.println("Woof!");
        }
    }

    class 
    Cat extends Animal {

         public 
    void talk() {
            
    System.out.println("Meow.");
        }
    }

    class 
    Interrogator {

        static 
    void makeItTalk(Talkative subject) {
            
    subject.talk();
        }
    }

    class 
    Clock {
    }

    class 
    CuckooClock implements Talkative {

        public 
    void talk() {
            
    System.out.println("Cuckoo, cuckoo!");
        }
    }

    class 
    Example4 {

        public static 
    void main(String[] args) {
            
    CuckooClock cc = new CuckooClock();
            
    Interrogator.makeItTalk(cc);
        }

    Using interfaces the cuckooClock can be passed to the makeItTalk() method, now if you were try to simulate this by simply putting all the methods in the root class you would somehow have to fit the cuckooClock class into the Animal family, which would not be particularly good modelling to say the least, alternitively you could just create the cuckooClock class seperately and write a seperate makeItTalk() method for it, but then repeating code like that defeats the point of using OO programming.
    Last edited by neil100; Sep 9, 2002 at 04:27.

  16. #116
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By adding multiple inheritance to a language it would only become worse
    You're pulling my statements out of context here, Harry!

    I didn't say the LANGUAGE would become worse if it would support multiple inheritance, I said the PHP code 'out there' that's implemented with OOP would become worse. That's something quite different!

    Using interfaces the cuckooClock can be passed to the makeItTalk() method, now if you were try to simulate this by simply putting all the methods in the root class you would somehow have to fit the cuckooClock class into the Animal family, which would not be particularly good modelling to say the least, alternitively you could just create the cuckooClock class seperately and write a seperate makeItTalk() method for it, but then repeating code like that defeats the point of using OO programming.
    Nice example. You give a very clear idea of what interfaces are for. The only problem with your example is that you don't take PHP's features into account.

    Question: why do you want interfaces? 2 reasons from 2 different points of view:
    1. (Language Designer) Because putting full multiple inheritance support in a language is hard, and interfaces are a clean way to get more or less the same results. I won't go into this any further, apart from saying that multiple inheritance is nowhere like interfaces at all, contrary to what Sun tries to make you believe.
    2. (Programmer) Because you want to support polymorphism in your code. You might want a list of Talkative objects, and those can be either Animals, Interrogators or Cuckooclocks. To be able to use polymorpish ('subject.talk()', with 'subject' being anything as long as it implements the Talkative interface), there has to be something that connects the object to the Talkative interface.

    In PHP, this is not necessary at all. You can call the method 'talk()' on anything; the object you're calling it on doesn't have to be Talkative. This is due to PHP's late binding. As an example, I can write this method:

    PHP Code:
    function speakWith(&$talkative)
    {
        
    $talkative->talk();

    Whether '$talkative' is a CuckooClock or an Animal doesn't matter, as long as it supports the 'talk' method. Instead of throwing an error at compile-time (Java), it will be thrown at run-time when 'talk' is called on an object that doesn't have this method.

    Of course there is a major drawback: the interface is nowhere specified explicitly. There is no way to enforce that a class implements all methods of an interface. In this example, the fact that both Animal and CuckooClock must implement the method 'talk' isn't clear, nor can it be enforced, whereas in Java, by saying that 'Animal implements Talkative', class Animal won't compile unless it defines all methods of the Talkative interface.

    Interfaces, access rights (private/protected/public) and such are all designed to aid the programmer, and nothing more. During compilation the compiler checks everything to make sure all rules are enforced (actually this is a pre-compilation step), and then happily throws them out of the window. Or do you believe that in machine code, private members are stored in some special, private set of variables, different from the one the public members are stored in? Of course not, they are all stored in the same block of memory. (Which is why in a low-level language like C++ it's possible to circumvent the various access rules; it's not hard to write a class that accesses private member variables of another class directly.)

    With my points I'm not trying to say that PHP's OO support is very good. I'm merely pointing out that everything you can do in Java, you can do in PHP as well in some way. So you can't say PHP's OO support is awful either; it's adequate.

    If multiple inheritence was of no use why do java and C# even bother with interfaces, why has vb.net introduced interfaces when they did not exist in the old VB, perhaps microsoft and sun are full of idiots that know nothing about programming, in that case I bow to your greater knowledge.
    You're turning what I say a bit around here. I said that USING multiple inheritance is almost always a bad idea. I never said that multiple inheritance itself is bad. That's not the same. There are very good reasons for multiple inheritance, but they are few. In 99 out of a 100 cases where multiple inheritance was used, object composition (or something else completely) would have worked much better.

    No I don't have to access members as if they were public, but then following that line, you could simply pass off any deficency in PHP by saying you don't have to use OO, you can just write your code line by line and eventually achieve the same outcome, the point is it is missing and is something that PHP OO lacks, which was the complaint I made not that you can't imitate certain things in PHP with workarounds.
    I understand your point, but I don't fully agree. I have found that even with PHP's limited support for OO, it's perfectly possible to write good OO. To achieve this, however, you (as a programmer) must be disciplined and follow a set of rules (like never accessing member variables directly). You could say that is working around deficencies of a language, but then again: most of the things missing are COMPILER features, aiding the programmer and then throwing them out. PHP is not a compiler but an interpreter, so you should give it some slack in that sense. Ruby for example is a great OO scripting language, but it doesn't enforce all 'standard' OO rules either, exactly because it is an interpreter and not a compiler.

    Vincent

  17. #117
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by voostind

    Interfaces, access rights (private/protected/public) and such are all designed to aid the programmer, and nothing more. During compilation the compiler checks everything to make sure all rules are enforced (actually this is a pre-compilation step), and then happily throws them out of the window. Or do you believe that in machine code, private members are stored in some special, private set of variables, different from the one the public members are stored in? Of course not, they are all stored in the same block of memory. (Which is why in a low-level language like C++ it's possible to circumvent the various access rules; it's not hard to write a class that accesses private member variables of another class directly.)

    With my points I'm not trying to say that PHP's OO support is very good. I'm merely pointing out that everything you can do in Java, you can do in PHP as well in some way. So you can't say PHP's OO support is awful either; it's adequate.
    No I don't believe private members are stored in a special place and I understand programming languages are simply there so programmers don't have to write in machine code.
    I also accept that you can use OO PHP through various workarounds and being disciplined in how you access members etc.

    The fact that PHP lacks support for static members may not be much in itself, even that it lacks support for interfaces, access rights, exception handling or that it copies every object rather than using handles (which may explain some comments on the performance of OO PHP compared to functional PHP) does not stop people writing OO PHP that works in the majority of cases. However in the context of this thread which is "reasons to choose .net as opposed to PHP" these areas where PHP OO is slightly lacking do make a difference. Although PHP's OO may be adequate in the majority of cases as you say, in this thread it is being compared to the languages available to .net, where it is fairly obvious that it's OO support is not as good, which counts against it. The fact the features missing are only there to help the programmer is no excuse, I and others like those features, features which are available in .net languages.

    Originally posted by voostind

    You're turning what I say a bit around here. I said that USING multiple inheritance is almost always a bad idea. I never said that multiple inheritance itself is bad. That's not the same. There are very good reasons for multiple inheritance, but they are few. In 99 out of a 100 cases where multiple inheritance was used, object composition (or something else completely) would have worked much better.
    Okay I was being a bit pedantic and while I agree it's not something that is or needs to be used very often, I would at least like the choice, very occasionally it is needed.

    Originally posted by voostind

    I understand your point, but I don't fully agree. I have found that even with PHP's limited support for OO, it's perfectly possible to write good OO. To achieve this, however, you (as a programmer) must be disciplined and follow a set of rules (like never accessing member variables directly). You could say that is working around deficencies of a language, but then again: most of the things missing are COMPILER features, aiding the programmer and then throwing them out. PHP is not a compiler but an interpreter, so you should give it some slack in that sense. Ruby for example is a great OO scripting language, but it doesn't enforce all 'standard' OO rules either, exactly because it is an interpreter and not a compiler.
    If we were just looking at PHP as a programming language in isolation then I would give it more slack on both it's OO and the fact that it's an interpreter rather than compilier. Once again however it has to be looked in the context of this thread, a comparision to .net and it's languages, so giving it slack is no longer an option. How many times has the fact that PHP hosting is cheaper than .net been mentioned by those who favour PHP, many times, yet do they give the .net hosts slack knowing they have to pay for more licensing or do they give microsoft slack for having to pay it's employees, no of course they don't and the same applies for being gentle on PHP, becuase it's not compiled.
    Last edited by neil100; Sep 9, 2002 at 06:57.

  18. #118
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well... as I said PHP's OO is slow relativly speaking. That's the major draw back for me. With other languages where OO is implemented faster I can write an OO application with a lot less lines of code and that actually runs faster than a procedural application.

    Second, there are a bunch of OO features that PHP does not offer that I have wanted to use in the past. Also, having the "polymorphism" implemented like you did makes it alot harder for other developers to see what's going on if the code is not well commented. With Interfaces, I could skim the code and see right away that the "makeittalk" function needed to be passed a class derived from the Talkative interface.

    Third, the question is not what can be done or not because everything can be done with almost any language. the question is how easily can it be done. I don't know about any of you but I can write OO code in assembly, the question is do I? Same goes for any other language. The fact is, PHP's OO is not up to par, and that cannot be denied. If it were, why would they be significantly improving it in the next version?
    Ohai!

  19. #119
    SitePoint Addict mgkimsal's Avatar
    Join Date
    Sep 1999
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Private/public

    I understand your point, but I don't fully agree. I have found that even with PHP's limited support for OO, it's perfectly possible to write good OO. To achieve this, however, you (as a programmer) must be disciplined and follow a set of rules (like never accessing member variables directly).
    As big a proponent of PHP as I am, the public/private issue does bother me some, specifically in the context of working with other developers.

    Yes, of course *I* can write stuff on my own and know what should and should not be accessed. when I let others start using my classes or try to redistribute my class in some fashion, there's nothing to enforce that private/public distinction. *THAT* to me is the problem - working by yourself is fine. Working in concert with other unknown entities is more problematic.
    Michael Kimsal
    =============================
    groovymag.com - for groovy/grails developers
    jsmag.com - for javascript developers

  20. #120
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, of course *I* can write stuff on my own and know what should and should not be accessed. when I let others start using my classes or try to redistribute my class in some fashion, there's nothing to enforce that private/public distinction. *THAT* to me is the problem - working by yourself is fine. Working in concert with other unknown entities is more problematic
    Tell me, why is that a problem for you? So what if other people access your private properties directly and they mess up the inner workings of your class/object. Isn't that their fault then? I mean, they are the ones messing with code they shouldn't mess with so if a problem arises because of that it's their fault...

    I agree with Vincent that private and public properties are there *only* to introduce some discipline in writing code, they have absolutely no meaning once the program is compiled. Public/Private makes you need come up with good class / interface designs, because your public methods need to be powerful enough to manipulate all aspects of the object without allowing the user of your class to mess up the internal workings of the class.

  21. #121
    SitePoint Addict mgkimsal's Avatar
    Join Date
    Sep 1999
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    public/private again

    Tell me, why is that a problem for you? So what if other people access your private properties directly and they mess up the inner workings of your class/object. Isn't that their fault then? I mean, they are the ones messing with code they shouldn't mess with so if a problem arises because of that it's their fault...
    Should I not do any error checking on user input then? After all, if I say 'put in a date' and they don't, and the program dies, it's their fault, right?

    If I sell a compiled/encoded PHP class, and someone happens to find an internal property which I *WANT* to be private, but is not enforced via PHP, there may be problems.
    Michael Kimsal
    =============================
    groovymag.com - for groovy/grails developers
    jsmag.com - for javascript developers

  22. #122
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IMHO opinion I believe you should have documentation which states which variables are public and what kind of variables your functions accept. You could include simple error checking for this of course.

    If your classes are compiled (using Zend Encoder I assume), the people who use your classes shouldn't even know about the existance of private variables, so they can't mess with them.

    It would of course be much easier if PHP were a strongly-typed language, cause then the compiler would enforce arguments passed to functions to be of a specific type. Maybe an idea for Zend Engine 3?

  23. #123
    SitePoint Guru Majglow's Avatar
    Join Date
    Aug 1999
    Location
    B-Town
    Posts
    645
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Captain Proton


    Tell me, why is that a problem for you? So what if other people access your private properties directly and they mess up the inner workings of your class/object. Isn't that their fault then? I mean, they are the ones messing with code they shouldn't mess with so if a problem arises because of that it's their fault...
    If I write an API or something using the OO paradigm w/ PHP but can't protect my private data and then SELL it. Then the client who buys it messes with the private members and the application breaks IN MY CODE then it's MY problem because the client won't be happy. I could end up losing money.

    Granted, this is less of a problem with PHP because there isn't dynamic memory and such to deal with... but it still is an issue.

    That is one example of why I am not too enthusiastic with the OO of PHP.

    *disclamer* (this is so I don't get bashed later because people think I said "PHP's OO sucks")

    I do not think PHP's OO "sucks". I use it when the need arises. I just think it could be better and does not better or equal to C#'s OO (ASP.NET: that's what the thread is all about).
    Ohai!

  24. #124
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I write an API or something using the OO paradigm w/ PHP but can't protect my private data and then SELL it. Then the client who buys it messes with the private members and the application breaks IN MY CODE then it's MY problem because the client won't be happy. I could end up losing money.
    Know this is not the answer you're looking for but right now (waiting for PHP 4.3) it's a practical solution: given you know C++ and you wish to sell you're software to customers using PHP, there's an alternative;

    Write your own PHP extension in C++

    (correct me if I'm wrong - is not in option with .NET)

    Not only is your code then closed source, it will also be extremely fast and benefit C++ OO.

  25. #125
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whats not an option with .NET? C++?


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
  •