| bio | website | |
|---|---|---|
| location | ||
| age | ||
| visits | member for | 1 year |
| seen | Apr 30 at 1:24 | |
| stats | profile views | 11 |
|
Feb 25 |
awarded | Caucus |
|
Jan 30 |
awarded | Commentator |
|
Jan 30 |
comment |
Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value? I understand Returning $this returns an instance of the object that the method is a member of. And in PHP OOP I believe, as I said in my question and you say in your answer, that the instance it returns is actually the very same instance as it is... i.e. it returns not a copy of itself but itself. If I am understanding correctly. |
|
Jan 30 |
revised |
Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value? added php tag |
|
Jan 30 |
asked | Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value? |
|
Oct 23 |
comment |
“Never do in code what you can get the SQL server to do well for you” - Is this a recipe for a bad design? @skynorth If you rely on the code to make sure your keys maintain integrity, then you are removing a fundamental principle of RDBMS from the DB. That makes no sense, because then every application that accesses the DB will have to make sure to precisely replicate that functionality. Why not just let the DB handle that, since that's what it's designed for. The DB can prevent duplicate keys natively, for example. |
|
Aug 29 |
comment |
Why don't inherited methods use child properties? (PHP) @NickC and who said anything about "coding only with static"? My question has one static function that returns an array of objects that each have object properties. My real class has a lot more class properties and a few more static properties. The question specifically asks about static property behavior, and so I didn't include all the irrelevant class components. |
|
Aug 19 |
comment |
Why don't inherited methods use child properties? (PHP) @NickC then how to handle properties that should remain constant through all objects of a class but allow them to be overridden by child classes? Class constants? Is it <i>better</i> to use a factory construct rather than a static method to generate collections of objects? It seems like the static method is simpler, but I'm probably wrong. |
|
Aug 19 |
revised |
Why don't inherited methods use child properties? (PHP) added apology on my use of static methods and members |
|
Aug 19 |
comment |
Why don't inherited methods use child properties? (PHP) Why is a static member not OOP? What is it's purpose, then? The data table is a constant for all objects of the class. I guess I could just use a class constant? Also, why is my question voted down 3 times without any explanation? I guess this site doesn't appreciate new posters. Good luck with that. |
|
Aug 19 |
awarded | Editor |
|
Aug 19 |
revised |
Why don't inherited methods use child properties? (PHP) added `extends` to child class (typo) |
|
Aug 19 |
comment |
Why don't inherited methods use child properties? (PHP) Yes that is a typo but it won't let me edit my post while there is an edit pending. And it also won't let me accept the edit. Makes sense, right? |
|
Aug 19 |
comment |
Why don't inherited methods use child properties? (PHP) I'm using PHP 5.3.2.1. I used static in the static methods and $this in the object methods and now everything is working. Thanks so much! |
|
Aug 19 |
comment |
Why don't inherited methods use child properties? (PHP) @AbhiBeckert yes that is just a typo. I want to fix it but it won't let me edit my post because there is a pending suggested edit, and I don't have enough rep to confirm that edit. That seems kind of stupid. How can I not be allowed to accept an edit to my own question? |
|
Aug 19 |
asked | Why don't inherited methods use child properties? (PHP) |
|
Aug 17 |
awarded | Teacher |
|
Aug 14 |
answered | Don't Use “Static” in C#? |
|
Aug 13 |
comment |
Does Parallel Inheritance Make for Good Code? Would you suggest a FieldStrategy class, where the __construct() takes arguments that set the field strategy? And then each class that needs a FieldStrategy can set its own version of the class? |
|
Aug 13 |
comment |
Does Parallel Inheritance Make for Good Code? After working on this code for a few more months, I have to say that I agree with @Izkata. That part of the system is very fragile. Rather than refactor it, I've ended up creating new classes to handle the same data, and left the old ones in place for use in the scripts that already work. |