oop

Objective C for beginners

I was just asked to talk about Objective C to a bunch of High School student for 20 minutes. They have no experience with programming at all. What topics should I cover? Should I define vocab such as Method, Class, Variable? Or should I do something else? Any comments are helpful! ...

Clean design and implementation for data import library

I have been given the task of developing a small library (using C# 3.0 and .NET 3.5) to provide data import functionality for an application. The spec is: Data can be imported from CSV file (potentially other file formats in the future) The CSV files can contain any schema and number of rows, with a maximum file size of 10MB. It must...

Mapping C# object orientation with BioInformatics

I am teaching C# for Bioinformatics students. Just I started OOP Principles. I have to explain the terms again and again because they feel bore while I use technical term. Finally I decided to communicate them in their language (I mean giving example from Biological related term). For me it is hard to coin the term class, object, ev...

Looking for some OOAD advice for Reporting

I have the need to create an arbitrary amount of reports in many different file formats. Most of the formats I am able to use Smarty to template the output. However, outputting to Excel and PDF complicate things and require the use of FPDF or TCPDF and PHPExcel. I am trying to figure out the best way to organize my classes via one or ...

What is the most elegant and efficient way to model a game object hierarchy? (design bothers)

I've got the following code, think simple shooter in c++: // world.hpp //---------- class Enemy; class Bullet; class Player; struct World { // has-a collision map // has-a list of Enemies // has-a list of Bullets // has-a pointer to a player }; // object.hpp //----------- #include "world.hpp" struct Object { virtual ~Object...

How can I initiate a PHP class and use it in several files?

I am stumped right now. In my last post about this question the answer was to use a singleton to make sure an object is only initiated 1 time but I am having the opposite problem. If I have a file called index.php and then I include these files into it, class1.php, class2.php, class3.php, class4.php. In index.php I will have, <?PH...

singleton inside of a construct method in PHP?

Is it ok to use a singleton method inside of a __constructor to initiate the class if it wasn't already? ...

Non-blocking HTTP requests in object-oriented PHP?

I have a PHP client application that is interfacing with a RESTful server. Each PHP Goat instance on the client needs to initialize itself based on information in a /goat request on the server (e.g. /goat/35, /goat/36, etc.). It does this by sending an HTTP request to its corresponding URL via cURL. Working with 30+ goat objects per page...

Can I declare something global at the class level in PHP?

Is there a way to set something as global in a class and have all methods of that class to have access to it? Currently if I use global $session; I have to add it into every method that uses it even if all the methods are in the same class. If I try to add it directly into the class then I get a php error saying it is expecting a funct...

How to change the controller class name in Zend Framework

For example, we have index controller: class IndexController{ ... How to make e.g. class Index_Controller{ ... work? ...

Particle System Design ?

Hello, I'm designing my own particle System engine, this is for learning purposes, I don't really want to use an existing engine. Right now I generated beautiful particles, but I want to layout the engine to make it easier to work with them. I have been thinking on a Class "Particle System", that class would contain the following refe...

Am I Using A Factory To Promote Polymorphism?

Hello! My first question is basically asking for a code-review. Does the code I'm about to provide use a Factory to promote Polymorphism? Its written in PHP. Here are the basic requirements: Pass a long url to a library and return a shortened url. Along with the long url, pass user properties to attempt to locate the users specifi...

Software Design is Trial and Error Approach, how true is this statement?

Dear Stackoverflow Readers, Please comment your votes on how true is following statement: "Software Design is Trial and Error Approach" Regards, Rachel ...

How to design this using OOP

I have an object called User, with properties like Username, Age, Password email etc. I initialize this object in my ado.net code like: private User LoadUser(SqlDataReader reader) { User user = new User(); user.ID = (int)reader["userID"]; // etc } Now say I create a new object that inherits from User, like: public...

C# How to split the following large complex class.

I've managed to program the following THWorkingMemory class, into a antipattern, the God Object. I planned it to be a fairly small class with around 20 methods, but now it's packed with queue handlers, timers, threads, callbacks, powershell queue callbacks, event handlers, lock handlers and about 50+ methods, i.e. the lot. The class has...

Coding classes with the same behaviour + unique behaviour

I have a set of classes which have similarities and differences. They derive from an interface, which defines the unique behaviour amongst these different classes, and a base class to call the common functionality in the several classes. Is there a design pattern which governs how these sort of classes are created? Is it acceptable to u...

How to initialize an array in a class constructor?

Working in Xcode on Mac OS X Leopard in C++: I have the following code: class Foo{ private: string bars[]; public: Foo(string initial_bars[]){ bars = initial_bars; } } It does not compile and throws the following error: error: incompatible types in assignment of 'std::string*' to 'std::string [0u]' I notice t...

How to plan a project...

I am about to embark on a project mostly using C# that will involve client and server communication. I'm wondering how to plan out a project like this. I usually just jump into smaller projects and figure things out as I go because I have a diagram in my head. How do I design a complex project before knowing everything it will require...

Better to use an Object or a Static Function in PHP?

I am trying to learn OO and classes and all that good stuff in PHP, I am finally learning the sytax good enough to use it some and I am curious if there is any benefit of starting a new object instead of just using static methods...let me show some code for what I mean... <?PHP test class { public function cool() { re...

How To create a UML diagram for Source Code Files?

I have one scenario That our program output will generate two source code files as ABC.c (1 code file) ABC.h (1 header file) these two files will be added to many other external programs and exe of those programs will be created Now my issue is for drawing a deployment diagram for those source code files, how can i display this sce...