oop

How to access function inside PHP OOP

Hi everyone, What do I need to do to call $this->two() from inside my function innerOne? Is that possible with PHP OOP? Here's the error I am recieving: Fatal error: Using $this when not in object context Here's how my code looks: class myClass { function one(){ function innerOne() { // Some code ...

Is this an example for parametric polymorphism?

Hi i am educating myself oop principles. I would like to know if this is a correct example of Cardellis definition of parametric polymorphism. Please enlighten me. The example is in cfml's script based syntax. <cfscript> Parent = createobject("component","webapp.model.Parent").init(); Child = createobject("component","webapp.model.Chil...

is there any way to access all references to given object?

Hello anyone has idea if and how is it possible to destroy / change php object which is referenced in many places? unset obviously destroys only one reference, and sometimes tracing all references manually is not an option. Any ideas? Maybe there is something i am missing in Reflection ? ...

Most efficient way to update attribute of one instance

Hi all - I'm creating an arbitrary number of instances (using for loops and ranges). At some event in the future, I need to change an attribute for only one of the instances. What's the best way to do this? Right now, I'm doing the following: 1) Manage the instances in a list. 2) Iterate through the list to find a key value. 3) Once I ...

First step in OOD?

What is the frst step in OOD? ...

Is there anything bad in declaring nested class inside interface in java?

I have an interface ProductService with method findByCriteria. This method had a long list of nullable parameters, like productName, maxCost, minCost, producer and so on. I refactored this method by introducing Parameter Object. I created class SearchCriteria and now method signature looks like this: findByCriteria (SearchCriteria crit...

How to avoid having very large objects with Domain Driven Design

We are following Domain Driven Design for the implementation of a large website. However by putting the behaviour on the domain objects we are ending up with some very large classes. For example on our WebsiteUser object, we have many many methods - e.g. dealing with passwords, order history, refunds, customer segmentation. All of the...

Undefined Variable in Matlab

The Following is the basic skeleton for my MATLAB program. Each box is a class definition. Scroll down for the error. Note: 1. Each Class has a custom constructor The Error Undefined function or variable 'Troom'. Error in ==> wall>wall.wall at 31 function o = wall(Tr) Error in ==> mainfile at 5 w1 = wall(); Thi...

How can I write classes that don't rely on "global" variables?

When I took my first programming course in university, we were taught that global variables were evil & should be avoided at all cost (since you can quickly develop confusing and unmaintainable code). The following year, we were taught object oriented programming, and how to create modular code using classes. I find that whenever I wor...

How to debug PHP?

Anyone's been trying himself at object oriented programming ? Most probably every developer I guess:D I for one have never studied OO design patterns thoroughly, and trying to put it all together now does prove at times thrilling, and many times frustrating also. Even more so when trying to do it in : PHP! All-in-all, my boss asked me t...

Is Design Pattern only for Object-Oriented design?

I was wondering if all design Patterns are only used in Object-Oriented design? Are there any design patterns used in non Object-Oriented design? Thanks and regards! ...

Bad method names and what it says about code structure.

(Apologies in advance if this is a re-post but I didn't find similar posts) What bad method name patterns have you seen in code and what did it tell you about the code. For instance, I keep seeing: public void preform___X___IfNecessary(...); I believe that this is bad because the operation X has an inversion of conditions. Note tha...

In Python, can an object have another object as an attribute?

In Python, can an object have another object as an attribute? For example, can a class called car have a class called tire as an attribute? ...

Is it poor design to create objects that only execute code during the constructor?

In my design I am using objects that evaluate a data record. The constructor is called with the data record and type of evaluation as parameters and then the constructor calls all of the object's code necessary to evaluate the record. This includes using the type of evaluation to find additional parameter-like data in a text file. There...

Cpp some basic problems

Hello. My task was as follows : Create class Person with char*name and int age. Implement contructor using dynamic allocation of memory for variables, destructor, function init and friend function show. Then transform this class to header and cpp file and implement in other program. Ok so here's my Person class : #include <iostream> usi...

c#: what is the point in having a purely public property

Possible Duplicates: Should I use public properties and private fields or public fields for data? Property(with no extra processing) vs public field What is the point in having a property inside a class that simply get and sets a member variable? What practical difference would be there to just making the variable public? ...

'Static/Constant' business ojects

I don't quite know how to ask this question, so I'll phase it as an example: Imagine in an application you have a Country object. There are two properties of this object: Name, and a 'Bordering Countries' collection. More properties might be added later, but it will be the kind of information that would change very rarely (e.g. change...

Property and Encapsulation

Hi Team, Following is a question regarding using Properties in class. I am software engineer with 3 years of experience. I have been using public properties instead of exposing member variables publically. Many a people told that this approach helps in encapsulation. I don’t realize any encapsulation advantage by making it a property. ...

rails model using class hierarchy from an external gem ?

Hello, I'm working on a project where the data model is : implemented in a separate gem does not use ActiveRecord, nor any relational database storage ( actually it relies on couchdb ) makes usage of namespaces makes intensive usage of class inheritance To simplify the schema, let's say we have the following root class : module ...

PHP: Singleton vs Static Class

Possible Duplicate: Difference between static class and singleton pattern? Hello, Just wanted to know what exactly is the difference between a singleton and static class? Thanks for your time ...