I have an object of which I am looking to get a piece of data from, the object looks like this,
Product Object
(
[name] => Simon Test Cup
[code] => 123456789
[category_id] => 3
[range_id] => 26
[price] => 10.00
[price_logo_add] => 0.25
[image_id] => 846
[rank] =>
[special_offer] => N
[cartPr...
I've got a class Widgets. Widgets are made up of Doohickies. I'm never going to need to access Doohickies directly via url -- they're essentially a private class, only used by Widgets. Where do you put your code to define the Doohicky class? In /app/controllers/doohicky.php? in app/controllers/widget.php? somewhere else? Obviously, the f...
Let's say I have a Java class
abstract class Base {
abstract void init();
...
}
and I know every derived class will have to call init() after it's constructed. I could, of course, simply call it in the derived classes' constructors:
class Derived1 extends Base {
Derived1() {
...
init();
}
}
class Deri...
I've got some real nay-sayers on my hands here, and I'm trying to give them the reason why OOP was developed in the first place. I realize that OOP is not perfect for all problems and situations, but it was developed for a reason...
My guess would be, that a few of those reasons would be:
Maintainability
Re-usability
Document-ability...
Recently i saw the following code that creates a class in javascript:
var Model.Foo = function(){
// private stuff
var a, b;
// public properties
this.attr1 = '';
this.attr2 = '';
if(typeof Model.Foo._init === 'undefined'){
Model.Foo.prototype = {
func1 : function(){ //...},
func2 : function(){ //... },
...
I'm writing a set of collection classes for different types of Trees. I'm doing this as a learning exercise and I'm also hoping it turns out to be something useful. I really want to do this the right way and so I've been reading Effective Java and I've also been looking at the way Joshua Bloch implemented the collection classes by lookin...
I have some code that looks like:
class Parent {
private Intermediate intermediateContainer;
public Intermediate getIntermediate();
}
class Intermediate {
private Child child;
public Child getChild() {...}
public void intermediateOp();
}
class Child {
public void something();
public void somethingElse();
}
class Client {
priv...
I have a class called "Layout" for the layout of the page, another class called "User" for the user.
Every page I create, I instantiate a new Layout.
When a user logs in, there is a new User instantiated.
How do I get an instance of the layout class to know about the instantiated user? I could also save the entire instance of the Use...
I have a method in a Pygame Sprite subclass, defined as such:
def walk(self):
"""move across screen"""
displacement = self.rect.move((self.move, 0))
if self.rect.left < self.area.left or self.rect.right > self.area.right:
self.move = -self.move
displacement = self.rect.move((self.move, 0))
self.rect = dis...
What does
$shipping_modules = new
shipping($shipping);
mean?
I know its silly but pls help...
...
What is the best practice for calling members/fields from a private method and public method? Should the private method always call private fields or should they call the public members?
private string _name;
public string Name
{
get {return _name; }
set { _name = value; }
}
public void DoSomething()
{
_doSomething();
}
pri...
I'm starting on my first business project (.NET) and am trying to follow DDD principles. Are there any guidelines or common patterns for orgaining source code and namespaces?
For example, do your domain objects go in a namespace MyProject.Domain or whatever? Would you separate the concrete implementations and the interfaces? In differen...
Hi,
i am trouble with this..
Is there some solution or i have to keep exactly class types?
//header file
Class Car {
public:
Car();
virtual ~Car();
};
class Bmw:Car {
public:
Bmw();
virtual ~Bmw();
};
void Start(Car& mycar) {};
//cpp file
Car::Car(){}
Car::~Car() {}
Bmw::Bmw()
:Car::Car(){}
Bmw::~Bmw() {}
int...
I'm obviously brand new to these concepts. I just don't understand why you would limit access to properties or methods. It seems that you would just write the code according to intended results. Why would you create a private method instead of simply not calling that method? Is it for iterative object creation (if I'm stating that correc...
I'm trying to extend Object functionality this way:
Object.prototype.get_type = function() {
if(this.constructor) {
var r = /\W*function\s+([\w\$]+)\(/;
var match = r.exec(this.constructor.toString());
return match ? match[1].toLowerCase() : undefined;
}
else {
return typeof this;
}
}
It'...
In C++, what's the benefit of having a class with functions...
say
class someClass{
public:
void someFunc(int arg1);
};
then having the function's actual functionality declared after int main
int main()
{ return 0; }
void someClass::someFunc(int arg1)
{ cout<<arg1; }
Furthermore, what's the benefit of declaring the...
I'm having something of a dilemma and would appreciate some input.
I have this class, let's call it "Car" where each instance has some individual settings (through properties), like "Color", "HasGearShift" or whatnot (I'm making this up for a simple example). These should be user customizable but there should also be default values.
So...
Hi all,
I have an OOP-related question. I have an interface, say:
class MyInterface {
public int getValue();
}
In my project, this interface is implemented by 7 implementations:
class MyImplementation1 implements MyInterface { ... }
...
class MyImplementation7 implements MyInterface { ... }
These implementations are used by se...
Is there anyway to store users data such as userid, email, etc to be accessible from all pages of a website after they have logged in, but without using sessions or cookies?
For example:
class User
{
var $userid;
var $username;
var $email;
.. methods..
}
after they login at login.php
$currentUser = new User($_POST['username...
in object oriented php mysqli
I am trying to request a username, and return if it matches a row, without actually returning any user data.
How would I write this?...so far I have...
$sql = "SELECT NULL FROM database WHERE usernick=?";
$stmt = $link->prepare($sql)
$stmt->bind_param('s', $snr);
$stmt->execute();
After this step I need...