oop

What does OOP mean

What is OOP, OO, etc. I see it everywhere, but have no idea what it means. I am just looking for a brief description. ...

using require inside a class

i want to make a "loader class" that will require selected files. so i just can call eg. loader::load('systemLibraries, 'applicationLibraries'). so inside this load() method i will use require. but i have tried this and it seems that the files required can't be used outside the class. how can i make it globally accessed? ...

using objects in ajaxcalls php files

i have instantiated a class in my index.php file. but then i use jquery ajax to call some php files but they can't use my object that i created in the index.php file. how can i make it work? cause i don´t want to create new objects, cause the one i created holds all property values i want to use. ...

Can you get merged attributes for a class in C#?

Say I have the following set of classes, is it possible for the attributes of DerivedClass to be merged? Currently if I use the GetType().GetCustomAttributes()method passing in true for inheritance it takes the highest attributes in the inheritance structure. i.e. [Another("Bob")] and [My(16)] Is it possible for the attributes to be me...

Javascript object oriented programming books

I find myself working on an application that started out small but that has increasing amounts of javascript in it. Currently my code is procedural. However the codebase is growing in complexity and I suspect I am getting into a situation where a more object oriented approach would be appropriate. I come from a procedural background...

Why fetch database 'Apples' into a List instead of an ArrayList, Vector or LinkedList?

I saw an example like this in a text and wasn't sure why they did it this way. Let's say you're getting a bunch of Apple objects from a database: List<Apple> appleList = (List<Apple>) db.getApples() Why would you cast to a List<Apple> instead of one of the concrete List types (ArrayList, Vector or LinkedList)? ...

PHP syntax to call methods on temporary objects

Is there a way to call a method on a temporary declared object without being forced to assign 1st the object to a variable? See below: class Test { private $i = 7; public function get() {return $this->i;} } $temp = new Test(); echo $temp->get(); //ok echo new Test()->get(); //invalid syntax echo {new Test()}->get(); //...

Combining subclasses which have different fields for efficiency?

I'm working on a Java Android game. Games here generally need to use memory pools to avoid garbage collection. For the sake of argument, say I have the following classes: // Enemy in the game class Enemy { int x; int y; abstract void update(); } // Enemy that just bounces around class Roamer extends Enemy { int direction; ... } // Enem...

Problem in mysqli real_escape_string

The following code results to an error Call to a member function real_escape_string() on a non-object But if place the ($this->conn = new mysqli) inside the escapedString($string) method, it will run without error. What can be the reason of the error? Thank you. private $onMagicQuote; private $conn; function __contruct(){ ...

HAS-A, IS-A terminology in object oriented language

I was just reading through the book and it had the terms, "HAS-A" and "IS-A" in it. Anyone know what they mean specifically? Tried searching in the book, but the book is 600 pages long. Thanks! ...

Prevent ability to add "instance variables" dynamically Javascript OOP

Hey all, I was wondering if there is a way to disallow the following in javascript: var c = new Circle(4); c.garbage = "Oh nooo!"; // Prevent this!! Any ideas? EDIT: I was just about to give up on this, but I decided to check to see what the gods do (jQuery dev team).. how do they accomplish this? $('#Jimbo').hello = "hi!"; alert($...

Break method chaining in php

Hi I am using method chaining for my class structure. So my problem is that , how could i break my chain when error occurred in some function. Below is my code: <?php class demo { public __construct() { $this->a='a'; $this->b='b'; $this->error = false; } p...

How to load different ASP.NET controls for different concrete classes that inherit from the same abstract base class

Say you have an abstract base class Task which is a task a user can complete. There are two concrete Tasks: SimpleTask and ChecklistTask. What if you wanted the (ASP.NET) UI to show a different control based on which type of Task it is? In WPF you could use DataTemplates, but what is a nice way to do it in ASP.NET? We are trying to avoi...

Java: Deleting a GUI object from within the GUI

Hey Guys Can you help me out here? A really simple problem but I just can't get what the solution is! I am coding a listener application that runs on its own thread & listens on a ServerSocket for incoming connections. When a connection arrives, a new 'Message' object is created on a new thread and passed the incoming text data "messa...

calling a method from another method in same PHP class

Hi, I'm trying to use a method from within another method in a class. I don't have much experience in PHP5 OOP, and I looked around for answers, but couldn't find any. I'm trying to use getClientInfo() in sendRequest(), which is in the same class. class DomainHandler { public static function getClientInfo($db, $client_id) { ...

Setting A Default Variable Value In The Construct Of A PHP Class

I'm having difficulties in setting the values of a private variable in the construct of a class i'm working on... Can anyone spot where i'm going wrong? function __contruct($brokerId){ parent::__contstruct($brokerId); $this->_coverSummaryPoints = array('option1' => array('bullet point 1', ...

How do you define an OOP class in JavaScript?

Based on my observation, the book that I am reading about JavaScript states that there's an OOP with JavaScript? It doesn't tell much about it, I mean it wasn't explained how to define a class. Can someone give me a sample snippet? Thanks ...

Connect to Database in Object oriented PHP

How can I create a class in oo php wherein that class will be the one that will manage the DB connection? Sample codes or sites will do. Im using MySQL Command Client by the way. Main problem: How can I connect to the DB so that I can insert new records, retrieve records, update records? Thank you! ...

When is a class too long?

When is a function too long? is a subset of this question, I think. What are a few good metrics for determining that a class is too long? I'm rerevising a set of code acceptance guidelines for a project with external contractors, and realized I haven't covered this in the past, but should cover this in the future. ...

Should a class validate itself or create another class to validate it?

Let's say I have a class like: class NavigationData { float roll; float pitch; double latitude; double longitude; } and if I want to create a method: const bool validate() const; which basically validates whether the 4 fields contain valid values. Should validate() be part of NavigationData class, or should I create someth...