// Decide which layout to use
$oo->layout = ($oo->layout != "") ? $oo->layout : $oo->config->get("DefaultLayout", OO_DEFAULT_LAYOUT);
$layout_file = sprintf("%s/%s.html", $layout_path, $oo->layout);
// Load the page
$oo->page = ($oo->page != "") ? $oo->page : $oo->action;
$page_file = sprintf("%s/%s.html", $page_path, $oo->page);
if (fi...
Hello,
I have a generic question about javascript specification or implementation of functions pointer (delegates?) which are points to object methods.
Please, read the following code snippet. Here we have an object with a method using 'this' to access an object field. When we call this method as usual (o.method();), returns value of ...
Hi
I have been given an opportunity to teach C++ Programming to school students, who are beginners to programming. I have introduced them programming basics neatly and now it is time for me to move on to teach them OOP Concepts. I can teach them about classes and objects but i have no creative ideas to introduce them these concepts prope...
I'm new to the OOP paradigm, so there's probably a simple explanation for this question...
Do you always need to declare public object-wide variables in a class? For example:
<?php
class TestClass
{
var $declaredVar;
function __construct()
{
$this->declaredVar = "I am a declared variable.";
$this->undeclaredVar ...
Does anyone have any suggested or established best practices and naming conventions for copy constructors / factory methods etc in Java? In particular, say I have a class Thing and I want a method somewhere that returns a new Thing with the same value as a Thing passed in (or as the instance if it's an instance method). Would you have ...
I am a huge fan of software design principles such as SOLID and DRY. What other principles exist for OO software design?
Note. I’m not looking for answers like "comment your code" but instead looking for OO design principles like the ones discussed by Uncle Bob.
...
I have client/server applications and a very simple protocol for communication. More precisely, it's a set of commands a server sends and a set of requests a client can make.
The idea is as follows:
When a command is made by the server, a client has to execute it.
When a request is made, server checks permissions and if everything is o...
I've come across 2 different styles when adding button listeners in UI. I use SWT as example. But nonetheless I saw the similar code in J2ME, Flash Actionscript as well.
style 1:
b1.addSelectionListener(new SelectionListener()
{
public void widgetSelected(SelectionEvent e)
{
System.out.println("b1: ");
}
public void widge...
So, I'm building stuff in AS3, I have a main movie clip, and I have one set of navigation to be displayed twice (one is a normal side bar setup, the other is a fancy designer scrolly thing down the bottom). When one is clicked, the other should react to reflect what has happened.
Should main.menuA reference main.menuB, or should I set ...
Hi ...
I know that when we have a virtual function in our own base class, then by overriding it in a derived class and considering casting when variable declaration, we have different result with comparison to using new modifier in the derived class. but why? Is there any logical reason for that or we have to learn it without any reason?...
Hi...
What's the Practical usage of new (modifier) functions?
...
I've just created a Classic ASP version of the FirePHP server side library, that works with the regular old FirePHP console.
see the Github project
However in my implementation, i have to create a global to store the class instance.
I have no idea how to, if it is even possible to create static methods, and thus use the singleton patt...
I need to explain myself why I do not use static methods/propertis. For example,
String s=String.Empty;
is this property (belongs to .Net framework) wrong? is should be like?
String s= new EmptySting();
or
IEmptyStringFactory factory=new EmptyStringFactory();
String s= factory.Create();
...
I often see two conflicting strategies for method interfaces, loosely summarized as follows:
// Form 1: Pass in an object.
double calculateTaxesOwed(TaxForm f) { ... }
// Form 2: Pass in the fields you'll use.
double calculateTaxesOwed(double taxRate, double income) { ... }
// use of form 1:
TaxForm f = ...
double payment = calculateT...
Hi guys, a point of architectural style that I'd like your opinion on please:
My ORM has given me a User object which corresponds to a user of my system. I wanted to develop a bunch of methods for handling Users - GetByUsername(), Authenticate(), VerifyLoginPassword() etc. However it feels to me that some of these methods don't really b...
Hi,
sorry for that weird subject but I don't know how to express it in an other way.
I'm trying to access a method from a calling class. Like in this example:
class normalClass {
public function someMethod() {
[...]
//this method shall access the doSomething method from superClass
}
}
class superClass ...
The button in the code below is to me the only object that should listen for ActionEvents but when I resize the window the circle changes color which should only happen when the button is pressed.
Does it in some way use frame.repaint() when resizing the window that generates new values for the drawPanel object or even makes a new draw...
I have the following code in a method of a class:
XmlSerializer serializer = new XmlSerializer(typeof(FooClass));
How do I pass into the constructor or a parameter of the class - the foo class?
I think it has something to do with reflection as you can't pass as a parameter just a class name - so the following code makes some sort o...
Let's say I have a very simple PrototypeJS class that looks like this:
var Foo = Class.create({
initialize: function() {
this.bar = 'bar';
},
dostuff: function() {
$$('.enabled').each( function(elem) {
alert(this.bar); //FAIL
});
}
});
This fails because the function being passed to .each() doesn't have a...
I got a Base superclass and a bunch of derived classes, like Base::Number, Base::Color. I'd like to be able to use those child classes as if I they inherited from say Fixnum in the case of Number.
What's the best way to do this, while still having them respond appropriately to is_a? Base ?
So, I should be able to do
Number.new(5) + N...