oop

PHP get_called_class() alternative

I've got an Abstract PHP superclass, which contains code that needs to know which subclass its running under. class Foo { static function _get_class_name() { return get_called_class(); //works in PHP 5.3.*, but not in PHP 5.2.* } static function other_code() { //needs to know echo self::_get_...

Why is C++ not an Object Oriented language?

I have always heard that C++ is not Object Oriented but rather "C with Classes". So, when I mentioned to an interviewer that C++ was not really object oriented, he asked me why I didn't consider it an OO language. I haven't done any C++ since University, and I didn't have much of an answer. Is C++ Object Oriented or not? and why? ...

Does the self-shunt testing pattern violate the Single Responsibility Principle?

I've used the self-shunt unit testing pattern a few times over the years. As I was explaining it to someone recently they argued that it violated the SRP. The argument is that the test class can now be changed for one of two reasons: when the test changes, or when the method signature on the interface that the test is implementing change...

In what cases should public fields be used instead of properties?

Possible Duplicate: Public Data members vs Getters, Setters In what cases should public fields be used, instead of properties or getter and setter methods (where there is no support for properties)? Where exactly is their use recommended, and why, or, if it is not, why are they still allowed as a language feature? After all, t...

Does passing values by reference improve speed significantly?

Possible Duplicates: Pass by value vs Pass by reference performance C#.net Which is faster? ByVal or ByRef? Did anyone already test if passing parameters by reference is significantly faster than just copying them? But the main focus of the question is: Are there any disadvantages using the ref keyword as opposite to not us...

The object oriented relationship...

Hi guys. I was asked to describe the relationship between vehicle, car, toyota in object oriented programming term (let's say in php environment). I was stumped. Can someone help me about it? Thanks... ...

How do you educate your teammates without seeming condescending or superior?

I work with three other guys; I'll call them Adam, Brian, and Chris. Adam and Brian are bright guys. Give them a problem; they will figure out a way to solve it. When it comes to OOP, though, they know very little about it and aren't particularly interested in learning. Pure procedural code is their MO. Chris, on the other hand, is an ...

The core of object oriented programming

Hi guys, I am trying to understand the core of object oriented programming for php or actionscript proect. As far as I understand, we will have a Main class that control different elements of the project. For example, photoslider class, music control class..etc. I created instance of those classes inside my Main class and use their meth...

workaround for multiple inheritences in PHP?

In a lot of my PHP classes, I have this code: private $strError = ""; private $intErrorCode = NULL; private $blnError = FALSE; public function isError() { return $this->blnError; } public function getErrorCode() { return $this->intErrorCode; } private function setError( $strError, $intErrorCode = NULL ) { $this->blnError...

arguments for breaking (bad) code conventions

The current code base that i am working on is "legacy" ( not in the age but the way things are a laid out ) , although codebase is fairly new it follows outdated conventions like creating an interface for every concrete (service)class, fat services and thin models, procedural blobs of code . What are some arguments for breaking (bad) c...

Decoupling - OOP

Hi, I have a simple question (working with Java). I have two classes, one represents a Document, a second represents a Word. The Document class needs to know some info about the words that is kept in Word. My question is, what's the best way to decouple the two classes? I have 2 options in mind: Have no connection between the classes...

When I derive a class in C++, does it create an object of base class and store it as my member variable in derived class?

Say i create a derived class as below, class CHIProjectData : public QObject { CHIProjectData(QMap<QString,QString> aProjectData, CHIMetaData* apMetaData = 0, QObject* parent = 0); private: QMap<QString,QString> m_strProjectData; CHIAkmMetaData* m_p...

imports and extends

can any one explain " While we are importing a package we can use its all public functions, Then what is the use of extending a class ?" " I m studying OOP Langusges for 3 years and i didnt get ans to this question " ...

Creating a basic class in asp.net

I am new to the .Net world, and was wanting to create a class so I can learn OOP. I have a .sln file, with multiple projects in that file. I want to create a class that will accept 3 parameters, a "stored proc name", "UserID" and "PageName". The stored proc will log the id of the person who launches a particular page, the page name an...

Data Access Layer as a web service -- Is this a good idea?

I have been researching for a while and have actually created a prototype ASP.NET web service as a DAL for a few ASP.NET 2.0 web sites. Just would like to ask for some insight/advice from more experienced developers out there who had successfully rolled out DAL as a web service. What are the drawbacks/risks to deploying DAL as a web serv...

Visibility of object constants

I found out that object constants in PHP always have public visibility so it is not possible to set them to protected or private like this: <?php class MyClass { protected const constant = "this won't work"; } ?> What's the explanation for this? I can't think of a good reason to force constants to be public. ...

How to pass value (array or arraylist) from 1 pane to another pane?

This is my main class code: public static void main(String[] args) { JFrame f= new JFrame ("My Frame"); f.setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE); JTabbedPane tp = new JTabbedPane(); tp.addTab("Pane1", new PaneFirst()); tp.addTab("Pane2", new PaneSecond()); f.add(tp); f.pack(); f.setVisible(true); } In PaneFirst, ...

Why YUI.lang.extend implements Inheritance this way?

I'm reading YUI2.8.1 source code yahoo/yahoo.js. The YAHOO.lang.extend method is implemented this way http://github.com/yui/yui2/blob/master/build/yahoo/yahoo.js I don't understand why it creates another F function. IMHO, below code should also work(ignoring overrides part) function extend (subc, superc ) { if (!superc||!subc) { ...

Magento custom admin module is blank

I've create a custom admin module but i can't put a content in it, it always is blank i'm trying with a simple code for test, but nothing seem to work public function indexAction() { $this->loadLayout(); $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHt...

C++: overriding pure virtual member variable?

This question is best described in code. I have a class called Vertex that contains an instance of a class called Params: class Params { virtual Params operator + (Params const& p) = 0; }; class Vertex { public: Params operator + (Params const& ap) const { return p + ap }; virtual float eva...