oop

Can I un-assign (clear) all fields of an instance?

Is there a simple way to clear all fields of an instance from a an instance? I mean, I would like to remove all values assigned to the fields of an instance. ADDED From the main thread I start a window and another thread which controls state of the window (the last thread, for example, display certain panels for a certain period of tim...

Inheritance Problem in Perl OOP

Hello, I have a sub class that calls a method from a super class. and the method in the super class use a method that is defined in the super class as asbstract(not really abstract) but implemented in the sub class. for example: package BaseClass; sub new { } sub method1 { return someAbstractMethod(); } sub someAbtsractMetho...

Using enums or a set of classes when I know I have a finite set of different options?

Let's say I have defined the following class: public abstract class Event { public DateTime Time { get; protected set; } protected Event(DateTime time) { Time = time; } } What would you prefer between this: public class AsleepEvent : Event { public AsleepEvent(DateTime time) : base(time) { } } public class A...

Java back-door interface, or, restricting method access by calling object

I'm using Java. I want to have a setter method of one class that is only accessible to an "owning" object of another class. I'll be more specific: I have Node and Port interfaces. Every node has a set of Ports, and each Port belongs to a single Node. A Port may be enabled or disabled, handled with a simple boolean property. However...

R: Pass by reference

Can you pass by reference with "R" ? for example, in the following code: setClass("MyClass", representation( name="character" )) instance1 <-new("MyClass",name="Hello1") instance2 <-new("MyClass",name="Hello2") array = c(instance1,instance2) instance1 array instance1@name="World!" instance1 array the output is > ins...

Flash AS3: automate property assignment to new instance from arguments in constructor

I like finding out about tricky new ways to do things. Let's say you've got a class with a property that gets set to the value of an argument in the constructor, like so: package{ public class SomeClass{ private var someProperty:*; public function SomeClass(_someProperty:*):void{ someProperty = _someProperty; } } } That's n...

C# Lack of Static Inheritance - What Should I Do?

Alright, so as you probably know, static inheritance is impossible in C#. I understand that, however I'm stuck with the development of my program. I will try to make it as simple as possible. Lets say our code needs to manage objects that are presenting aircrafts in some airport. The requirements are as follows: There are members and ...

AS3 OOP MVC with PHP

Im new to ActionScript and Flex 3... im trying to develop an MVC 100% OOP application with Flex 3 using MXML,AS3 and PHP. M (PHP) V (MXML) C (AS3) The 3 layers i choose for my development. I have 10 AS3 classes that are object related between them and some inherit or implement interfaces. The only problem here is how to interact 100% ...

Is this a good way to expose generic base class methods through an interface?

I am trying to provide an interface to an abstract generic base class. I want to have a method exposed on the interface that consumes the generic type, but whose implementation is ultimately handled by the classes that inherit from my abstract generic base. However I don't want the subclasses to have to downcast to work with the generi...

Better explanation of $this-> in this example please

Referring to this question: http://stackoverflow.com/questions/2035449/why-is-oop-hard-for-me class Form { protected $inputs = array(); public function makeInput($type, $name) { echo '<input type="'.$type.'" name="'.$name.'">'; } public function addInput($type, $name) { $this->inputs[] = array(...

What do you call functions which get and set?

The jQuery framework has a lot of functions which will either retrieve or mutate values depending on the parameters passed: $(this).html(); // get the html $(this).html('blah'); // set the html Is there a standard name for functions which behave like this? ...

static void classes

Hello, I'm tidying up some of my code with the correct scope on some methods and attributes (I have two classes and at the moment I have a number which I just declared as public to get working, but I feel I should look into this and make private where possible, for better practice) When working in eclipse it's suggested on one method, w...

Calling overridden method from within overriding method in OO PHP

Working in a symfony model, I want to override a function and call the overridden function from within the overriding one, along the lines of class MyClass extends BaseMyClass { function setMyProperty($p) { parent::setMyProperty($p); //do some other stuff } } This is resulting in a segmentation fault. I don't want to alt...

How to make this OO?

Hello, Sorry for the poor title,I'm new to OOP so I don't know what is the term for what I need to do. I have, say, 10 different Objects that inherit one Object.They have different amount and type of class members,but all of them have one property in common - Visible. type TSObject=class(TObject); protected Visible:boolean; en...

How does this code break the Law of Demeter?

The following code breaks the Law of Demeter: public class Student extends Person { private Grades grades; public Student() { } /** Must never return null; throw an appropriately named exception, instead. */ private synchronized Grades getGrades() throws GradesException { if( this.grades == null ) { this.grades = c...

OOP Design Question - Where/When do you Validate properties?

I have read a few books on OOP DDD/PoEAA/Gang of Four and none of them seem to cover the topic of validation - it seems to be always assumed that data is valid. I gather from the answers to this post ( http://stackoverflow.com/questions/1651964/oop-design-question-validating-properties ) that a client should only attempt to set a valid ...

Any tips on moving from ActionScript 3 to Python?

I've been developing stuff using ActionScript since AS2,and when AS3 was released i had a bit of a hard time to understand its concepts. Then i realized i had to learn some OOP. I started studying OOP and now i feel i need to take a step further, that's why i chose Python. Are there any tips/advices/hints or whatever like that to help me...

How do I improve this design for dealing with intersecting date ranges and resolving date range conflicts?

I am working on some code that deals with date ranges. I have pricing activities that have a starting-date and an end-date to set a certain price for that range. There are multiple pricing activities with intersecting date ranges. What I ultimately need is the ability to query valid prices for a date range. I pass in (jan1,jan31) and I ...

get python class parent(s)

How can I get the parent(s) object of python class? ...

explaining $this->load->view()

In a controller you can use this method to load a view, but I want to know what happens behind the scenes here. I'm new to PHP and frameworks, but I’ve learned the basics of OOP. When $this->view() is called then the method in the current class or the parent class is used. But what does $this->load->view() mean? What is the intermedi...