Suppose we have an object that represents the configuration of a piece of hardware. For the sake of argument, a temperature controller (TempController). It contains one property, the setpoint temperature.
I need to save this configuration to a file for use in some other device. The file format (FormatA) is set in stone. I don't want the...
Hi, i got a question when create a javascript object,
when one function invoking another function within the object, do we need to use 'this'
MyObject = function() {
this.function_one = function(param) {
return param + param;
};
this.function_two = function(param) {
return this.function_one(param) * this....
First thing i want to say that it's not an easy question to explain, so please be patient if it seems confusing.
I have a set of classes like this
class Product {
public static $static_type = 'product';
public static $static_table = 'product_table';
public function __construct($params) { //do some }
}
and then there are t...
Of course, I can explain it in whole books.
But I read a few days ago, that in a application talk, it is often asked and they expect a answer in 2-5 sentence, that should be very clear and show that you udnerstand the material.
I tried a few times to collect the answer in 2 sentence but don't get a good one.
...
We recently built a web app using Prototype, making a fair amount of use of its Class.Create() functionality. Right now, we're considering migrating to jQuery as it seems to be considered a 'better' library. I've been doing some reading on the topic and found out that jQuery does not have straightforward built-in support for class-creati...
Im trying to access the Magento customer session in another part of my website.
domain.com/shop/ <- Magento
domain.com/test.php
The shop itself works like a charm, however im trying to determine within test.php if a customer is logged in, so I can display his name with a link to his cart.
Contents of test.php so far:
<?php
require_o...
As I wire up my first fairly complicated Cocoa-Touch view I feel like I'm inadvertently slipping back into old procedural patterns and finding it difficult to shake them off...Though fully aware of many of the Cocoa (OO) design patterns I'm afraid I may be subverting them.
As such this view in question is quickly becoming unmanageable a...
Can anyone see anything wrong with this login script:
public function login($username, $pass, $remember) {
// check username and password with db
// else throw exception
$connect = new connect();
$conn = $connect->login_connect();
// check username and password
$result = $conn->query("select * from login w...
I recently had an idea to create my own String class to make using PHP's functions easier. Instead of strlen($str) I write $str->length(). Makes it easier to remember parameter orders in certain functions, like substr.
I ran some timing scripts on it and found that it's about 5 times slower than using the regular functions. I haven't te...
I'm a student looking for resources which can help me further understand how to properly apply access modifiers to members/types as I code them.
I know (in C#) what restrictions access modifiers like private, public, protected, etc. put into place. When I code my own little projects I have a tendency to just make everything public. I'm ...
I'm working on a large project (for me) which will have many classes and will need to be extensible, but I'm not sure how to plan out my program and how the classes need to interact.
I took an OOD course a few semesters back and learned a lot from it; like writing UML, and translating requirements documents into objects and classes. We ...
I'm trying to learn how to use oop in php. I'm also fairly new to jquery. Is it possible to make an Ajax request to a php class method? I've only ever sent Ajax requests to a file specifically for that purpose and that returns the data I need. Sorry if I haven't explained myself very well.
...
How do you define a software component and what kind of relationship is there between OOP and component programming? What are the pros and conns and what is the "golden ratio" of these paradigms?
...
Method chaining is the practice of object methods returning the object itself in order for the result to be called for another method. Like this:
participant.addSchedule(events[1]).addSchedule(events[2]).setStatus('attending').save()
This seems to be considered a good practice, since it produces readable code, or a "fluent interface"....
Hi,
Can you please outline the differences between the Repository pattern and the Factory pattern?
...
Is it possible to access a parent member in a child class...
class MainClass {
class A { Whatever }
class B {
List<A> SubSetList;
public void AddNewItem(A NewItem) {
Check MasterListHere ????
}
}
List<A> MasterList;
}
So... my main class will have a master list. It will also have a bunch of instances of...
In this code:
<?php
class Foo
{
var $value;
function foo($value)
{
$this->setValue($value);
}
function setValue($value)
{
$this->value=$value;
}
}
class Bar
{
var $foos=array();
function Bar()
{
for ($x=1; $x<=10; $x++)
{
$this->foos[$x]=new Foo("Foo...
I understand overriding a method/function redefines its implementation in the derived class from its implementation in the base class.
Now what confuses me, is if I override a class in ASP.NET such as CreateChildControls() (I picked it randomly for no particular reason), VS2008 auto generates:
protected override void CreateChildControl...
Good evening,
In my app that I'm currently developing, I have a class that handles multilinguism. It does so by externally loading an associative array, where a translation source would be defined something like this:
'Source input' => 'Zdroj vstupního'
Currently this works flawlessly by addressing and using the class the following w...
Should functions that act on and object, say to fill it out from xml, belong to the object itself or should whatever is creating the object own these function?
...