oop

Can you do classes in vbscript and ASP?

Is there anyway to do something like classes in vbscript. I ain't so good in classic ASP. Or does anybody have a C# vbscript conversion FAQ. My problem is that I must consume a webservice in classic ASP and the returntype is an array of a class. In asp.net with C# it's a piece of cake, because I know how to do it, but how do you do it i...

Should I use unset in php __destruct()?

Is it a good practice to unset the variables that you used in a class? Or its an optional? If its a good practice what is the benefit of using the unset function? Thank you. ...

How can I duplicate an object anonymously in C++-CLI?

I have a stream of data which is contained in a System::Collections::Queue. My data source can output the same data to multiple streams but to do so, needs to duplicate the data for each one. I currently do the following: void DataGatherer::AddMyDataToQueues(MyData^ data) { // Send duplicates to all queues for( int i = 0; i < m_...

Plain Old Objects in Ruby?

I notice in Ruby it is very common to for vendor APIs to pass back results as arrays? Shouldn't Plain Old Objects (Like POJOs in Java) be more of a standard? If I write my own library shouldn't I use POJOs POROs? ...

Does the Liskov Substitution Principle apply to subtype which inherited from abstract class?

loosely speaking, Liskov Substitution Principle states that a derived class can be substitute in place of the base class without affecting the user. In the case when the base class is an abstract class, which means no user is using an instance of the base class, does the Liskov inheritance restrictions still apply to the derived class? ...

Should I be using the command pattern? Seems like a lot of work...

My Room class has a lot of methods I used before I decided to use the command pattern. Previously, I was invoking a lot of commands and now it seems I have to make a method in my roomParser class for every method. If I wanted to invoke say, setHotelCode I would have to create a method in roomParser that iterates through and invokes the m...

Why aren't both versions of this code failing the -c Perl check?

The new method of Parse::RecDescent has this prototype: sub new ($$$) { # code goes here } and if I create an object like this: my $parser = Parse::RecDescent->new($grammar); it will create a parser, and the method will receive 2 parameters "Parse::RecDescent" and $grammar, right? If I try to create an object like: Parse::RecDe...

Where to learn how JavaScript based inheritance works?

Hi, I'm trying to write a software in JavaScript, but I'm having hard time trying to get the idea of all this prototype and other wicked looking inheritance stuff. What I would like to know are the different ways to get inheritance, and the pros and cons of each. ...

Is there a, kind of, 'Crystal Ball' OOP Design Pattern?

With regards to design patterns such as GoF, is there a pattern to decribe when one object needs to observe another object that is not even in existance yet? i.e. $crystalBall = new crystalBall(); $futureDependent = new FutureDependent(); $futureDependent->attach($crystalBall); ... then much later .... $importantObject = new Importa...

Help with Class Design

I have a class that has to take product information from one system's database and save it to another system's product database. I'll call a product from the first system Product A and the other Product B. Product B's data depends on settings selected from a user. So Product B may have a GetDescriptions method that looks at a user se...

Avoiding compiler warnings when doing message forwarding

I created a class that wraps a UITextView and adds some ui elements. I want the new class' API to be identical with UITextView, so I use message forwarding (listing below) to relay messages between the wrapped text view and the delegate. The irritating thing is that the compiler issues warnings for method invocations on instances of my ...

C# : Mini Application Structural Design (Classes/Interfaces/etc.)

I've been creating a small application that allows a user to convert images to various sizes and formats. I've been struggling on getting a good solid design with this application. I have the application up and running, but it does integrate good Object-Oriented design. Since this is a personal project, I've been wanting to learn more...

Should this JavaScript thing be an object or a singleton class?

Hi, I'm working on a JavaScript software that bears resemblance to Windows. It has a desktop, taskbar, etc. and I'm wondering whether I should make the desktop a class or an object? I'm thinking about making a process list array that holds all instances of objects. It would hold an instance of desktop. Does this make sense? Or should I...

put different class in hierarchy in one container in C++

Hi, Some times we have to put different objects in the same hierarchy in one container. I read some article saying there are some tricks and traps. However, I have no big picture about this question. Actually, this happens a lot in the real word. For example, a parking lot has to contain different types of cars; a zoo has to contain d...

Object oriented javascript best practices question: How should I configure my objects for the following...

I've decided I need to improve my javascript programming skills, as well as my OO skills. I am currently reading through some books, but sometimes it's hard to get a grip on the theory without seeing some practical examples first. So, I have a theoretical question about "best practices" for the following scenario... I would like to cr...

How to refactor this code?

Grouped params: <?php class Form { private $field; public function getFieldRelated($field) { return $this->fieldrelated[$field]; } public function __construct() { $this->fieldrelated['email']['name'] = 'email'; $this->fieldrelated['email']['value'] = $_POST['email']; $this->fieldrelated[...

Should I REALLY make subclasses in this situation?

I'm finishing a small project, an iPhone game. I've been expanding my GameObject class to include powerups and mines. These are physically identical to each other. Late last night I came up with the genius idea of making two subclasses of GameObject. They're each less than a hundred lines long. I also have to do stuff like cast them t...

Is downcasting (i.e. casting to derived type) ALWAYS wrong?

What is your perspective on downcasting? Is it ALWAYS wrong, or are there cases where it is acceptable, or even preferable or desired? Is there some good measure/guideline we can give that tells us when downcasting is "evil", and when it's "ok"/"good"? (I know a similar question exists, but that question spins out from a concrete case....

Doubt in using the interface ?

Hello All, Whenever i hear about interfaces i have the following doubt. i have the following interface interface Imammals { walk(); eat(); run(); } and i have two classes Human and Cat that implements this interface. Anyway, the functionality of the methods are going to be diffe...

Calling a method in an object, from inside a different object?

Is there anything particularly bad about doing something like this in Javascript: myapp.someObject = { this.doSomething = function() { // stuff happens . . . // myapp.someOtherObject.doSomething(); } } ...That is to say, calling a method in another object, from inside an objec...