oop

PHP Accessing a child's private properties in parent

Hi I have a parent object that I use for general CRUD in my applications - it has basic save & retrieve methods so I can don't have to reinclude them them in all my objects. Most of my child objects extend this base object. This has worked fine, but I'm finding a problem with retrieving a serialized child object. I use a "retrieve" meth...

Application Settings for C# App

Hello, I have an app that has settings the user can pick before running the app. The settings are stored in a database. The entire app uses these settings. Right now, each class that uses the settings calls the database in its constructor to load the settings into a class. This seems odd to me because, the settings shouldn't change in t...

modeling a real world problem into java classes

How can i model foollwing problem statatement into java classe? I have a class vehincle. Vehicles can be of type Trucks, Cars, Scooters, motorcycles. Vehicle has a engine. engine shold have following contraints Petrol Engine and Diesel Engine are types of Engines Truck comes with 4 stroke, 12 cylinder Diesel Engine Car can have eithe...

Pass instance as function argument

I wrote a nice little app that gets Yahoo weather info and posts it to Twitter. It worked flawlessly and now I want to rearrange the code into differently named files so it makes more sense. And that's when I hit some issues. Previously, I had a Class in libtweather.py. It was my account. It allowed me to do accountName.parseFeed() an...

Tree Data Structure OOP Design Problem (C#)

Hi Guys, I have a tree structure design problem, and i can't think of a way out. i want to have one class Tree containing a generic data, and extend the Tree class with ComplexTree that will contain more methods like Iterate, DoSomthingOnComplex, etc. here is a sample of the code i have: class Tree<TData> { public TData Data { ge...

Do you see any way to shorten this class name?

I have a class called PriceStep. I keep a list of PriceStep objects in a class called PriceStepSearchSpace. Now I am required to have different PriceStepSearchSpace objects for different products and I need to keep them in some sort of a dictionary. I called this new class PriceStepSearchSpaceRepository. Can you think of a simpler/short...

override google.maps.Marker.prototype.setPosition return error

catch google.maps.Marker.prototype.setPosition calls (function(){ var setPos = google.maps.Marker.prototype.setPosition; google.maps.Marker.prototype.setPosition = function(latLng){ console.log(["setPos", latLng]); setPos(latLng); }; })(); return error this.set is not a function http://maps.gstatic.com/intl/cs_ALL/mapfiles/ap...

CakePHP - Fatal error: Call to undefined function

I get the Error Fatal error: Call to undefined function getAvnet() in C:\xampp\htdocs\ems\app\controllers\queries_controller.php on line 23 when accessing the source file attached. The line is: $ret = getAvnet('de', $searchstring); supposably calling function getAvnet($country, $query) The Source File ...

Can a MYSQLI connection be reopened WITHOUT instantiating a new object.

Hi All, Just a quick question here: If I choose the object oriented style to interact with my database, ie... $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); And I then use $mysqli->close(); to close the connection at some point... Can I reopen that connection by simply initiating another query $mysqli->quer...

How do I create a class that contains several classes that can communicate with each other?

I'm trying to take full advantage of object oriented php and learn something along the way. Following an MVC tutorial I was able to do this: class Repository { private $vars = array(); public function __set($index, $value){ $this->vars[$index] = $value; } public function __get($index){ return $this->va...

Which effect do interfaces have on execution speed in Delphi?

If I replace all object references in my Delphi program with interface references, and use objects which are inherited from TInterfacedObject, will the resulting application run with the same speed as before? Or does the reference counting add a significant execution overhead at run time? ...

Is there any reason to have interfaces for very basic data objects?

In writing my current project, I have created interfaces for all of my objects. I thought that this was considered good coding practice. I've basically ended up with a bunch of interfaces which define pretty trivial classes. Eg: public interface IUser { int Id { get; } string DisplayName { get; } } I don't really see any po...

AS3 OOP visualization logic - linking filters and data source

I'm trying to visualize the results of a quiz in ActionScript 3.0. What I would like some input on is how to best link the "filters" (top right corner in attached image) to the data source in a flexible OOP way. The result array now contains both number of correct answers and meta data about the person taking the quiz. The meta data cou...

Keeping code at the same level when dealing with static methods.

Hi all. This might be a little subjective, but I'd like to get your input on my current situation. I have a class that will be used to serialize/deserialize an object. public class MyClass { public static string ToXmlString( MyClass c ) { /*...*/ } public static MyClass FromXmlString( string xml ) { /*...*/ } } I only like th...

How do you declare a method as public but non-static in PHP?

The question is in the title. ...

JavaScript field Inheritance weird behaviour.

function A(){ this.a = {}; this.b = 0; this.Test = function(value){ this.a.x = value; this.b = value; }; } function B(){} B.prototype = new A; var b1= (new B()); b1.Test(1); var b2= (new B()); b2.Test(2); log(b1.b == 1); //true log(b2.b == 2); //true log(b1.a.x == 1);//false ...

Private class (not class method) in a Ruby module?

I'm new to Ruby (experienced with Python, C++ and C). I need to create a class that is only to be used by other classes and methods in a module. In Python, I'd just call it __classname. I'd use an empty typedef in C++. How do I do this in Ruby (or am I barking up the wrong tree and not doing this the "Ruby way"?) ...

AS3 accessing super class variables from subclass

Hey guys, I am hoping someone can explain about subclasses accessing variables from the super class. I found that the subclass can only access variables which are set in the constructor of the super class. Is there any way around this? package Character { import flash.display.MovieClip; public class Character extends MovieClip { ...

organising classes and modules in python

I'm getting a bit of a headache trying to figure out how to organise modules and classes together. Coming from C++, I'm used to classes encapsulating all the data and methods required to process that data. In python there are modules however and from code I have looked at, some people have a lot of loose functions stored in modules, wh...

What is the best way to parse this configuration file?

I am working on a personal project that uses a custom config file. The basic format of the file looks like this: [users] name: bob attributes: hat: brown shirt: black another_section: key: value key2: value2 name: sally sex: female attributes: pants: yellow shirt: red There can be an arbitrary number of users ...