oop

OOPS, there goes the performance?

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...

Best practice when using multiple libraries with overlapping classes

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...

Desigining Proper Classes

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 ...

Will splitting up included functions improve PHP performance?

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...

Javascript 'this' question

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...

What's so bad about ref parameters?

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 ...

Does using boost pointers change your OO design methodology?

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...

OOP - Where to put the calls to the Data Access Layer?

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?

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...

A use for multiple inheritance ?

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; } ...

What books do you suggest for understanding object oriented programming design deeply?

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? ...

Best practice for naming subclasses

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. ...

Object construction from serialization - which is preferred?

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...

Javascript OO question

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...

Use of @synthesize/@property in Objective-C inheritance

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...

What's a good example for class inheritance?

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...

Associative arrays in javascript

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...

Choosing between immutable objects and structs for value objects

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? ...

Child-Parent table : where I should put the method in 2 class?

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...

OOP - Objects For Entities With Master Lists and Object Composition

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...