Check if function has been called yet
New to OOP in PHP One of my functions requires another function to be executed before running. Is there a way I can check this? ...
New to OOP in PHP One of my functions requires another function to be executed before running. Is there a way I can check this? ...
In object-oriented programming, it's sometimes nice to be able to modify the behavior of an already-created object. Of course this can be done with relatively verbose techniques such as the strategy pattern. However, sometimes it would be nice to just completely change the type of the object by changing the vtable pointer after instant...
Is it possible in C# to define return type of a method as some class that additionally implement some interface? For example, in GTK# application I would like to have a widget to display documents. I would like to provide several implementations of that widget - one based on Gecko, one on Webkit and one, basic,on regular Gtk.TextView. C...
I need to construct an XML transaction of the following format: <RateV3Request USERID="MyId"> <Package ID="1ST"> <Service>ALL</Service> <FirstClassMailType>LETTER</FirstClassMailType> <ZipOrigination>06226</ZipOrigination> <ZipDestination>06231</ZipDestination> <Pounds>0</Pounds> <Ounc...
This site tickled my sense of humour - http://www.antiifcampaign.com/ but can polymorphism work in every case where you would use an if statement? ...
I need to attach a significant number of additional properties to every user in my Django project. Some of these properties are simple CharFields, others are more complex ManyToManyFields. The trouble for me, is that in my digging around of ways to do this, I've found two options: The user profile method explained in the documentation,...
Suppose I have a class Base which has a member variable A* my_hash. I also have class Extended which inherits from class Base. I also have a class B which extends A. class Base{ Base(): my_hash(new A) {} //methods which use my_hash protected: A* my_hash; }; class Extended:public Base{ //methods which use my_hash from A //I can...
HI all. I have started a new job recently where I am supposed to work with C++/ I have been doing programming in C language for past 5 years. I am looking for ways to get me up to an acceptable level in OOP. I have all the basic concepts of C++ and OOP but don't have much experience of actual class designing. What I really am looking for...
What I want to do is access the query function in my database class form anther class. Evey time a query is done I track the time it takes and add the the query count, I want to do that for all query's. The layout I have now is: Global ----------------------------- | | database class ...
Are there any generalisations of object and data and thread interactions given design pattern names? Obviously what goes on a lot is synchronisation on an object, passing messages through a queue and also reference counts in memory management systems. But are there any more OO-oriented names for multithreading design patterns and syste...
Hi, I have a "meter" class. One property of "meter" is another class called "production". I need to access to a property of meter class (power rating) from production class by reference. The powerRating is not known at the instantiation of Meter. How can I do that ? Thanks in advance public class Meter { private int _powerRating ...
Is a data type a piece of code? In other words, is it software? I'm talking about fundamental data types like integer, char, etc. If so, does that indicate that objects in OOP programming are extensions of data types? That is, basically, have programmers taken data types to another level in creating objects? ...
I have a Java class that only consists of static member variables and static methods. It is basically serving as a utility class. Is this a bad practice to have a class that only consists of static member variables and static methods? Thanks Steve ...
How can i do the followin tasks public function addToCache($id,$items) { // in zend cache } public function getFromCache($id) { // in zend cache } The first method should take an id and items which should be cached. The second method should just take an id of an cached object, and should return the content of the cache of that it...
I was wondering if anyone had a possible solution to the following problem... I have a base class that a series of derived classes will inherit from. The base class cares about whether properties on the derived class have changed. This is to set up an "IsDirty" approach for a data transfer object. The traditional approach would be to...
I'm new to Ruby, coming primarily from C# and ActionScript 3 (among other langauges). I'm curious about abstracting functionality. Specifically, wrapping and abstracting Ruby's FTP and SFTP libs. I was searching around and came across a gem called Backup. It really got my attention because it supports backing stuff up via S3, SCP, SF...
I just can across some code where they've got an implicit setter, but no getter eg: public class Person { //no getter! public function set food(value:Food):void { // do something with food. this.processFood(value); this.dispatchEvent(new Event(FoodEvent.EATEN)); } } This smells bad to me. Hacky. W...
Hi, How do i call a function of a child class from parent class? Consider this: class whale { function __construct() { // some code here } function myfunc() { // how do i call the "test" function of fish class here?? } } class fish extends whale { function __construct() { parent::construct(); } function...
Hi I have been programming in Java for the past 2 years and now i want to get into Designing applications. So far i am only into coding ie; i am given design document/class diagram etc and asked to code. Now i want to learn how to design, i mean i want to lean when should a class be interface not a concrete class, coming up with design g...
When designing classes you usually have to decide between: providing a "full" constructor that takes the initial values for all required fields as arguments: clumsy to use but guarantees fully initialized and valid objects providing just a "default" constructor and accessors for all necessary fields: might be convenient sometimes but d...