I was working on my website written in php/mysql. When I first wrote it, it was spaghetti with lots of php embedded in html and the like - very hard to maintain.
I rewrote the whole thing with a nice modular structure with OOPS, and now it is much easier to maintain and expand.
But when testing the site performance using webwait and si...
Consider the task:
Read a polygon from a KML file using library A
Intersect it with another polygon using library B
Calculate its area using library C
Each library has it's own Polygon class, and they are all equivalent. Which is the best practice when using all these classes? At the moment I first wrote this question I had imp...
Hello,
I've read all the books about why to create a class and things like "look for the nouns in your requirements" but it doesn't seem to be enough. My classes seem to me to be messy. I would like to know if there are some sort of metrics or something that I can compare my classes to and see if there well designed. If not, who is the ...
Hello.
I have main php-file with main class.
Also in this class i do
require_once("func.php");
which has many useful functions for my site.
Size of func.php is very big, because there is many functions for different actions on different pages. But I include it on every page, because including called by main class.
What I need to d...
I have the following:
var o = {f: function(fn) {
fn.call(o);
}};
var ob = {f: function() {
o.f(function() {
this.x = 2; //HERE: how can this reference ob?
//ob.x = 2;
});
}};
ob.f();
ob.x; // undefined
o.f(fn) calls fn where this is bound to o.
At HERE, I want to use this to access ob.
However, when ob.f i...
I'm faced with a situation that I think can only be solved by using a ref parameter. However, this will mean changing a method to always accept a ref parameter when I only need the functionality provided by a ref parameter 5% of the time.
This makes me think "whoa, crazy, must find another way". Am I being stupid? What sort of problems ...
After switching from C++ to C++ w/boost, do you think your OOD skills improved?
Do you notice patterns in "Normal" C++ code that you wouldn't consider that you've switched, or do you find that it enables a more abstract design?
I guess I'm really wondering if you just use it as a tool, or if you change your entire approach to OO desi...
I am implementing a Data Access Layer (DAL), which is basically a set of classes with (VB.NET) Shared functions to actually execute the database (CRUD) calls. I am trying to figure out the best place to place the calls to the DAL within the class hierarchy. Let me give an example.
Suppose I have a class Customer, with only standard ID, ...
What is the advantage to have all my classes instantiated only through the Factory DP?
As far as know a Factory is good when you have to choose from a list of similar objects to perform some task,let's say like translations classes (english-> franch, arab->hebrew ...)
But when you have really one possible option, no reason to obscure/ab...
Can anyone think of any situation to use multiple inheritance? Every case I can think of can be solved by the method operator
AnotherClass() { return this->something.anotherClass; }
...
I have been programming OO for a while. But now I feel I have reached a place where I need to understand principles and fundamentals of object oriented design and theory scientifically and deeply.
What resource, especially books can you suggest?
...
I am often in a situation where I have a concept represented by an interface or class, and then I have a series of subclasses/subinterfaces which extend it.
For example:
A generic "DoiGraphNode"
A "DoiGraphNode" representing a resource
A "DoiGraphNode" representing a Java resource
A "DoiGraphNode" with an associated path, etc., etc.
...
Lets say you have a class SomeClass which has its own implementation of toString(), and also has the ability to parse a new instance of itself by reading that same string.
Which of these methods do you prefer, or find better to use?
You can either define it as another constructor:
public SomeClass(String serializedString);
or you can...
So I want to build a form validation class/object in javascript. The way I see it working would be something like this:
var form=new Validation();
form.addField("name","Your name","required");
form.addField("email","Email Address","is_email");
.........
form.validate();
I was thinking that the validation class would be defined someth...
If you have Class A with an instance var "foo" which has a @property/@synthesize directive, and Class B inherits from Class A, does it also need to @property/@synthesize "foo"? The reason I ask is because when I try to use Class B's "foo", the calling class says that "foo" is not something of a structured union or a member, which makes m...
I'm writing documentation for an object-oriented language, and I wonder what kind of classes would be a good example for inheritance.
Some common examples:
class Person {
}
class Employee extends Person {
}
Currently my favorite, but I don't like Person->Employee because 'Employee' does not exactly look like fun.
class Bicycle {
}
c...
I have this object:
function formBuddy()
{
var fields = new Array();
var labels = new Array();
var rules = new Array();
var count=0;
this.addField = function(field, label, rule)
{
fields[count] = field;
labels[field] = label;
rules[field] = rule;
count = ++count;
}
}
Its use...
How do you choose between implementing a value object (the canonical example being an address) as an immutable object or a struct?
Are there performance, semantic or any other benefits of choosing one over the other?
...
I have two table with parent child relationship and still confuse how to map it into class from tables. Simple class which encapsulate methods and not using Business Object / Value Object. The tables are category and product.
When a webform list product from a category, what approach I should do?
Create Category object and call GetProd...
I'm trying to wrap my head about how to properly implement an OOP design for business objects that:
Have a "master list" in a database (ex. classifications)
Are a part of another object as a property (i.e. object composition) but with additional properties
Here is where I'm stuck on the theory. Suppose that I have a Classification ob...