oop

How to handle billions of objects without "Outofmemory" error

Hi All, I have an application which may needs to process billions of objects.Each object of is of TRange class type. These ranges are created at different parts of an algorithm which depends on certain conditions and other object properties. As a result, if you have 100 items, you can't directly create the 100th object without creatin...

What (not) to do in a constructor

I want to ask you for your best practices regarding constructors in C++. I am not quite sure what I should do in a constructor and what not. Should I only use it for attribute initializations, calling parent constructors etc.? Or might I even put more complex functions into them like reading and parsing configuration data, setting up ex...

Designing a generic DB utility class

Time and again I find myself creating a database utility class which has multiple functions which all do almost the same thing but treat the result set slightly differently. For example, consider a Java class which has many functions which all look like this: public void doSomeDatabaseOperation() { Connection con = DriverManager.ge...

Changing the type of an entity at some point of its life

I have the following hierarchy: Party is a base class, extended by Person and Corporation. I need to change the object class of an entity at some point of its life, and I don't know what's the best way to do this. I'm modeling the financial world, so I have that a Party can own shares of a Corporation, while only Corporation can have s...

When should I call super?

What is the best using of [super ... any method name]. Recently I have found out that In dealloc the [super dealloc] must stand in the same end. Because any variable what didn't use before can be filled by garbage if we set it after [super dealloc] It's a rare thing, but it's possible. After this we will have crash in our app. So what i...

Billing system best practices

Dear Gurus, I'm currently developing a web application for one of my clients. This client requested a small billing module. The client istelf is small SIP provider. There are several pricing items, plans, etc. All they different types of payment like onetime, monthly, annual. Are there any best practices, good books, articles on blling...

Is there any programming language in which you can override a method of 2 classes up?

For example, if you have class A, class B inheriting A, and class C inheriting B, is there any programming language in which class C can override a method of class A, even if class B don't override it? class A { method() {} } class B extends A{ } class C extends B { //override method from A method(){} } ...

Why overload a function with fewer / greater arguments?

So I am a java programmer and I know what overloading a function means. Moreover, I have overloaded a function with different type of arguments, and can overload with, fewer and greater arguments. I was asked this on an interview. I really don't know if this has any benefits or what the interviewer was getting at here. Does it have any...

How to get an instance of my object's parent

Is there a way in Java to get an instance of my object's parent class from that object? ex. public class Foo extends Bar { public Bar getBar(){ // code to return an instance of Bar whose members have the same state as Foo's } } ...

Routine to keep names of methods, classes and functions organized?

I am working on a web application with a couple of colleagues for the moment. It have turned out that we all have our own way of naming the classes, methods or whatever functions that we currently are writing. This is starting to get really annoying already so I know that we have a iceberg ahead if we continue like this. Obviously the ...

linking two objects // updating value on first and second

function associate( obj1 ,obj2 , key ){ if(typeof key === 'object'){ for ( var i in key ) associate(obj1, obj2 , key[i]); } else { obj1.watch(key, function (id, oldval, newval) { obj2[id] = newval; return newval; }); } } I wrote this function because if h...

Object Oriented way to iterate through a std::vector?

I have a class which has a std::vector of child control pointer. For obvious reasons, I do not want the user of the class to have direct access to the std::vector. All I would want is a way to give the caller the pointers. What would be a good OO way to do this? (this function will be called often) Thanks ...

How to create two parent controllers in Codeigniter?

I want to create two parent controllers: one for admin and one for user site. They have to extend a regular Controller class but each of them has to do different things. ...

ooPHP - How do I create an array of objects from an associative array?

Hi all, I'm not sure if this is even possible after trying to figure it out for hours but here goes... I have an class, UserPicture, which has properties for filename, filetype, created etc. (i.e. it doesn't store the actual picture as a blob, rather references it by using $filename.$filetype). I want to be able to have a page that dis...

General DFS on River Crossers

I'm trying to write a DFS to solve multiple river crossing problems (Fox Goat Cabbage, Jealous Husbands, Mercenaries and Cannibals, etc.). I've written the puzzle classes, but I'm having trouble structuring my solver. I understand how DFS works, but I can't figure out where to start to adapt it to this design. Each puzzle has a move() m...

What's are options for simplifying calls to functions with the same name, but different signatures in separate subclasses in python?

I have an base class, and two subclasses. Each needs to implement a method that's defined in the base class (but in the base class raises an NotImplementedError.. the base class is basically an abstract class). But, the implementation of the method in one of the subclasses requires more parameters than in the other subclass. class Subc...

Should I use «this.» keyword in OOP programing where it's possible to skip it? Any benifits of using it?

Possible Duplicate: When do you use the this keyword? In OOP sometimes we can write this.PropertyName = VALUE and sometimes we can skip this. and just write PropertyName = VALUE. So my question is, should we try always to use this.? Does using / writing this have any effect on application performance or does it just make the ...

Plain old singleton or spring singleton bean ?

I have a service in my application which is a singleton. My application is being bloated with the use of spring framework. I am confused over to use the singleton service as 1: Plain Old Singleton [Access them statically when required] OR as a 2: Spring singleton bean. [Use DI to inject when required] Which approach is correct ? ...

Designing WCF service interface. Procedural vs Object Oriented Design

Hi all, we are building product that can be used by other systems. As we have SOA, we develop only a service (WCF). We had several controversial discussions about how to design an interface of that service. We are choosing between procedural and OO design for service. As our service will be used from .NET and Java some say that it is h...

Codeigniter and Multiple Inheritance?

Wondering if this is even possible or a limitation of PHP, googling around seems to be the case but maybe I'm missing a clever solution here. Hopefully this will make sense. Right now I have two portions to my site, an admin and client side. I have been able to split it into two controllers(admin and client) that inherit from a base M...