oop

Pass an object into another class by reference

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? ...

Method naming depending on returntype

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. ...

Getting data from custom classes (an OOP question)

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...

MVC and Classic OO Paradigm. How to?

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...

How to downcast a Java object?

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...

OOPs whats happening here in this assignment.

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 ? ...

C# abstract class, works with array initialization.

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 = ...

OOP question: Calling a subroutine?

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...

How would I translate a Haskell type class into F#?

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...

PHP assign value to $this

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...

DTO pattern vs Memento pattern

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. ...

How can we create library from Application? (Deriving library/API from Applications)

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...

Is "program to interfaces" a common design principle in C++ projects?

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)? ...

Wrapping several different types in a common generic class for common access?

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...

What a simple get; set; in a class means?

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...

Find who calls a method in PHP's class

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. ...

Alternative for static method in interface - enforce implementing class-level methods in asp.net custom controls

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...

Best way to implement observer pattern in Delphi

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. ...

Java, Cannot reduce the visibility of the inherited method from object

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...

Delphi: writing to the private ancestor's field in descendant class

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...