oop

why is this optional method argument shared across different python objects?

Possible Duplicate: Least Astonishment in Python: The Mutable Default Argument can anyone explain me this? class Strange(object): def mutate(self, x=[]): x.append(1) return x obj = Strange() print obj.mutate() another_obj = Strange() print another_obj.mutate() >> [1] >> [1, 1] mutate() is called with...

OOP/OOD Coupling question

I have a function that returns the orders for a given period. I've create a Period object which ensures that, when specifying a date range, the start date is <= to the end date. Likewise, if dealing with a month period, the start and end dates of the period should be the first and last days of the month, respectively. My question is thi...

Object Oriented Javascript vs. Pure jQuery and .data storage

My current style of programming is OO javascript using the Class.extend function by John Resig: http://ejohn.org/blog/simple-javascript-inheritance/ This has been fine but I find myself writing numerous setters and getters that only get used on init. Also, it seems to lead to memory leaks in IE when storing instances of these objects i...

PHP: how to get a list of classes that implement certain interface?

I've got an interface interface IModule { public function Install(); } and some classes that implement this interface class Module1 implements IModule { public function Install() { return true; } } class Module2 implements IModule { public function Install() { return true; } } ... class ModuleN ...

php getting array key column dynamically

Hi, I am trying to dynamically get a specific data array by using a function (parsing an excel file, so for instance, I can grab the fourth column of the file as follows): foreach ($obj->Worksheet->Table->Row as $row) { $rows[] = (string)$row->Cell[4]->Data; } My problem is im trying to dynamically specify the "cell" to get and ...

Objective C [object release]

I'm looking at someone else's code, but it appears to RELEASE object VIDEO but then continue to use it. Now from my understanding of Object Oriented Programming languages, once it's released, it should be dealloc'd from memory... I can't see how it has any references...but I'm assuming that's the reason it's OK. Seems like a strange th...

Objective C / Object Orientated Pointers

Hello world.. I have been playing with objective C a little and am finding it a great language.. Coming from C# i found pointers a little hard but now i understand the concept and how to use them.. ie: MyObject* x = [[myObject alloc] callinitializer]; which create a new object on the heap and a pointer on the stack.. but can someb...

Recommended program structure

Hi all, as a beginner, I have formulated some ideas, but wanted to ask the community about the best way to implement the following program: It decodes 8 different types of data file. They are all different, but most are similar (contain a lot of similar fields). In addition, there are 3 generations of system which can generate these fil...

PHP: Why isn't it possible to extend more than one class?

I've faced a situation when I want to extend two parent classes, but php does not allow this. Why I can't extend more than one class, but can implement more than one interface. What's wrong with extending many classes? It seemed to me like a pretty obvious thing, until I got parse errors. Is it a bad practice? If so, what are the alterna...

Need advice for Coursework

Hello, In have Coursework in my university by OOP development. I have some themes in this Coursework, but i can create Coursework inmy own idea. Please can you advice me theme in Coursework by object oriented programming, any programming language supporting OOP. Thank you. ...

If using Functional Oriented Programming does the "impedance mismatch" go away?

I see a lot of work at the moment on Entity Modelling in Code and interest in functional Programming. After some years working in Object Oriented Systems I have time and time again come up against the "Impedance Mismatch". Since Transact SQL implements some FOP with datasets being described as Sets in a declarative way, does the "imped...

PHP5 Class scope quirks

Hey php gurus. I'm running into some bizarre class scope problems that clearly have to do with some quirk in php. Can anyone tell me what out-of-the-ordinary situations might give the following error... Fatal error: Cannot access self:: when no class scope is active in MyClass.php on line 5 Now, obviously if I were to use self:: outs...

New to OOP PHP, need critique on first Geo RSS Class

I'm completely new to OOP PHP and currently reading "PHP Objects, Patterns and Practice". I needed to develop something that will generate a GeoRSS feed. This is what I have (it works perfectly, I would just like some critique as to what I could do different / more efficiently / safer): class RSS { public $channel_title; public $chann...

Designing a library with helper methods static or interface based ?

I am designing a .Net library that exposes methods all of which can be tagged only as helper methods. Takes in PersonID, RoleID etc returns calculated salary, Salary for the entire year, Bonus etc. Is it ok to design just a static class that has methods like GetSalary(), GetBonus(), GetHistoricSalary(). Or should I have an interface IS...

What design pattern, or anti-pattern?

I'll describe what I'm trying to do, and hopefully, somebody can tell me what design pattern this is or point out a better alternative. I have a method doing a bunch of complicated stuff that involves an approximation. It is possible to compute the result without the approximation but this involves more work. What I want to do is get o...

Looking for some good CS videos

I'm wondering if there are any good free videos out there of actual Computer Science courses (college) on hardware and programming...both. Anyone know where I may find a few to review some concepts? couldn't find jack in ITunes University, just a bunch of basically promotion junk for each university, nothing of real value or actual cla...

Why aren't static methods considered good OO practice?

I'm reading Programming Scala. At the beginning of chapter 4, the author comments that Java supports static methods, which are "not-so-pure OO concepts." Why is this so? ...

'Use a static array'... what does that even mean?

I know what a static array is and how to use it in Java, but my Prof assigned us a program and for one of the many classes we had to create, he asked us to 'use a static array' in such a way that multiple objects will store their data there. For instance, if the objects were car garages, then each garage instance would store in a 100x3 ...

Where does my DDD logic belong?

I’ve been persuaded by Eric Evans’ book and am integrating DDD into my framework. All basic elements (services, repositories, bounded contexts, etc) have been implemented and now I’m looking for feedback on how to correctly integrate this. I have some business logic which has to be performed when an entity is created or modified. This e...

Javascript: Allowing "virtual" function in base class to create instance of subclass

Hi, I have the following object model I want to get working - have been banging my head against the clone bit! Is this possible? I can't seem to get access to the SubClass constructor from within the baseclass without hard coding it. The code is for a queue of arbitrary operations that all share a lot of common functionality; new operat...