Re: [PHP] Silly OOP question
Semantics. Until any langiage compiles to pure 1s and 0s, it's all about bytecode. Even C compiles to assembler which is really just a low level bytecode. Just a note: C compiles to opcodes. opcodes are 1s and 0s directly interpreted by CPU. Same applies to assembler. (asm-opcodes). The true is that C has nothing to do with assembly language. Note on inline C assembly: When you use inline C assembler several thing happen: 1) C compiles itself to assembler 2) Your inline assembly code is then inserted properly 3) Asm compiles to opcodes (And assembler compiler is required: MASM - used by ms compilers, TASM-borland etc..) When no inline assembly used C code compiles directlly to opcodes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
On Mon, 2004-11-15 at 10:17, Simas Toleikis wrote: Semantics. Until any langiage compiles to pure 1s and 0s, it's all about bytecode. Even C compiles to assembler which is really just a low level bytecode. Just a note: C compiles to opcodes. opcodes are 1s and 0s directly interpreted by CPU. Same applies to assembler. (asm-opcodes). The true is that C has nothing to do with assembly language. Note on inline C assembly: When you use inline C assembler several thing happen: 1) C compiles itself to assembler 2) Your inline assembly code is then inserted properly 3) Asm compiles to opcodes (And assembler compiler is required: MASM - used by ms compilers, TASM-borland etc..) When no inline assembly used C code compiles directlly to opcodes. True :) I guess the point I was trying to make is that the opcodes that C compiles to are less efficient (processor wise) than if the actual machine language was manipulated. Working with assembler gets one closer to that potential efficiency, but still not perfect. Understandably this is necessary or we'd still be spending weeks to write simplistic programs. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Silly OOP question
I've always wondered this about OOP and maybe you guys can answer this question. I'm writing a php application and I'm trying to figure out the correct way to right the oop part of this application. for instance. I have a project.class file that has functions for dealing with individual projects because you break down ideas into singular entities in OOP(as I understand it) But what if I wanted to deal with multiple projects such as getting a list of the projects in my database, should I create a function in the project.class to handle the now plural request, or should I create a projects.class file that has a function called getProjects. Hopefully I'm explaining this question right. It makes sense in my own head. :-) Thanks, Brent
Re: [PHP] Silly OOP question
At 12:34 14-11-2004, Brent Clements wrote: I've always wondered this about OOP and maybe you guys can answer this question. I'm writing a php application and I'm trying to figure out the correct way to right the oop part of this application. for instance. I have a project.class file that has functions for dealing with individual projects because you break down ideas into singular entities in OOP(as I understand it) But what if I wanted to deal with multiple projects such as getting a list of the projects in my database, should I create a function in the project.class to handle the now plural request, or should I create a projects.class file that has a function called getProjects. Hopefully I'm explaining this question right. It makes sense in my own head. :-) If I get what you're doing right, then you need to break it down more, if you wanna go truly OOP ... and create an array of objects. Something like: $arrProjects[] = new project($projectname); and then have an object for each idea, that are handled by the projects, like: class Project { var $project_name; var $arrIdeas[]; function Project($projectname) { $this-project_name = $projectname; } function add_idea() { $this-arrIdeas[] = new idea(); } } Just remember that PHP isn't a true OOP language, so going OOP may not necessarily be the best solution always. OOP makes certain types of projects easier to code, and some projects would be almost impossible to do without OOP (like anything you wanna do where you need to use scope to avoid major headaches), but because PHP isn't compiled or a true OOP language, OOP in PHP hampers performance, and that hampering is exponential with the complexity of the objects. FWIW Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
On Sun, 2004-11-14 at 09:30, -{ Rene Brehmer }- wrote: Just remember that PHP isn't a true OOP language, so going OOP may not Please define true OOP language and provide a few examples that meet your criteria. Then show how other examples like PHP fail to meet your true OOP criteria. Don't forget, if a language has OOP as a subset, it still has true OOP capabilities. Also it might help to clarify if you mean PHP in general or PHP4 and below. necessarily be the best solution always. OOP makes certain types of projects easier to code, and some projects would be almost impossible to do without OOP (like anything you wanna do where you need to use scope to avoid major headaches), but because PHP isn't compiled or a true OOP PHP is runtime compiled to bytecode. It's just as compiled as any other language. With a good compiler cache it's just as compiled as java. language, OOP in PHP hampers performance, and that hampering is exponential with the complexity of the objects. You're shitting us all right? Exponential? Really? could you show us some benchmarks on how it's exponential? Let's not be sowing seeds of FUD on the PHP general list. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
Brent Clements wrote: or should I create a projects.class file that has a function called getProjects. Yes, that's a possibility. You can even create more stuff in this Projects class like createProject, removeProject and stuff like this. If these tasks are pretty static and you don't need multiple instances of the Projects class then you can implement it completely statically so you don't need to instanciate the class: class Projects { private static $projects = array(); public static function getAll() { return self::$projects; } public static function add(Project $project) { self::$projects[] = $project; } } So now you can do this to get the projects: $projects = Projects::getAll(); Adding objects to the list can be done by the constructor of the Project class: function __construct() { Projects::add($this); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
At 17:14 14-11-2004, Robert Cummings wrote: On Sun, 2004-11-14 at 09:30, -{ Rene Brehmer }- wrote: Just remember that PHP isn't a true OOP language, so going OOP may not Please define true OOP language and provide a few examples that meet your criteria. Then show how other examples like PHP fail to meet your true OOP criteria. Don't forget, if a language has OOP as a subset, it still has true OOP capabilities. Also it might help to clarify if you mean PHP in general or PHP4 and below. True as in parts of the OOP not being optional, like it is in PHP. You can fudge around the OOP principle in PHP and still get it working. necessarily be the best solution always. OOP makes certain types of projects easier to code, and some projects would be almost impossible to do without OOP (like anything you wanna do where you need to use scope to avoid major headaches), but because PHP isn't compiled or a true OOP PHP is runtime compiled to bytecode. It's just as compiled as any other language. With a good compiler cache it's just as compiled as java. Compiled to byte-code is only the same as pre-compiled in most other programming languages. language, OOP in PHP hampers performance, and that hampering is exponential with the complexity of the objects. You're shitting us all right? Exponential? Really? could you show us some benchmarks on how it's exponential? Dynamic object creation will always hamper performance relative to the object complexity. It's true for all languages ... it's within seconds though on a non-dedicated server, but depending on what you do, it's not that hard to break 30 secs exec time on PHP that way. Let's not be sowing seeds of FUD on the PHP general list. Then it might be good to read instead of interpret. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
On Sun, 2004-11-14 at 13:27, -{ Rene Brehmer }- wrote: At 17:14 14-11-2004, Robert Cummings wrote: On Sun, 2004-11-14 at 09:30, -{ Rene Brehmer }- wrote: Just remember that PHP isn't a true OOP language, so going OOP may not Please define true OOP language and provide a few examples that meet your criteria. Then show how other examples like PHP fail to meet your true OOP criteria. Don't forget, if a language has OOP as a subset, it still has true OOP capabilities. Also it might help to clarify if you mean PHP in general or PHP4 and below. True as in parts of the OOP not being optional, like it is in PHP. You can fudge around the OOP principle in PHP and still get it working. True OOP is a programming paradigm you can choose or not choose to adhere to. Even in a purist OOP model, some person could implement their entire application in a procedural manner by creating a single Program object and using that object's methods as though they were non OOP procedures. So thusly, if I choose to only use OOP features in my code, then PHP is as pure as any other pure OOP model, by your own understanding. Thus the ability of PHP to be OOP is entirely dependent on the developer. necessarily be the best solution always. OOP makes certain types of projects easier to code, and some projects would be almost impossible to do without OOP (like anything you wanna do where you need to use scope to avoid major headaches), but because PHP isn't compiled or a true OOP PHP is runtime compiled to bytecode. It's just as compiled as any other language. With a good compiler cache it's just as compiled as java. Compiled to byte-code is only the same as pre-compiled in most other programming languages. Semantics. Until any langiage compiles to pure 1s and 0s, it's all about bytecode. Even C compiles to assembler which is really just a low level bytecode. language, OOP in PHP hampers performance, and that hampering is exponential with the complexity of the objects. You're shitting us all right? Exponential? Really? could you show us some benchmarks on how it's exponential? Dynamic object creation will always hamper performance relative to the object complexity. It's true for all languages ... it's within seconds though on a non-dedicated server, but depending on what you do, it's not that hard to break 30 secs exec time on PHP that way. There is a performance loss in any OOP system over a non OOP system, because the great things like polymorphism have a pricetag. However, your original comment specifically narrowed the field of attention to PHP, which is not valid narrowing since it makes it seem like there are OOP implementations that do not have performance overhead for such features. If there are, I'm sure you can tell me a few. Let's not be sowing seeds of FUD on the PHP general list. Then it might be good to read instead of interpret. To read is to interpret. Otherwise you're just looking. You moment you give anything meaning you have made an interpretation. Albeit the interpretation may be based on globally shared rules, or personal subjective ideals. Either way, your writing was not IMHO based on globally shared rules, but rather on your own personal subjective ideals, which again IMHO, were promoting FUD for PHP OOP. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
Klaus Reimer wrote: you can implement it completely statically so you don't need to instanciate the class Well, it might be useful to have more than one list of projects, ie if you want all design-related projects, or all PHP-projects. -- Daniel Schierbeck Help spread Firefox (www.getfirefox.com): http://www.spreadfirefox.com/?q=user/registerr=6584 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Silly OOP question
Daniel Schierbeck wrote: you can implement it completely statically so you don't need to instanciate the class Well, it might be useful to have more than one list of projects, ie if you want all design-related projects, or all PHP-projects. But then you might need a class to organize these Project Lists. Maybe THIS is then well suited for static methods ;-) -- Bye, K http://www.ailis.de/~k/ (FidoNet: 2:240/2188.18) [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger [EMAIL PROTECTED] to get public key) signature.asc Description: OpenPGP digital signature