My application controller looks like this
class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :all # include all helpers, all the time
protect_from_forgery # :secret => 'sup3rs3cr3t'
filter_parameter_logging :password
# Here's the interesting bit
before_filter :login_required, :except => ...
Say as an example I have a Player class that has a race via a Race class. These races are fixed in number and are loaded into an array which can be accessed statically.
My question is whether the Player class should have an index ID number which would then need to call the static function getRaceByID(int) to retrieve the Race class to ...
I have been working on some of the projects of my own and dont have any indrustial exposure. Currently i use simple approach for developing small applications with negligible OO approach like creating a common class for database functions using polymorphism of functions little bit use of constructors but i dont really able to think of ho...
I have a Blog class that does exactly what you think it would...create an object and handle it. That part is nice and clean.
I am now in need of a function that will quickly return a number of all the blogs in my database (not necessarily related to the blog object). Therefore, I am thinking a static method would be a good choice.
My q...
I've this sample code:
class A
{
public function A_A() { /* ... */ }
public function A_B() { /* ... */ }
}
class B extends A
{
public function B_A() { /* ... */ }
public function B_B() { /* ... */ }
public function B_C()
{
return get_class_methods($this);
}
}
$a = new A();
$b = new B();
Doing this:
echo '<pre>';
print_r...
Short description: I have a doubt whether it's normal that AbstractCrudDaoImpl implements both interface and abstract class which are inherited from the same parent (ReadOnlyDao).
...
If I have a interface IUser and a class that implements IUser:
public class User : IUSer
and both files are in different folders, can't ReSharper figure this out and link the two if I need to push down a method to the interface and vice versa?
...
I have a classB which extends classA. In classB I define a method fooBar() which is also defined in classA. In fooBar() of classB I want to call fooBar() of classA at the beginning. Just the way I'm used to, from Objective-C. Is that possible in PHP? And if so, how?
...
I am in the process of converting all my parameters, return types, classes to all use Interfaces instead ie. IUser instead of User.
Besides the extra code required to maintain this, are their any negatives to this approach?
...
Is it allowed to implicitly assign instance variables to an instance?
That is, inside a method of a class that has no instance variables, can I just do this?
$this->foo = "foo";
$this->bar = "bar";
and later just call those again? Will PHP just create instance variables in this case?
...
I'll be as direct as I can concerning this problem, because there must be something I'm totally missing coming from a structured programming background.
Say I have a Player class. This Player class does things like changing its position in a game world. I call this method warp() which takes a Position class instance as a parameter to mo...
Lets say I have an abstract ParentClass and a ChildClass. ChildClass extends ParentClass. Now ParentClass has got this nice constructor:
function __construct($tplFile) {
$this->$tplFile = $tplFile;
}
Will ChildClass automatically inherit this one? And if I don't add any constructor to ChildClass, will I be able to say $foo = new C...
I mean: Are there any things I can't implement in an abstract class? Like: Can an abstract class have a constructor, which just gets inherited by any child class? Or is the only limitation that I just can't say new AbstractClass(); ?
...
I'm having a hard time understanding why there is only one test per function in most professional TDD code that I have seen. When I approached TDD initially I tended to group 4-5 tests per function if they were related but I see that doesn't seem to be the standard. I know that it is more descriptive to have just one test per function be...
I am in the process of making a PHP web application. I have a situation that I believe would foster a good time for nested inheritance. Anyway, here is my situation:
public class RecurringWeeklyEvent extends RecurringEvent { }
public class RecurringEvent extends Event { }
It does not seem to me that this would be a bad design practic...
VB.NET: What is the best way to ensure that a particular object may be instantiated only once during program execution?
...
How do I use a function that I defined in a parent class in the child class?
for example if i use a class like the below
<?php
class mat
{
function square($x)
{
return $x *$x;
}
}
class matchild extends mat
{
function doublesquare($x)
{
return square($x) * square($x)
}
}
?>
If I try the above , I get an error saying th...
I've read some related questions (1, 2), but none seemed fully adequate.
What's the best way to access globally important objects in each class or .php script? A few examples:
DB (database)
Cache (memcache wrapper)
Logger (custom)
CurrentUser (details about the currently logged in user)
Some options I've seen include:
Relying on ...
I'm having a bit of a hard time. Essentially I need a data structure that would work a bit like a database. I need to be able to have multiple bits of data for each key and have the possibility of having multiple keys with the same name. Then I need to be able to search that data structure and pull the correct keyword and check it agains...
I have been using Rails for over 4 years so obviously I like Rails and like doing things the Rails Way and sometimes I unknowingly fall to the dark side.
I recently picked up Clean Code by Uncle Bob. I am on Chapter 6 and a bit confused whether we as rails developers break the very fundamental rule of OO design, i.e. Law of Demeter or e...