starting use oop
why:
class user
{
private $pdo;
function __construct()
{
$this->pdo = singleton::get_instance()->PDO_connection();
}
...
}
this works fine. but this:
class user
{
private $pdo = singleton::get_instance()->PDO_connection();
...
}
this does not working. Error parse error, expecting...
function SuperClass()
{
var self = this;
self.someVariable = true;
}
function SubClass()
{
var self = this;
self.name = "Sub";
}
SubClass.prototype = SuperClass;
var sub = new SubClass();
alert("This is a sub class with name " + sub.name + " and variable " + sub.someVariable);
</script>
</head>
<body>
</bod...
Im new to PHP Object Oriented Programming but I know to code in procedural way.
If this is my PHP Class
<?php
class person {
var $name;
function __construct($persons_name) {
$this->name = $persons_name;
}
function get_name() {
return $this->name;
}
}
?>
and if I access it in my PHP page
$jane = new person("Jane Do...
I have a class that represents a basic page with "go back", "go forward", and "canel" buttons in Wicket. But not all pages have all the buttons, e. g. the first page doesn't have "go back" obviously.
My idea is to define a generic ActionHandler
public interface ActionHandler {
void perform();
}
and let subclasses return the actions...
Hi!
Sorry if this question is very very basic.
I need to cast, in the better way, 2 objects of 2 types of 2 custom-classes (in VB.Net):
The code:
Public Class pluto
Public Sub New(ByVal campoPippoPass As String)
_campoPippo = campoPippoPass
End Sub
Private _campoPippo As String = ""
Public Property campoPippo...
I apologise for the unclear title, I cannot think of any better one. I'm getting this error:
Fatal error: Call to a member function query() on a non-object
This is caused by the constructor in a class SPConfig, which can be seen together with a class SPClasses as follows:
$sp = new SPClasses();
class SPClasses
{
public $db, $...
Hello everybody!
Is there any heuristics for finding class invariants, I mean
pay attantion on ...;
never rely on ...;
Maybe there is common advices.
Any links on paper where studing real-life examples will be welcome.
...
Hi All,
I have added this thread in order to get good hands in OOPs.
I want to get depth knowledge in OOPS. Please share your knowledge and also give references for the same..
Lets starts to explore OOPs Concepts.
...
In my abstract class (C# 3) I'm using a virtual method named GetData() which returns a DataTable. The algorithm of the method is as following:
Get SQL query string from the class.
Get DataTable from database using above query.
Do transformations on DataTable and return it.
In the 3rd point, I clone the original DataTable in order to ...
When a class is compiled in c# do the functions get stored with it, thus increasing the memory required?
In other words is it worth creating two classes 1 to store the data and one to store all the functions with an instance of the data class?
So if I have 200 instances of the data only class would it differ (memory required) from 200 ...
Suppose I have a C++ application for a pet store that started out just with Cats. The app has a class that does some data handling for a Cat dialog box:
CatDlg.cpp:
CatDlg::CatDlg() {//ctor stuff}
CatDlg::onInitDialog() {
DBAccess db;
db.open();
CatRec cat;
cat = db.findRec(m_catID);
CString name = cat.getName();
Na...
I've got few variables I really want to hide because they do not belong outside my class. Also all such non-documented variables render inheritance useless.
How do you hide such variables you don't want to show outside your object?
To clarify why I need private variables, first one example where inability to hide variables is just an i...
So we have a PHP+Zend Framework+Doctrine 1.2 application that has the following structure:
Controller -> Action -> Service -> Model
Not all models are interacted with through a service. Our current opinion is that a controller could use a model directly and a service could possibly use other services.
My question is: If you have a pi...
I've got a protocol:
@protocol Gadget <NSObject>
@property (readonly) UIView *view;
- (void) attachViewToParent:(UIView *)parentView;
@end
And an "abstract" base class, with an implementation (as a getter, not shown) of -(UIView *)view:
// Base functionality
@interface AbstractGadget : NSObject {
UIView *view;
}
@property (re...
I want to populate class with constructor using FETCH_INTO of PDO:
class user
{
private $db;
private $name;
function __construct($id)
{
$this->db = ...;
$q = $this->db->prepare("SELECT name FROM users WHERE id = ?");
$q->setFetchMode(PDO::FETCH_INTO, $this);
$q->execute(array($id));
...
I guess I'll try to explain my question through 2 code snippets:
// snippet 1
class FooBar
{
private int value;
public int DetermineSomeResult()
{
PerformSomeCalculationOnValue();
PerformSomeMoreStuffOnValue();
return value;
}
public int GetCachedValue()
{
return value;
}
}
The fir...
Hello
I design an objected oriented application using C# with database back end, for some time I was building same application using procedural way in which I feel storing data to database is little bit easier using simple SQL statement.
I my application I want to store the objects attribute to database, for example for an item object
...
Can someone tell me why I am getting
undefined method print_hash() error?
I have the following class
class EmailManager{
private $replytoArray;
private $receiverArray;
private $fromArray;
function __construct(){
$replytoArray = array();
$receiverArray = array();
$fromArray = array();
}
function addReceiver($k){
if(!i...
Is there any problem with declaring a class with a static member which is another class in a header. E.g:
class Stat
{
public:
int avar;
Stat();
};
class Test
{
public:
static Stat stat;
};
The reason I fear it might cause problems is that it seems very similar to declaring a global variable in a header. If included in tw...
I have a question about OOP in PHP5. I have seen more and more code written like this:
$object->function()->first(array('str','str','str'))->second(array(1,2,3,4,5));
But I don't know how to create this method. I hope somebody can help me here, :0) thanks a lot.
...