oop

How do functional programming languages work?

I was just reading this excellent post, and got some better understanding of what exactly object oriented programming is, how Java implements it in one extreme manner, and how functional programming languages are a contrast. What I was thinking is this: if functional programming languages cannot save any state, how do they do s...

design the interface

I want to design an interface has the function to do mapping from Entity object to Form object public interface IFormToEntityMapper { TEntity Map(TForm tForm); } and vice versa. public interface IEntityToFormMapper { TForm Map(TEntity tEntity); } I have the question if I should define these two functions ...

Better to use constructor or method factory pattern?

I have a wrapper class for the Bitmap class called BitmapZone. Assuming we have a WIDTH x HEIGHT bitmap picture, this wrapper class should serve the purpose of allowing me to send to other methods/classes itself instead of the original bitmap. I can then better control what the user is or not allowed to do with the picture (and I don't ...

Does it ever make sense to call [init] outside of [[alloc] init]?

I am wondering if [[alloc] init] is just a convention or if separating the two calls has wider use. For instance, I wonder if people ever call [init] (or friends) on an existing object to "re-initialize" it. ...

How to properly name classes inside a domain namespace?

Let's say I'm trying to implement a Chess Game. I'd create my Chess classes in a Chess namespace. Now, should I prefix all my Chess related classes with the Chess word, or as they are already inside that namespace, should I just call them by what they are? Example: ChessGame vs Game ChessPiece vs Piece ...

Does Javascript have classes?

A friend and I had an argument last week. He stated there were no such things as classes in Javascript. I said there was as you can say var object = new Object() he says "as there is no word class used. Its not a class. -- Whats your take on it guys? thanks. ...

Updating multiple Sprites - AS3 performance best practices

Within the container "BubbleContainer" I have multiple "Bubble sprites". Each bubble's graphics object (a circle) is updated on a timer event. Let's say I have 50 Bubble sprites and each circle's radius should be updated with a mathematical formula. How do I organize this logic? How do I update all Bubble sprites within the BubbleCont...

a good resource or book for architecting object-oriented software

I have looked at a couple of books and all I have looked at were just discussing the technicalities of OOP. By technicalities I mean, here's a concept, here's some code, now get working. I have yet to see a book that discusses the architectural process, what are the ways of doing this, why doing this is bad, how to actually incorporate d...

Singletons and constants

I am making a program which makes use of a couple of constants. At first, each time I needed to use a constant, I'd define it as //C# private static readonly int MyConstant = xxx; //Java private static final int MyConstant = xxx; in the class where I'd need it. After some time, I started to realise that some constants would be needed...

php require class call from inside method

from my understanding, require pastes code into the calling php file. what if you were requiring from inside a method...it would paste the entire code/class inside the method, blocking the next statement in the method. eg. function test() { require 'pathtosomeclasscode'; somestatement; // any code after the require is block...

PHP string to object name.

Ok I have a string... $a_string = "Product"; and I want to use this string in a call to a object like this: $this->$a_string->some_function(); How the dickens do I dynamically call that object? (don't think Im on php 5 mind) ...

How do I dynamically instantiate a class in javascript?

I'm starting out with classes in Javascript and have hit a wall. I've looked all over for a tutorial that goes a little further than simply how to construct a class (usually Animal) then extend the class and have a Method do something (Dog alert('Bark');). I have created a class that I want a user to be able to instantiate (is that the ...

define constant in php

how do I define a constant inside a function eg. class { public test; function tester{ const test = "abc"; } } ...

Transfer data between C++ classes efficiently

Hi, Need help... I have 3 classes, Manager which holds 2 pointers. One to class A another to class B . A does not know about B and vise versa. A does some calculations and at the end it puts 3 floats into the clipboard. Next, B pulls from clipboard the 3 floats, and does it's own calculations. This loop is managed by the Manager and r...

Do PHP interfaces have properties?

Do interfaces have properties or only methods? Thanks ...

Which book should I choose?

Hi guys, I'm looking for a good read on object oriented design. The two books I'm currently looking Head First Design Patterns and Head First Object object-oriented analysis & design. They seem very similar when looking at the contents and browsing through available sample text. Which one would be the best choice? About myself: I have ...

Imitating Multiple Inheritance in PHP

I am working on my own MVC framework and found myself stuck. I need the following construction: Controller --> Backend_Controller --> Backend_Crud_Controller --> Frontend_Controller --> Frontend_Crud_Controller Both 'Backend_Crud_Controller' and 'Frontend_Crud_Controller' have the same functionali...

android mobile development performance vs extensibility

im developing a game in android, and i've been thinking about subdividing many of the elements of the game (e.g. game objects) into separate classes and sub-classes. but i know that method calls to these objects will cause some overhead. would it be better to improve performance or to improve extensibility? ...

How can I make a family of singletons?

I want to create a set of classes that share a lot of common behavior. Of course in OOP when you think that you automatically think "abstract class with subclasses". But among the things I want these classes to do is to each have a static list of instances of the class. The list should function as sort of a singleton within the class. I ...

Writing fortran robust and "modern" code

In some scientific environments, you often cannot go without FORTRAN as most of the developers only know that idiom, and there is lot of legacy code and related experience. And frankly, there are not many other cross-platform options for high performance programming ( C++ would do the task, but the syntax, zero-starting arrays, and point...