oop

Registry pattern and lazy instantiation of registered objects

Hello, Let's imagine that we have Registry pattern... <?php class Registry { private static $objects = array(); private static $instance = null; public static function getInstance() { if (self::$instance == null) { self::$instance = new Registry(); } return self::$instance; } protected function _get($key)...

Creating interdependent objects

Hi Stackoverflow, I have a design problem I cannot find a clean and nice solution to. I am developing in PHP but I believe this could occur in any language. My basic problem is that I have two objects that have circular interdependence at some level of indirection. That means I have a class (call it F) implementing the Facade pattern whi...

Is Erlang Object-Oriented?

Message-passing is a fundamental part of Erlang. Alan Kay has argued that message-passing is a concept more important than objects in his view of object-oriented programming (and he "invented" the term!). Can Erlang be considered an object-oriented programming language (à la Smalltalk)? ...

Is there a workaround for Composition and Marker Interfaces?

I see myself regularly confronted with the following problem. I have some kind of Marker Interface (for simplicity let's use java.io.Serializable) and several wrappers (Adapter, Decorator, Proxy, ...). But when you wrap a Serializable instance in another instance (which is not serializable) you loose functionality. The same problem occur...

What's a good practice to use forms in PHP? Can you use OOP PHP in a form?

Hello people, Right now i been creating a form for a comment section, a Login section, and sending email for a site i'm doing. The code I using was from a tutorial I learned and has too much HTML in it. It was the only way I knew how to create a form and valid the data. I wanted to ask if there was a better way to create forms and if t...

Design object for avaibility product stock of partner store.

Allowing a store whether a product is available in the stock of another store partner, the latter may either accept or reject the request, in all cases the applicant is informed of réponse. I want to implement a diagram class. Now I have a class product, and a class list of collections of products. I don't know how to represent a class ...

Process for pulling data from a sql database

I want to make a program that pulls objects from a sql database and processes the objects against a set of functions before returning the data to the user. It will work like this: User specifies a date range in a javascript form. The date range is sent to a php file on the server that converts it to a sql query. The sq...

How can I restrict a class to be creatable only within another class?

Hello all, I've been breaking my brain to figure out how to do this in C#. I have a TextGrid class, which is essentially an MxN grid of text. I'd like to have a Cursor class that maintains an (X, Y) position in a TextGrid, as well as methods for moving the position, querying the current position, etc. Ideally, I'd like for this class to ...

Static or not static?

Hello, people! What is better to use in this context, static methods, or simple public method and call them always like this: $request = new Request(); if($request->isPostRequest()){ do smth } ofcourse its easier to use static, but what is more properly to use? Class Request { public static function isSecureConnection() {} public sta...

Are there any instances when the destructor in PHP is NOT called?

Hello everyone! :) This is my first time posting to stackoverflow, but I these threads have helped me tremendously! Anywho, onto my question... are there any instances when the destructor in PHP is NOT called? The reason I ask is because I have a mapper class which maps data to objects and in the constructor, I start a transaction and ...

good example of OO JS?

Hi, Can anyone point me in the right direction of some real world object-orientated javascript? I'm learning OO for javascript from a few books but all the examples given in these books boil down to the dog object inheriting from the animal prototype or similar. I really want to see something a bit more substantial. I've looked at jQu...

Where can I find an example of a large JavaScript project using Crockford's method for prototypal inheritance?

I have read about Crockford's push for using JavaScript in a more obviously prototypal manner (cloning objects to create new ones, never using the "new" keyword). But in the wild, I have never seen anybody use this style for larger projects. Where can I find examples of a large project that uses this style? ...

Baffling JavaScript Inheritance Behavior

<disclaimer> What follows is the fruits of a thought experiment. What I'm doing isn't the issue; the symptoms are. Thank you. </disclaimer> I've finally wrapped my head around constructors, prototypes, and prototypal inheritance in JavaScript. But the SomethingSpectactular method in the sample below bugs me: function FinalClass() { ...

Visual Inheritance

Hi. I have same settings for all of my forms for example color , font , align, etc How can i do these settings for one form and inheriting it on all forms. thanks. Edition 1 : i am using Windows Forms. ...

Will there be any support for OO languages in HP-QTP ?

It seem to be a pain to stick to procedural kind of programming in Quick Test Professional. Often large no of lines of code need to be written which otherwise can be not required with OO langiages. What do you say? ...

how do i namespace pseudo-classical javascript

Hi, I have some simple OO code I've written that I'm playing with: //define a constructor function function person(name, sex) { this.name = name; this.sex = sex; } //now define some instance methods person.prototype.returnName = function() { alert(this.name); } person.prototype.returnSex = function() { return this.s...

codeigniter model error: Undefined property

I am new to codeigniter model, i try to follow steps in docs to load all user registered in my db. This is my model: user.php class User extends Model { function user() { parent::Model(); } function alluser() { $query = $this->db->query("select * from user limit 0,5"); //Line 30 error as in my IDE locat...

What is composition as it relates to object oriented design?

I hear (and read on this site) a lot about "favour composition over inheritance". But what is Compositon? I understand inheritance from the point of Person : Mammal : Animal, but I can't really see the definition of Compostion anywhere.. Can somebody fill me in? ...

How can I do dynamic class generation in Python? (or would a series of if/elses be better)

Hey guys! So, I'm writing something and I've come into a roadblock on how to do it (and what is the proper way of doing things). SO, explaining the situation will help be better understand the problem, and hopefully someone will know the answer :) Here it goes: Basically, I'm writing up some dynamic forms in Python (more specifically D...

should base class have attributes?

Hi All In another community, i have people suggesting that you should 'NEVER' have attributes in your base class. Instead it should have only pure virtual functions and let the derived class take responsibility to provide definition for all these methods. My take on it is that 'It is not a rule of thumb'. I gave following trivial examp...