I'm trying to understand inheritance in Javascript, but this code (tested in Firebug) doesn't work the way I'm expecting. What am I not understanding about it?
var A = function(v){
this.v = v || 'foo';
}
A.prototype.shout = function(){ alert(this.v); }
var B = function(){};
B.prototype = new A;
var test = new B('bar')
test.shout()...
Hello, everybody.
I'm developing a little application in ASP.NET MVC.
This app has a lot of "HTML pieces" that are used many times with a little variance.
For this pieces, I'm using strongly-typed partial views.
My question is: This is the right way to reuse code in View layer? Is there some inconviniece to use partials views?
Thank...
I was wondering how much memory does an object that inherits from "object" and has no fields/properties take ? And I guess methods don't. Right ? I am talking for .net objects.
...
I am designing an OO object model with a plan to use NHibernate as the data access layer.
I'd like to know the best OO design when dealing with two entities that have a many to many relationship with each other (especially for easy integration with NHibernate).
The objects:
User - a single User can be related to multiple Subjects
Subje...
Hierachical Data from SQL
Adjacency List Model
In my model I have a series of objects, each stored with their parent id. I am using the Adjacency list model as my hierachy method.
All examples of Adjacency list simply output there and then. None try to create a multi dimensional array from the result set.
---------------
| id | paren...
I've heard some voices saying that checking for a returned null value from methods is bad design. I would like to hear some reasons for this.
pseudocode:
variable x = object.method()
if (x is null) do something
...
Hi,
I have a problem, I wish to use reflection to generate instances of one of a set of classes at runtime. However, I have hit a snag. I want to get all of the classes involved to register themselves so the appropriate class can be chosen from a GUI. I can do this using a static code block in each file which provides a tidy OO solution...
Hi all,
Can anyone tell me how to implement OOP efficiently in PHP?
Thanks
Fero
...
I know the rule of thumb is that a noun used by the user is potentially a class. Similarly, a verb may be made into an action class e.g. predicate
Given a description from the user, how do you -
identify what is not not to be made into a class
...
I was confused when I first read Christer Fahlgren's comment on an answer on this question, where he states you would benifit from using 'MVC style design' when starting an application that uses both Delphi and a WebBrowser component on a form, and HTML with CSS and JavaScript to create a fancy mix of flexible UI and dynamically updating...
Hi Guys,
I have this:
one string variable which holds the class name ($classname)
one string variable with holds the property name ($propertyname)
I want to get that property from that class, the problem is, the property is static and I don't know how to do that.
If the property weren't static, it would have been:
$classname->$pro...
public static function __get($value)
does not work, and even if it did, it so happens that I already need the magic __get getter for instance properties in the same class.
This probably is a yes or no question, so, it is possible?
...
Hi, I've setup data binding in VB.NET as follows with an Address business object and a Textbox. My issue is when I use
AddressObjectInstance.Name = "Bob"
the text box will update while if I do
AddressObjectInstance = AnotherAddressObject
the text field does not update. How do I force them to update properly?
My Address Object:
...
Can some one please tell me why I get odd results rurning the following code?
<?php
class Bank
{
var $ID;
var $balance;
var $name;
function bank($name,$id,$balance=0)
{
$this->ID=$id;
$this->balance=$balance;
$this->name=$name;
}
function getBalance()
{
return $this->balance;
}
...
I'm relatively new to php, and I'm working on a project using a mysql database. The project consists of users being able to write posts, which are then shown in a list format. The problem is, the posts are shown in different locations on the site, like the index (main) page, and the users profile page. Similar to twitter if you're confus...
Hello there
I am wondering if php methods are ever defined outside of the class body as they are often done in C++. I realise this question is the same as http://stackoverflow.com/questions/71478/defining-class-methods-in-php . But I believe his original question had 'declare' instead of 'define' so all the answers seem a bit inappropr...
I've been struggling in this area for days now, and I have reached a conclusion, but since the conclusion was not what I was looking for, before I give up, I'll try to see what other people say. Faith dies last...
Let's say we have a superclass (called "Super") and a subclass (called "Sub").
class Super {
protected static $title = ...
I have a class designated for a certain site. In that site I have different functions to retrieve data from the database and store that data into an array. I have other functions within the same class that take the data and format it into html and returns the html containing the data from the database.
For example...
function GetUserPr...
Hi,
I need to parse an XML record that represents a QuizQuestion. The "type" attribute tells the type of question. I then need to create an appropriate subclass of QuizQuestion based on the question type. The following code works ([auto]release statements omitted for clarity):
QuizQuestion *question = [[QuizQuestion alloc] initWithXMLS...
Hello
To avoid the more complicated solution where the frame calls some routine in the parent form so that the form can kill the frame... I was wondering if it's OK to simply set the form as the frame's parent, and let Delphi call Frame.Free when the user closes the application?
procedure TForm1.FormShow(Sender: TObject);
var
Frame2 ...