oop

building a factory with object repository in C++?

I want to create a factory for creation of objects implementing an abstract interface, which would return a reference to the object that is kept internally, and objects are not replicated. The idea is pretty much the same as in the log4cxx/log4j Logger class design. I would also like to hide as much details from the client as possible, i...

Providing .Net Training to recruitment team

In our organization responsibility is given to me to teach .net to our recruitment team (non technical), i need to design the entire training session. They want a training so they can filter out some of the candidates at their level. Please give me suggestion that what i should teach them in my training ? ...

How can I represent implementation of a pattern in a UML class diagram?

In UML, how can I represent that a class implements some design pattern or follows some convention? For example, in Java, that a class follows the JavaBean convention? ...

AS3 Object Oriented GUI Design

I'm trying to make a small Flash game that has a GUI, which is basically a menu where players can select certain items, sort of like the Tower Defense games. Would it be a good idea to make the GUI a singleton? Because obviously there can only be 1 instance of the GUI class. Is there a better way? ...

What is the difference between -> and :: in PHP?

Hi, This thing has been bugging me for long and I can't find it anywhere! What is the difference when using classes in php between :: and -> Let me give an example. Imagine a class named MyClass and in this class there is a function myFunction What is the difference between using: MyClass myclass = new MyClass myclass::myFunction()...

Better use of methods or properties, whats different?

Hi I'm pretty new in OOP but have to develop a big project... Just for imagination, below 2 examples which returns same. Which one is (more) correct, hmm or cleaner? The Property or the method? In real I have to return complex datasets from joined tables... I avoid copy the complet query which returns the dataset. Thats why it's just ...

What is Method Dispatch?

What is Method Dispatch? I can find several concrete examples, but an abstract definition of method dispatch eludes me. Anyone care to venture theirs? ...

Is it ever justified to write a fairly large, database-centric PHP app procedurally and without MVC?

Sorry for the rather subjective question, but I was hoping to get an opinion from someone more experienced than myself on this. I'm pretty far into an ajax-driven PHP application and, while I have pretty good separation between markup and behavior on the client side, my PHP is slowly becoming a bit of a mess. I'm doing alright so far b...

Class Design Problem

Hi, I am writing the following program and I am thinking of a good design for it in C++ Problem: I am writing a graph library. There is Graph<E> class. Different graph algorithms have different types of information stored on the edges (Potentials, Cost, color, flow values, capacities etc.) For each algorithm, there is a different Edg...

Photoshop style GUI design

In a tool such as Photoshop, there is a selection of tools you can click on (e.g. pen, brush etc). Once you click on a tool, you can use that tool to paint, erase etc depending on what tool is selected. I'm wondering how that would be best implemented in an OO design. I could only think of having a GUIManager that always knows which too...

Multithreaded Java server: allowing one thread to access another one

Hopefully the code itself explains the issue here: class Server { public void main() { // ... ServerSocket serverSocket = new ServerSocket(PORT); while (true) { Socket socket = serverSocket.accept(); Thread thread = new Thread(new Session(socket)); thread.start(); } // .. } public...

Is it good practice to use a Dynamic Array in an object field ?

I am refactoring some existing Delphi code into a class. The current code uses a global variable defined as a dynamic array array of byte. At initialization time the code figures out the size of the array and uses SetLength to allocate it. It is convenient both as the buffer to obtain the data and as the runtime container for a later p...

OO Javascript constructor pattern: neo-classical vs prototypal

I watched a talk by Douglas Crockford on the good parts in Javascript and my eyes were opened. At one point he said, something like, "Javascript is the only language where good programmers believe they can use it effectively, without learning it." Then I realized, I am that guy. In that talk, he made some statements that for me, were...

How to structure a Genetic Algorithm class hierarchy?

I'm doing some work with Genetic Algorithms and want to write my own GA classes. Since a GA can have different ways of doing selection, mutation, cross-over, generating an initial population, calculating fitness, and terminating the algorithm, I need a way to plug in different combinations of these. My initial approach was to have an abs...

OO Javascript: good way to combine prototypal inheritance with private vars?

In OO Javascript constructor pattern: neo-classical vs prototypal, I learned that constructors using prototypal inheritance can be 10x faster (or more) than constructors using the so-called neo-classical pattern with closures as proposed by Crockford in his "Good Parts" book and presentations. For that reason it seems like preferring p...

Call a method on a class or pass as a parameter to another class? C#

Suppose I am logging some data with a 'Job' class. (A list of business objects, with various properties, for what it's worth.) I wish to be able to print this data, so I am wondering if there is a more preferred design for doing this. I have two ideas at the moment - calling a Print() method on the Job itself, or passing a Job instance ...

In a PHP project, how do you store, access and organize your helper objects?

How do you organize and manage your helper objects like the database engine, user notification, error handling and so on in a PHP based, object oriented project? Say I have a large PHP CMS. The CMS is organized in various classes. A few examples: the database object user management an API to create/modify/delete items a messaging obje...

Overriding AnalogClock in Android

Hi all, I want to create an AnalogClock that can display a preset time, given as a parameter. And I want to draw between the background and the hands. I want to paint the area between the minute-hand and location of the hour-hand at a preset future time. This is to let the user see how much time remains for the current activity. I tho...

help with c# pattern.

Hello and thanks for any assistance. using .Net 3.5 C#; Say i have about 10 methods that all follow the same pattern Using 3 as an example: public Customer CreateCustomer(Customer c) { .. } public Car CreateCar(Car c) { .. } public Planet CreatePlanet(Planet p) { ..} the internal logic of each method has the exact same pattern. ...

Making a Python script Object-Oriented

I'm writing an application in Python that is going to have a lot of different functions, so logically I thought it would be best to split up my script into different modules. Currently my script reads in a text file that contains code which has been converted into tokens and spellings. The script then reconstructs the code into a string,...