I am trying to learn my first programming language. Unfortunately I picked the Iphone to start. Thought it would be easy... ooops. Anyway 4 weeks later I've actually got a couple of working apps! kind of...
One of my apps that had a couple of text boxes and a couple of labels.
Each person has a has button that starts a timer that decre...
Hi,
I have quite a lot of data to store, read and modify in memory while the application works. The data could be compared to a tree, where each node is described by limited number of strings and integers, and has quite a lot of subelements.
Currently the data is stored using classes/objects, like
TRootElement = class
fName, fDescripti...
Hi.
Just for the kicks i am trying to create a simple data object in javascript. Here is the code.
var roverObject = function(){
var newRover = {};
var name;
var xCord;
var ycord;
var direction;
newRover.setName = function(newName) {
name = newName;
};
n...
Hello!
Im trying to display two list: one for categories and brand but only the categories are being displayed. And when I remove the code for categories, the brands are being displayed. Is it because it is not possible to create instances of two classes in the same php page?
In index.php:
<?php
$obj = new CategoryList();
if (metho...
Example: I have a class called ParentClass. ParentClass has a constructor like this:
function __construct($tpl) {
// do something with the $tpl
}
When creating a new instance of ParentClass, I must provide that $tpl parameter like this:
$p = new ParentClass('index');
Then there's a ChildClass extends ParentClass. I want that th...
In PHP, is there any performance impact on using one long class with a lot of functions in it? Or is it advisable to use many small classes and call them separately when needed?
I am a newbie in OOPS and please ignore any silliness in the question. Thanks.
...
Example:
I want to have two different constructors, and I don't want to use func_get_arg(), because then it's invisible what args are possible.
Is it legal to write two of them, like:
class MyClass {
public function __construct() {
// do something
}
public function __construct(array $arg) {
// do something
}
}
...
I've got this constructor that takes an optional argument. The main problem with this is usability. The developer using my framework will catch a headache instantly because he doesn't know if he can provide an argument, what kind of argument, or if he can't at all. Conclusion: It just sucks. But PHPDoc may help a little bit if someone ha...
class MyImageTestClass{
var $url = "nfl2.jpg";
var $ID = "one";
function __construct() {
}
function setUrl($value){
$this->url = $value;
}
function setID($newid){
$this->ID = $newid ;
}
function loadImg($value,$newid){
$this->setID($newid);
...
I have a class for products import from CSV file operation which requires about 7 parameters. This is an info which is definitely needed for importer.
All of this parameters have the same life time. In the end we must have an Immutable Object.
I was too scared to list all of them in constructor because of its affect to readability and ...
I have 5 or 6 classes that I want to have follow the same basic structure internally. Really most of those that the classes should follow are just for the use of the function itself, so I really want these methods to be private.
Is there any way to achieve this? I know interfaces would work great but they won't take private members and...
Hello, I've been pondering the best way to implement a certain kind of functionality... that being derived objects referencing other derived objects with the same base (including mutual referencing).
Below is the best (simple) example I could think of to illustrate the kind of problem: a house made up of 3 rooms (though in practice it ...
Hi,
When performing OO design, is it better to consolidate a collection of methods that use simple value types into a generic method ? For example:
public int Sum(int x, int y)
// Overload with float.
public float Sum(float x, float y)
Consolidated to:
public T Sum<T> (T x, T y)
Thanks,
Scott
...
I am trying to design the interface that will be used internally for my application. Following Google's example, I strive to reduce public API clutter. However, there are some convenience methods that are defined in terms of the minimal methods. What factors should I consider as I seek a balance between convenience and tidiness?
Google ...
Hi SO,
I was wondering how associations, dependencies and such relations inherit in UML (or let's say, in general).
So, in a situation like this:
┌──────────┐ ┌──────────┐
│ ClassA │ │ ClassB │
├──────────┤ ├──...
I have a product class which contains 11 public fields.
ProductId
ShortTitle
LongTitle
Description
Price
Length
Width
Depth
Material
Img
Colors
Pattern
The number of fields may grow with attributes for more specific product tyes. The description may contain a large amount of data.
I want to create a slim version of this product cla...
I'm relatively new using OOP in PHP. It's helped immensely in the organization and maintenance of my code, but I'd like to get better at designing my classes and using OOP as efficiently as I can. I've read the Gang of Four Design Patterns book, but still need some help. After building a few small apps, here's one thing I keep running ac...
So my clients iphone app has balloned from 5 or so classes to over 25 in the last few weeks. With such a large (for the iphone anyway) class structure I've been utilizing the Singleton class for accessing global variables. The problem is that whenever I need to access a variable outside of the class I'm working on, I have a choice of e...
I have class that extends another class.
class TWITTER_FOLLOWERS extends TWITTER_BOT
in TWITTER_FOLLOWERS i want to acces the db object from TWITTER_BOT
but i get just an error
Fatal error: Call to a member function fetch_all_array() on a non-object in /var/www/bot/inc/TWITTER_FOLLOWERS.php on line 163
On line 163 i have this code
...
I hope this isn't too subjective. I can't decide between these two design opportunities.
I have a Front Controller pattern. When the user surfs to a specific URL, my framework loads a specified View Controller for this URL. The View Controller then calculates some things and loads a View Template, to show the results.
Now imagine you ...