To tailor your scripts toward mp2, avoiding the need for any compatibility wrappers and such, it's said that you're supposed to declare variables using "local our" rather than "my". What about in modules?
sub new
{
local our $type = shift;
local our $self = {};
bless $self, $type;
}
Is that right? Or should it be 'my' so...
I have a set of some classes which are all capable of being constructored with an argument being an instance of a particular interface. Since they all can be constructed by this same object (and the process during which this construction happens is largely the same in all cases), I figured perhaps templating would work. Basically, I wa...
I was just thinking of cases when invariant(s) for mainly classes, but to some extent also structs, cannot be readily defined. Would the lack of invariant(s) be a definitive sign of bad design of the class or struct, or can you see valid reasons not to be able to define them?
To me, it feels like that's where you end up when things are ...
I'm attempting to access member variables in a child class via the parent class without instantiation.
This is one of my attempts but B::getStatic() fails with Access to undeclared static property.
Is there another solution to this, possibly without static?
class A {
static public function getStatic() {
return self::$myS...
Hi,
I a modeling a system to evaluate expressions. Now the operands in these expressions can be of one of several types including some primitive .NET types. When defining my Expression class, I want some degree of type-safety and therefore don't want to use 'object' for the operand object type, so I am considering defining an abstract...
So I've become a reasonably proficient Rails developer, and I'm finding that my bottleneck is now my lack of understanding of more complex Ruby constructs. I'm trying to build some plugins, and looking at some complex ones out there, their OOP wizardry is Greek to me. (I never had much formal OOP training so that's part of the problem.)
...
Say I have an interface IFoo, and I want all subclasses of IFoo to override Object's ToString method. Is this possible?
Simply adding the method signature to IFoo as such doesn't work:
interface IFoo
{
String ToString();
}
...since all the subclasses extend Object and provide an implementation that way, so the compiler doesn't c...
Is it acceptable to use the word 'Base' in a class name which is a the bottom of the inheritance tree?
I have always found this a bit of a cop-out, just wondering if anyone agrees with me.
For example, if I am refactoring certain elements from MyClassA and MyClassB into a common base class, I'd be tempted to create a MyBaseClass from w...
While reading some programming books, I notice that the authors says that, in OOP, you may have some confusion while understanding the main idea of OOP.
And hell yeah!. I had some confusion. Did you have the same and what makes this confusion to programmers(even experienced programmers)?!
And if you had it, how could you beat this ?!
...
class Super {
public void anotherMethod(String s) {
retValue(s)
}
public String retValue(String s) {
return "Super " + s;
}
}
class Sub extends Super {
public void anotherMethod(String s) {
retValue(s)
}
public String retValue(S...
Hi All,
I'm thinking in this line of code
IDataReader myReader = questDatabase.ExecuteReader(getQuest);
I'm using DAAB but I can't understand how and what's the meaning of the fact the method ExecuteReader(DbCommand) returns an IDataReader Interface.
Anyone can Explain, Please
...
I'm building an MVC framework, and I'm looking for native solutions / frameworks / tag libraries to draw from or to replace my framework entirely.
I'm interested in the following features specifically:
server-side DOM manipulation
server-side events (page reload, form submit, node insertion, etc.)
traversing the DOM tree using css sel...
I am attempting to learn OCaml by using compiled code instead of the top-level; however, much of the sample code online seems to appeal to the latter.
I would like to create a new Foo within a method of an object per below. This code does not compile, citing a syntax error with the doFooProc definition.
class bar =
object (self)
metho...
What is the best way to implement DTOs?
My understanding is that they are one way to transfer data between objects. For example, in an ASP.Net app, you might use a DTO to send data from the code-behind to the business logic layer component.
What about other options, like just sending the data as method parameters? (Would this be easi...
I'm working on a 10 page web site with a database back-end. There are 500+ objects in use, trying to implement the MVP pattern in ASP.Net. I'm tracing the code-execution from a single-page, my finger has been on F-11 in Visual Studio for about 40 minutes, there seems to be no end, possibly 1000+ method calls for one web page! If it wa...
I have a class in C++ with the following member:
map< someEnum, vector<SomeObject*>* > someMap
So I have a map that gives me a vector of objects for each enumeration I have. For the life of me, I cannot understand how C++ is initializing these objects. Does it deep initialize them by default? If not, what do I need to do?
I'm getting...
I have written a program with both a Advanced Mode and a Beginner Mode to allow the user to get the hang of my program before it is actually used. The Advanced Mode is almost identical to the Beginner Mode apart from one or two methods needing to be replaced by another, so I have decided to create a general Mode class for both Advanced M...
Recently I've been thinking about securing some of my code. I'm curious how one could make sure an object can never be created directly, but only via some method of a factory class. Let us say I have some "business object" class and I want to make sure any instance of this class will have a valid internal state. In order to achieve this ...
If I implement an interface on a base class will it be inherited by its sub classes, I know the functions/procedures will be, but I am more interested in whether I will be able to cast the subclass to the interface and then back to its original class.
What I am hoping I can do is pass objects of different base classes to a function, and...
Updated: 09/02/2009 - Revised question, provided better examples, added bounty.
Hi,
I'm building a PHP application using the data mapper pattern between the database and the entities (domain objects). My question is:
What is the best way to encapsulate a commonly performed task?
For example, one common task is retrieving one or mor...