oop

A question of design and object responsibility

Hi. I have a design and object structuring related question. Here is the problem statement: I have a Robot object which is suppose to traverse the ground on its own. It would be provided movement instructions and it must parse accordingly. For example sample input would be: a. RotateRight|Move|RotateLeft|Move|Move|Move Where move is...

How to keep track of OpenGL state across function calls?

Since OpenGL is a state machine, I am constantly glEnable() and glDisable()-ing things in my program. There are a select few calls that I make only at the beginning (such as glClearColor) but most others I flip on and off (like lighting, depending on if I'm rendering a model or 3d text or the gui). How do you keep track of what state th...

Is my PHP code object oriented?

Hi , If I made my PHP code which would connect me to my MySQL database in a separate PHP file and made a require on the necessary pages of my website would the DB Connent PHP file be an Object Orentated item ? ...

How to implement the OO in Javascript using prototype framework?

please give the example to me. I want a class, which is a abstract class name "Person" , and two abstract class named "Male" and "Female", which extends "Person", and two concrete class named "Young man" which extends "Male" and "Young woman" which extends "Female". Also, I need a multiple inherited class which called "Unknown", and it ...

Object Orientation - Where to place this Interface Declaration...

Hi there. I have a few questions for you wise people involving OO design with Interfaces and abstract base classes. Consider the following scenario: I have an abstract bass class "DataObjectBase" and a derived class "UserDataObject." I also have an interface "IDataObject." The interface of course exposes all of the public methods an...

Object oriented analysis and design: can a process be a class?

I understand that there are several questions on OOD; this one is not a duplicate (I hope) because of its specific nature - can a functionality that process data be a class? First, some background. This came up from a discussion my supervisor had with me. I was supposed to write a video loading class. His idea was to have a single Vide...

C : How do you simulate an 'instance' ?

Let's say that I have the following code in C that represents a stack : #define MAX 1000 int arr[MAX]; static int counter = 0; isstackempty() { return counter <= 0; } void push(int n) { if (counter >= MAX) { printf("Stack is full. Couldn't push %d", n); return; } arr[counter++] = n; } int pop(int* n) ...

Avoiding casts when translating public APIs to internal glue code

So, I have this public API that my application exposes, allowing customers to write plug-ins. For the sake of this example, let's say it's a fairly simple key-value pair system, something like: public interface Key { // marker interface, guaranteed unique in some scope } public interface KVPService { Set<Key> getKeys(); Object ge...

Difference between "->" and "::" in PHP MySQLi OOP

Can anyone tell the difference between mysqli->commit and mysqli::commit? The header in this page is mysqli::commit but in examples they use mysqli->commit I'm confused. ...

ASP.NET object caching - how much is too much?

Hey guys, My first time really getting into caching with .NET so wanted to run a couple of scenarios by you. Question 1: Many expensive objects I've got some small objects (simple int/string properties) which are pretty expensive to instantiate. These are user statistic objects which each user may have 1 - 10 of. Is it good or bad p...

Looking for a design pattern

I haven't studied design patterns, but I'm willing to bet that there is one for what I need to do. I'm running a set of different algorithms over a couple of trees. They all implement an interface: public interface DistanceMetric { public double distance(AbstractTree<String> t1, AbstractTree<String> t2); } public class concreteDis...

Custom javascript class and private variable scope issue

I am having some trouble with the classic javascript local variable scope topic, but dealing with a JSON variable. I have looked at other questions here regarding the same thing, but nothing has matched my case exactly, so here goes. I have a class that I have made from javascript that has 3 methods: func1, func2, and func3. I also ha...

Inheritance question - declaring abstract and concrete versions of the same property

Okay, two alternatives, but before I begin, you need to know this: public abstract class GatewayBase { ... } public class Gateway : GatewayBase { ... } Alternative #1 public abstract class ModelBase { public GatewayBase GatewayBase { get; private set; } // property named GatewayBase public ModelBase(GatewayBase gateway) ...

Python - printing out all references to a specific instance

I am investigating garbage collection issues in a Python app. What would be the best readable option to print out all variables referencing a specific instance? ...

Question about some wild javascript syntax and contraints

Hey all, So I know javascript pretty well, but I'm not sure about this one. Tough to explain so I'll just show it: var view = new View(); view.rating = 4.5; Is there anyway to have view.rating be called as a function to manipulate the DOM a bit and set that rating to five? So in View: View.prototype = { rating : function() { ...

lines of a class in Java

I have a class in Java which is written bellow.I want to know does that has normal size or it is big and huge and should be broken into some pieces: import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger...

The limit of OOP Paradigm in really complex system ?

I asked a question previously about Dataset vs Business Objects http://stackoverflow.com/questions/1248470/net-dataset-vs-business-object-why-the-debate-why-not-combine-the-two and I want to generalize the question here: where is the proof that OOP is really suitable for very complex problems ? Let's take a MMO Game Engine for example. ...

How do I work with collections of objects? Or rather, does an object retrieve a collection of similar objects?

Hi. I think I get the OOP paradigm at its basic level but I'm having a hard time conceptualizing the proper way to lookup records in a database. I suspect this is because I don't really get OOP as much as I think I do... The application I'm trying to write is a shopping cart because it has a lot of good candidates for objects. The obje...

OO JQuery and classes

I'm working on a site and using JQuery for essentially the first time. I've mostly used MooTools for previous projects, and I have a few widget classes I've written using the MooTools Class structure. I'd like to port them over to JQuery, but it looks to me like there is nothing similar to the MooTools functionality when it comes to ob...

visitor pattern against conditionals?

I don't seem to find this in usage scenarios for the visitor pattern (or maybe I don't get it). It's also not hierarchical. Let's use an authentication example. A UserAuthenticator authenticates credentials given by a user. It returns a result object. The result object contains the result of the authentication: authentication succeeded,...