oop

tagging methods and calling them from a client object by tag

Hello, I have been trying to figure out a way to tag several methods from my base class, so that a client class can call them by tag. The example code is: public class Base { public void method1(){ ..change state of base class } public void method2(){ ..change state of base class } public void m...

Getting an OOP PHP calendar app to update two tables at once.

I'm building a PHP calendar app for a photography group. They need to be able to assign multiple dates/times to a single event. As of now, I have an Events table and a Slots table (for time slots). Events only has id, title, and description, while Slots has id, start time, end time, and event_id as a foreign key. I've created an Event ...

Object design in .NET

I have a couple of employees that, while technically proficient, do not seem to fully grasp the nuances of building objects. Because C# is an Object Oriented Language (hey, no laughing from you Java people!! Don't think I didnt hear that!!) they understand that they are creating classes but they dont really understand how those classes ...

Python: List all base classes in a hierarchy

Given a class Foo (whether it is a new-style class or not), how do you generate all the base classes - anywhere in the inheritance hierarchy - it issubclass of? ...

How to know what class is referenced by a Class object?

We have the Class object (an object that reference a Class) so you can create objects from that Class object: var classObject:Class = package.to.class.AClass; var objectFromClass:AClass = new classObject(); Now, I want to know what object is referenced by classObject. For example: function Creator(classObject:Class):AClass { // h...

How to design an interface for muliply containment

Consider the following simplified demonstration: Class X contain class Y. Class Y has public method, Y.doY Stuff(). How to design X interface which use Y methods as is? If one append public method to X which simply forward the requst to Y, it results in an undesirable fat X interface and dependency of X code to Y code. This approach ...

In PHP, can you instantiate an object and call a method on the same line?

What I would like to do is something like this: $method_result = new Obj()->method(); Instead of having to do: $obj = new Obj(); $method_result = $obj->method(); The result doesn't actually matter to me in my specific case. But, is there a way to do this? ...

What is the best way to initialize an application?

What is the best way of initializing and terminating an application? The library needs to be initialized/terminated only once and can be used by any number of dlls. Is there any standard design to accomplish this? This initialization has to be the very first step. Is singleton is what I need here. Any number of dlls which are loaded...

OOP DAO design question

Quick background: I'm programming in PHP, I have a domain model with a separate data access layer (DAO classes) that are responsible for fetching data from the DB and creating domain classes. Let's say I have a DAO class responsible for creating group and groupList objects. You can imagine the groups as a component of a social network; ...

How do you implement a class in C?

Assuming I have to use C (no C++ or object oriented compilers) and I don't have dynamic memory allocation, what are some techniques I can use to implement a class, or a good approximation of a class? Is it always a good idea to isolate the "class" to a separate file? Assume that we can preallocate the memory by assuming a fixed number of...

Javascript OOP query re DOM

can you use parameters some how to alter 'book' and 'person' in this statement : book.borrower= person; eg JSObj.borrower = "SteveJobs"; I cannot seem to find a way, Is there one? ...

What will be a good minimalistic Javascript inheritance method?

I'm rewriting a JavaScript project, and I want to be able to use object oriented methodologies to organize the mess that the current code is. The main concern is that this JavaScript is supposed to run as a widget inside 3rd party websites and I can't have it conflicting with other JavaScript libraries that other websites may use. So I'...

Object oriented design resources

I am looking for good resources (books/web sites) for learning object oriented design. Every resource that I find are tutoring me more on UML and RUP instead of OO design. Head first book's sheer repetition is making me not want to read any of their books. I am looking for a book similar to "Structure and interpretation of computer progr...

How to access to ghost parent classes in ruby?

Hi, I was watching the first ruby metaprogramming screencast by prag dave. At some point he said that ruby introduce 'ghost classes' when you add a method to an instance variable. i. animal = "cat" def animal.speak puts "hola" end animal.speak # => hola animal.class # => String dog = "dog" dog.speak # Undefined ...

Get list of object's methods, properties and events?

Hello When trying a new component for which there's no documentation, I need to go through its methods, properties, and events to try to figure out what it can do. Doing this through the IDE's Object Inspector is a bit tedious. Is there a utility that presents this list in a more readable format? Thank you. ...

Input Required for Message Passing?

Is message passing taking place when calling a function with no input? i.e. with: object.toString(); Am I passing a message to 'object'? This might vary between languages, but I'm specifically referring to Java. ...

how can I replace instanceof in this case?

I'm trying to compare compareCriteria. Simple ones like 'between' and 'inArray' or 'greaterThan'. I use polymorphism for these classes. One method they share from the compareCriteria interface is 'matchCompareCriteria'. What I'm trying to avoid is having each class check for the type of compareCriteria they should match against. Eg the ...

Availability Issue

Architecture: A bunch of clients send out messages to a server which is behind a VIP. Obviously this server poses an availability risk. The client monitors a resource and the server is responsible to take action based on the what status the majority of the clients report to it and hence the need for only 1 server/leader. I am thinking...

Is it bad to use autoloading in PHP?

From php.net... In PHP 5, this is no longer necessary. You may define an __autoload function which is automatically called in case you are trying to use a class/interface which hasn't been defined yet. By calling this function the scripting engine is given a last chance to load the class before PHP fails with an error. Now I am wantin...

couple of questions about OO and classes in PHP

I am learning about OO and classes, I have a couple of questions about OO and classes in PHP As I understand it, a class that extends another class simply means that the class that extends the other class has access to the variables/properties and the functions/methods of the class that it is extending from. Is this correct? I know tha...