oop

What's the most efficient way to interact with a Singleton?

I've been working on my own little framework for a while for my own benefit, constantly going back over the code as I learn new stuff. As you might expect, I have a Registry object that's used by pretty much every other object. At present, the most basic object (AFObject) is set up a little like this absract class AFObject { var...

Implementing Model-View-Controller the right way

Working on a game in Objective-C/Cocoa for OS X, and I finished the prototype as much as it's worth being finished. It's a mess of code, being my first game, but everything works. I've been reading up on the best way to put things together, and MVC seems to make the most sense, but I'm a bit confused. Where does it start? With the cont...

Game positioning OO design

Hi guyz, I'm starting a game project, my first, it'll be like a civilization clone, with a big focus in war. I always worked with C# but for business apps (mostly web apps) so I have a doubt about what would be a good design to build the map positioning system. I would like to each unit know where it's positioned, and to the map to kn...

Zend_Auth: why authenticate object named adapter and not strategy?

$Zend_auth->authenticate($adapter); Why is it called an adapter and not a strategy? ...

When to use static vs instantiated classes

PHP is my first programming language. I can't quite wrap my head around when to use static classes vs instantiated objects. I realize that you can duplicate and clone objects. However in all of my time using php any object or function always ended up as a single return (array, string, int) value or void. I understand concepts in books ...

What means a class name in constructor of other class?

I read some scripts and I cannot understand why they put a class name in a constructor of other class: public function __construct(AclassName $foo){ $this->foo=$foo; } ...

a CSS class for Java

I'm about creating a java class for parsing and storing the content of a simple CSS stylesheet. This class will be used to paint a non-html object using the CSS selectors. My naive approach is to basically use a Map<String,Map<String,Object>> to store this stylesheet. Would it be any (clever) other way for storing this information ? ...

Tips for designing Properties?

Can anyone suggest some guidance for designing and implementing good Properties? I am concerned with aspects such as: Side-effects Mutual Exclusivity Concurrency Symmetry and Reversibility Error Handling/Exceptions Pointers to existing write ups that answer these topics would be great. I am NOT looking for help with WPF Dependency ...

OO PHP direct member acccess

I always thought you should never set/get a member variable directly. E.g. $x = new TestClass(); $x->varA = "test": echo $->varB; I thought you should always use object methods to access member variables. But I've just been looking at __set and __get, which imply it's ok to access members directly. Any thoughts? ...

OOP - Message Passing in C#

What is the example of the OOP concept 'Message Passing' in C# (calling methods/Passing parameters/Firing Events/Handling Events/???) and why is it called message passing? ...

OOD and subject-object confusion

Suppose I have a definition for a door: class Door { public void Lock() { // lock the door } } This appeared to make sense to me, at least for awhile. But now, I'm not so sure. If I had a Person object that wanted to lock a Door, he would call aDoor.Lock(). But in real life, we do not lock doors by telling the d...

Implementing conditional in a fluent interface

I've been trying to implement a fluent interface for a set of rules in my system. What I am trying to accomplish is this TicketRules .RequireValidation() .When(quartType => quartType == QuartType.Before).TotalMilageIs(64) .When(quartType => quartType == QuartType.After).TotalMilageIs(128); However, I have trouble implementing the When...

is this a pattern, a bad idea or something you know how to improve?

Given a class hierarchy like this one: a package tree would it be a good idea to have a class that helps in creating the objects? E.i. a class with methods that correspond to each class that can be created (method equals() returns a CompareCriteria eg). The advantage I see is that it would hide away the complex inheritance structure and ...

method hiding in c# with a valid example .why is it implemented in the framework.? what is the Real world advantage.?

Can anyone explain the actual use of method hiding in C# with a valid example ? If the method is defined using the new keyword in the derived class, then it cannot be overridden. Then it is the same as creating a fresh method (other than the one mentioned in the base class) with a different name. Is there any specific reason to use th...

OOP: retrieve 'fathers' attributes from the 'child' object.

Hi guys, here i am again ;) My problem atm is with nested php classes, i have, for example, a class like this one: class Father{ public $father_id; public $name; public $job; public $sons; public function __construct($id, $name, $job){ $this->father_id = $id; $this->name = $name; $this->job =...

Is it safe to extend classes generated from an XML schema?

Suppose I have this (outrageously) simplified XML schema: <xsd:complexType name="Person"> <xsd:sequence> <xsd:element ref="FirstName"/> <xsd:element ref="FamilyName"/> </xsd:sequence> </xsd:complexType> If I generate a Java class from it I get something like this: public class Person { protected FirstName firstName; p...

jQuery val() Method on a Custom Object

I have an object called ValueBox that I created like this: function ValueBox(params) { ... $.extend(true, this, $('/* some HTML elements */')); ... var $inputBox = $('input[type=text]', this); ... this.val = function(newValue) { if(typeof newValue == "number") { $inputBox.val(newValue); $inputBo...

How to find a mentor/code reviewer for freelancer?

About 6 moths ago I switched to fulltime freelance job. Before that I worked in enterprise environment with highly professional craftsmen :) I'm striving in improving my skills in Object Oriented Design and software architecture. I read lots of books about OOD, T.D.D., patterns(implementation, design, architectural). I like to research...

Is there a way to transfer/translate the code written in Java to other languages?

Theoretically this seems possible to me. So can Any one confirm this to me, if it's possible? and if there is such a software that does this?(like Java to C++ or C#) And in general would it be possible to transfer languages like Java to server-side programing language like PHP? ...

Advanced OOP in PHP5?

I want to know more about OOP in PHP 5.2. Can anybody help me with a link to advanced OOP tutorials in PHP? I know about static, public and private class member attributes, I need more info about basic and advanced OO techniques. I hope somebody can help. :) Thanks a lot to all. ...