oop

help fixing pagination class

here is my pagination class. the data in the construct is just an another class that does db queries and other stuff. the problem that i am having is that i cant seem to get the data output to match the pagination printing and i cant seem to get the mysql_fetch_assoc() to query the data and print it out. i get this error: Warning: mysq...

how to write a constructor...

is that correct to write a constructor like this? class A { A::A(const A& a) { .... } }; if yes, then is it correct to invoke it like this: A* other; ... A* instance = new A(*(other)); if not, what do you suggest? Thanks ...

Methods and properties in scheme - is object oriented programming possible in scheme?

I will use a simple example to illustrate my question. In Java, C, or any other OOP language, I could create a pie class in a way similar to this: class Apple{ public String flavor; public int pieces; private int tastiness; public goodness(){ return tastiness*pieces; } } What's the best way to do that with ...

the use of private keyword

Hi everyone I am new to programming. I am learning Java now, there is something I am not really sure, that the use of private. Why programmer set the variable as private then write , getter and setter to access it. Why not put everything in public since we use it anyway. public class BadOO { public int size; public int weight;...

domain modeling naming problem

Hello There are some simple entities in an application (e.g containing only id and title) which rarely change and are being referenced by the more complex entities of the application. These are usually entities such as Country, City, Language etc. How are these called? I've used the following names for those in the past but I'm not sur...

When should one create interface for request or response for messaging within the application

Hi, I want to know if there is any need to create interface for request/response objects. I know ServletRequest is an interface. I see request/response as simple pojo, where having some members to hold data and getter/setters would suffice. The processing of such data could be delegated to external utility classes. Does anyone have sp...

Can i access outer class objects in inner class

I have three classes like this. class A { public class innerB { //Do something } public class innerC { //trying to access objB here directly or indirectly over here. //I dont have to create an object of innerB, but to access the object created by A //i.e. innerB ...

Get information from a higher class?

I don't know really how to word the question so please bear with me... I have 3 classes: Server, Database, and Table. Each class has a "Name" property. How I want it to work is that each server can have multiple databases and each database can have multiple tables. So in the Server class I have this property. Private _databases As List...

Would you rather use a Singleton or dispatch another class' event through a Chain of Responsibility?

In general, what would make your program more maintainable? I know a lot of folks that make heavy use of Singletons, but that seems like a cop-out, which creates a kind of global junk drawer organization. ...

Should static methods be avoided as much as possible?

While developing an application in OOP, should static methods be avoided as much as possible? ...

I'd want a method to be called only by objects of a specific class

Suppose you have this class: public class A { private int number; public setNumber(int n){ number = n; } } I'd like the method setNumber could be called only by objects of a specific class. Does it make sense? I know it is not possible, is it? Which are the design alternatives? Some well known design pattern? So...

Factory vs instance constructors

I can't think of any reasons why one is better than the other. Compare these two implementations: public class MyClass { public MyClass(string fileName) { // some code... } } as opposed to: public class MyClass { private MyClass(){} public static MyClass Create(string fileName) { // some code....

ActionScript 3.0: placing code on stage/MC timelines a la AS2 instead of in classes

I'm aware that ActionScript 3.0 is designed from the ground up to be a largely object-oriented language and using it means less or even no timeline code in Flash documents. I'm quite experienced with OOP and am comfortable writing classes. However, since I mostly use Flash for animations, I hardly ever need to write ActionScript code ot...

[PHP] Access class with only the name of the class as a string

I am attempting to use an already initialized class in a function with only the string name of the class being passed to said function. Example: class art{ var $moduleInfo = "Hello World"; } $art = new Art; getModuleInfo("art"); function getModuleInfo($moduleName){ //I know I need something to happen right here. I don't...

PHP: Recursive array function

Hi everybody, I want to create a function that returns the full path from a set node, back to the root value. I tried to make a recursive function, but ran out of luck totally. What would be an appropriate way to do this? I assume that a recursive function is the only way? Here's the array: Array ( [0] => Array ( ...

OOPS and ADO.Net

Hi, I am building an bugtracking application where I am thinkining of taking maximum possible benefits of OOPS starting from my presentation layer to my data access layer. The architecture will be as usual 3-tier but I want to use Design Patterns or simply OOPS to create connection pull out data or something like that. ...

What is (self) in the python code? (OOP question)

class MyController(BaseController): def index(self): # Return a rendered template #return render('/test.mako') # or, return a response return '' Why does the function "index" have "self"? I got this code from Pylons controller ...

What is the difference between the Facade and Adapter Pattern?

I've been reading both definitions and they seem quite the same. Could anyone point out what are their differences? Thanks ...

Learning OOP in PHP, trying to refactor my code. Can't connect to database anymore.

Thought I understood how classes work, then I tried this code: class user { var $dbcon; var $dbinfo; var $con; var $error; function dbConnect() { $this->dbinfo['server'] = "localhost"; $this->dbinfo['database'] = "foolish_faith"; $this->dbinfo['user'] = "user"; $this->dbinfo['password'] = "password...

How to create PHP method linking?

I've seen other objects that do this: $obj->method1()->method2(); How do I do that? Is each function just modifying the pointer of an object or returning a pointer? I don't know the proper term for this style -- if anyone could help me with that, it would be great. ...