I did see this question but it doesn't fully answer the question I have.
If I do this:
$obj1 = new ObjectOne();
and then this:
$obj2 = new ObjectTwo($obj1);
$obj2->someFunction();
Where someFunction() modifies the attributes of the object passed into it, will both $obj1 and $obj2->passedInObject both in effect be updated?
...
Trying to avoid Tell-don't-ask, I want to combine a bool property that I was asking before calling a method, into a new method returning bool.
I try to follow the pattern, that if a method can't perform the action implied by it's name, it will throw an exception. For example if SendMail can't send the mail, it will throw an exception.
...
How can I get some var / data from a custom classes?
The XML class
package classes
{
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
public class videoData extends MovieClip
{
private var myXML:XML;
private var myXMList:XMLList...
Hi,
I'm a little bit confused about MVC and OO paradigms. I have read some documentation about classical OO in the book "The Object-Oriented Thought Process".
Now I need to apply what I have learn in this book in the context of MVC pattern.
How can I design from scratch using the OO paradigm and implement it in a MVC Framework like C...
Hello,
I am trying to understand Java's polymorphism, and I have one question about downcasting an object.
Let's say for this example I have two subclasses Dog and Cat that inherit from a superclass Animal
From what I understood, the only way to downcast an object is if this Object is already of the good type, like this:
Animal a = ne...
I came across these lines of code
ClassA classAObject;
//some lines of code that hydrate 'classAObject'
DerivedFromClassA derivedObject = classAObject as DerivedFromClassA;
whats going on, on the last line? Is it assigning to derivedObject only those values that are in common between derivedObject and classAObject ?
...
Hey All,
As we know that we CANNOT create the instance of abstract class.
I just want to know that if we create the array of abstract class, it will sure work.
E.g.
public abstract class Creator
{
public abstract void DoSomething();
}
Creator creator = new Creator(); // this will give you compilation error!
Creator[] creator = ...
I have been thrust into taking over some code but I may be out of my element in figuring this one out. If someone could give me a hint I'd appreciate it. I'm enjoying learning this code but every now and then I need a push.
When looking through this code I came across this line:
my @files = My::Module::DB::raw_info->search_like(custom...
I'm trying to translate the Haskell core library's Arrows into F# (I think it's a good exercise to understanding Arrows and F# better, and I might be able to use them in a project I'm working on.) However, a direct translation isn't possible due to the difference in paradigms. Haskell uses type-classes to express this stuff, but I'm no...
Basically what I'm trying to achieve is to make the object reference another object of the same class - from inside of a method. It'd be perfect if the following would work:
$this = new self;
But one cannot reassign $this in php.
I of course know, I can return another object from the method and use that, so please do not advise that...
What are the differences between DTO pattern(by Fowler) and Memento pattern(by GoF) in motivation and implementation aspect? Can it be the same classes? If yes, how can I name them (xxxDTO or xxxMemento)? Do they have any principal difference in implementation? Where are their place in MVP architecture?
Thanks.
...
Dear Experts,
My intent is to create a library/API for small scale distributed multi-user game /simulation.
i have created couple of applications using java RMI, i tried to keep them simple and to achieve decoupling and now i want to transform those or want to derive/extract from them a generic template.
Can somebody please shed ligh...
I read a lot about "program to interfaces" and "inversion of control" during the last days. Mostly in the context with the Java language. My question is if it is also a common practice in C++ development. What are the advantages? What are the disadvantages?
Is it worth to apply to small projects (like 15-20 classes)?
...
I have several web services which return various results. Some results are strings and some are arrays (automatically generated from the WSDL). When I call the web services, I want to get all the various results (including exceptions), and then operate on them through a common interface, but because of the type differences, I cannot ge...
Take for example following code from a class:
public class Employee : IEntity
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int EmployeeID { get; set; }
}
public class Company : IEntity
{
public string Name { get; set; }
public string TaxID { get; set }
}
I always used get; an...
Possible Duplicate:
Find out which class called a method in another class.
Hello everyone,
I have a class and I can't find where his object creates.
I mean, can I somehow find out who calls his constructor?
Thanks a lot,
Andrey.
...
I have a hierarchy in my website project as below:
[CustomControl1 - folder]
- CustomControl1.ascx
- CustomControl1.css
- CustomControl1.js
I load css and js files dynamicaly based on which controls are used on particular page. I am doing it by using following code:
protected void Page_Load(object sender, EventArgs e)
{
CustomCon...
I found different implementations of the observer pattern in Delphi, like:
Sourcemaking Design Patterns and Delphi Hobbyist.
In general, what is the best way to implement an observer in Delphi?
I would say using interfaces because the code is more readable.
...
Continuing from this question: http://stackoverflow.com/questions/1600667/method-overriding-and-visibility-in-java
I need to create class B that is almost identical to class A, except that B cannot do certain things that A can.
Being a lazy programmer as I am, I tried to inherit A, only to greet with error that B cannot reduce the visi...
I need to fix a third-party component. This component's class has private variable which is actively used by its descendants:
TThirdPartyComponentBase = class
private
FSomeVar: Integer;
public
...
end;
TThirdPartyComponent = class (TThirdPartyComponentBase)
protected
procedure Foo; virtual;
end;
procedure TThirdPartyComponent.F...