oop

Python elevator simulation problem

I have a homework assignment that's really baking my noodle. It involves an elevator simulation that takes user inputs for the number of floors and the number of people using the elevator. the people's starting floor and destination floors are random numbers within the floors. I realize that my code is very sparse and that there's qui...

PHP: How to return an instantiated class object, given a class name?

They say that eval() is evil. I want to avoid the use of the eval() line using proper PHP5 functionality. Given a class name in a static class method, how do I make it return a real object? class Model { public static function loadModel($sModelPath) { if (!(strpos(' ' . $sModelPath, '/')>0)) { $sModelPath .= '/' . $sModelPat...

PHP: How to pass existing database connection to static class methods?

I have a set of static class methods. I also have an existing database connection in a script stored in an object variable $DB. How do I call those static class methods and let them use that $DB object without having to pass them this variable every time as a parameter on the class method? For instance, right now I'm having to use a glo...

How to design an application in a modular way?

I am looking for pointers, suggestions, links, warnings, ideas and even anecdotical accounts about "how to design an application in a modular way". I am going to use python for this project, but advice does not need to necessarily refer to this language, although I am only willing to implement a design based on OOP. Here's some context ...

which resources would you recommend for learning object oriented programming (C#)?

hi, as the question says, i wish to learn OOP in c#. I am aware of the basics of OOP such as what does class means, what is object, and all 6-7 features of OOP. What i dont understand that how to make use this in real application? I get stuck when it comes to using all these features during development (coding). I have code in VB.NET a...

Model-view seperation, Airplane simulator

I am trying to achieve Model-view separation. My airplane is a class. While developing the application, can't I use the console as sort of viewer. Can I spawn the airplane on it's own thread, while the console makes references to the airplane object to retrieve/read it's current altitude. I am trying to make the airplane an Active object...

Naming Classes - How to avoid calling everything a "<WhatEver>Manager"?

A long time ago I have read an article (I believe a blog entry) which put me on the "right" track on naming objects: Be very very scrupulous about naming things in your program. For example if my application was (as a typical business app) handling users, companies and addresses I'd have a User, a Company and an Address domain class - a...

Recursive directory searcer PHP

How can i write an recursice directory searcher that takes a geven string and return the whole path plus the filename in php? ...

Calling Functions in Objects with Javascript

I have an object defined like this: Blah = { hideTimer:null, setTimer: function() { this.hideTimer = window.setTimeout(Blah.hidePopupInner, 500); // must be done via window due to Greasemonkey }, hidePopupInner: function() { log("This? " + this); }, hidePopupInnerPublic: function() { Blah.hidePopup...

Is there a Database for ALL ENTITIES in the world? or an Object-oriented library?

Hi Guys, I do not know why I want to get or make this, a relational database contains all entities in the world, or an object-oriented set of classes, structs, interfaces.. etc for EVERYTHING in the world! Do you know where I can find something like this? ...

Set an object's superclass at __init__?

Is it possible, when instantiating an object, to pass-in a class which the object should derive from? For instance: class Red(object): def x(self): print '#F00' class Blue(object): def x(self): print '#00F' class Circle(object): def __init__(self, parent): # here, we set Bar's parent to `parent` ...

Make sure only corresponding implementations or childs of it will be handled

Imagine the following situation: As may notice the Handler-childs and the Costumer-childs match each other. Each Handler has a method that takes a costumer. Is there any good way true oo-ish to make sure that a Handler-implementation only takes a correponding Costumer-implementation or any childs of it? Some examples: Handler will...

Overriding target in jQuery event

Is it possible to override jQuerys target in a custom event? f.ex: var scope = function() { this.param = 'foo'; } var instance = new scope(); $(instance).bind('bar', function(e) { console.log(e.target); }); $(instance).trigger('bar'); This outputs the entire instance object, as it should. But if I want target to be someth...

Is it possible to descend from Silverlight's System.Windows.Controls.Page?

I would like to create a descendant of the Silverlight Navigation Framework's Page class, so I can perform common navigation code on all of my pages, but I can't figure out how to do this. When I create a descendant class, how do I reference that from my XAML files? They currently have the "navigation:page" tag, so how do I replace that...

Convert Array to Object PHP

How can i convert an array like this to object? [128] => Array ( [status] => Figure A. Facebook's horizontal scrollbars showing up on a 1024x768 screen resolution. ) [129] => Array ( [status] => The other day at work, I had some spare time ) ) ...

Composition or Inheritance for DAL And BLL?

Questions Should the Data Access Layer (DAL) and Business Logic Layer (BLL) be exposed through interfaces or through abstract base classes? When should we choose abstract classes instead of interfaces and when interfaces instead of abstract classes? Is one benefit of using abstract base classes that if external party decides to ext...

How do i get out of the habit of procedural programming and into object oriented programming?

Hiya all, I'm hoping to get some tips to kinda help me break out of what i consider after all these years a bad habit of procedural programming. Every time i attempt to do a project in OOP i end up eventually reverting to procedural. I guess i'm not completely convinced with OOP (even though i think i've heard everything good about it...

Extending dojo.gfx.Group with default instanciated shapes

I'm attempting to create some simple UI components with dojo.gfx. I've managed to extend dojo.gfx.Group, but am out of my depth getting any of the default shapes drawn to the surface. Inspecting the rendered SVG in Firebug, there's rightfully a node but no rect. The simplified class looks like this: dojo.provide("gfxui.SimpleButton")...

PHP share objects across multple sessions

How can i have user A and user B has the same instance of an object? I guess this would be across two different sessions. TIA. ...

Level Design in Pygame

Hey--I'm trying to design my first game using the Pygame library for Python, and I was wondering what the best practices are for level design in general. I would love to hear what you guys think are good object oriented design patterns for managing levels. Also, I'm fairly new to Python--thanks! ...