oop

Significant Challengers to OOP

From what I understand, OOP is the most commonly used paradigm for large scale projects. I also know that some smaller subsets of big systems use other paradigms (e.g. SQL, which is declarative), and I also realize that at lower levels of computing OOP isn't really feasible. But it seems to me that usually the pieces of higher level solu...

OO Design: Returning a child class from a parent

I'm still a novice when it comes to polymorphism so I hope I can phrase my question correctly. Let's say I have tables in my Database - Dog, Cat and Mouse. I want to be able to call something like: $animal = new Animal("dog", 12); with the animal class being something like: class Animal { protected $id; protected $legs; prote...

Is there a design pattern that deals with callback mechanism?

Is there a design pattern that deals with callback mechanism? ...

Accessing a class that is related to two other classes

Given the following tables: User, Trial, UserTrial. Where A user has multiple trials, a Trial does not internally map to any Users and contains details about the trial (name, description, settings), and a UserTrial contains information specific to an instance of a User's trial (expiration date, for example). What would be the proper way ...

how to implement a decorator in PHP?

Suppose there is a class called "Class_A", it has a member function called "func". I want the "func" to do some extra work by wrapping Class_A in a decorator class. $worker = new Decorator(new Original()); Can someone give an example? I've never used OO with PHP. ======================================================= Thank you g...

Managing inter-object relationships

How do you code special cases for objects? For example, let's say I'm coding an rpg - there are N = 5 classes. There are N^2 relationships in a matrix that would determine if character A could attack (or use ability M on) character B (ignoring other factors for now). How would I code this up in OOP without putting special cases all ov...

Business rules - where do they go in OOP?

I have a class : Schedule. public class Schedule { private int locationNum; private int cost; private String costReason; private Date weekOfChange; private Date dayOfChange; private String changeReason; // and all those getters and setters public Schedule(int locationNum, int cost, String costReason, Date weekOfChange, Date dayOfCh...

Composite Strategy pattern - java - How bad is this code?

This question is kind of continuation to my earlier post: http://stackoverflow.com/questions/944824/visitor-pattern-implementation-in-java-how-does-this-look I got a bit confused while refactoring my code. I am trying to convert my visitor pattern (explained in the prior post) into a composite strategy pattern. I am trying to do somethi...

Declaring a Class as a Member of itself

I was working in the Microsoft.Ink dll recently using C# and was debugging a problem (which is not related to this) I noticed, that when I was debugging it, ink objects had a strokes object, which had an ink object, which had.... etc. This confused me, as I was under the assumption you could not do this (I come from a C++ Background) ...

Design question - java - what is the best way to doing this?

I have a design problem. I have two data objects which are instances of say class A and class B. A and B don't have any behavior - they are java beans with getters and setters. I have a Validation interface and 10 implementations of it defining different Validations. I would like to specify in my properties file which Validation appli...

What are the best practices for database development with Delphi?

How can I use the RAD way productively (reusing code). Any samples, existing libraries, basic crud generators? How can I design the OOP way? Which design patterns to use for connection, abstracting different engines/db access layers (bde-dbexpress-ado), basic CRUD operations. ...

Auto- Property Initialization or Service-Oriented assignments?

If my objects are for the most part simply holding data that will be sent to the View, does it make sense to implement a separate Service class to initialize object, retirve data and make assignments? Instead, shouldnt the object 'know' what it has to do when it is instantiated, and thus make appropriate calls to repository as needed? ...

Enforce static method overloading in child class in C++

I have something like this: class Base { public: static int Lolz() { return 0; } }; class Child : public Base { public: int nothing; }; template <typename T> int Produce() { return T::Lolz(); } and Produce<Base>(); Produce<Child>(); both return 0, which is of course correct, but unwanted. Is there anyw...

Good strategies for reusing "entities" in multiple applications?

Let's say you've got two applications for working with "Customers"... one might be an account management application, the other might be a support / helpdesk application. Both applications use the same Customer entities... by that I mean they both hit the same datasource to manage Customers. At a basic level, a Customer is exactly the ...

MustInherit and Shared Functions

I'm looking at a VB.NET class (that I didn't write) that is declared "MustInherit" (abstract in C#, I believe) that has three methods, all of which are defined as "shared" (static in C#). There are no properties or fields in the class - only the three methods. From an OO perspective, does this make any sense? My thinking is no, becaus...

How do you design your application for different presentation layers?

I am part of a team that is developing a web application using a proprietary mvc framework. This framework behaves a bit like a very poor man's struts! It has a central controller, configuration in properties file, torque like generated database action classes and no form beans. Say you have a user account editing screen, Here is a typ...

Knowing when to model domain relationships and how to handle contextual relationships.

Hi - I am new to Domain Modelling so forgive me for asking a couple of elementary questions. My first question is about knowing when to model domain relationships. I find sometimes I feel like all classes appear to be related in some way to most others and I am unclear about when I should model these relationships directly (by holding a ...

JQuery Widget Events in Object Orientated Javascript

I'm attempting to write a custom widget and I want to use existing UI widgets within the class that I'm writing. The problem is that when an event fires the class method that is invoked seems out of scope from the rest of the class, as any members I attempt to read are undefined. Here is the code: <script type="text/javascript"> MyCla...

How would you structure Zend_Auth & Zend_Acl in Zend Framework to obey having a Thin Controller?

There has been a fair bit of talk/debate lately in the Zend Framework community about thin controllers. Apparently there is a tendency of ZF users to view the Model as nothing more than the gateway to the database. The argument is that Models should be "fat" and do more of the work and Controllers shouldn't be chaining methods and doin...

Difference in deriving from abstract and non abstract class

In OOP, I see a lot of classes which derive from parent classes, but the parent classes are not marked as abstract. When the class IS marked as abstract, what advantage does this provide? Thanks ...