I've been playing mostly with PHP and Python.
I've been reading about Interfaces in OO programming and can't see an advantage in using it.
Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well?
Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I ...
Exactly what happens when Foo.SomeCheck() is called in the Bar class? Is an instance of Foo created in order to call SomeCheck()? If so, is this instance stored on the heap, and is it ever collected through garbage collection?
public class Foo() {
public static bool SomeCheck() {
return true;
}
}
public class Bar() {
...
Hi, I made an PHP OOP Cart Class like this
print_r($_SESSION["cart"]);
the result is:
Array ( [1] => 1 [3] => 2 )
How can I print this session, like a "real" cart?
example:
echo "Your basket: ";
echo "ItemID: ".$cartid." Itemnumber:".$cartnumber;
The adding to basket part:
if (isset($_POST['submit']))
{
$cart= new Cart(...
Sorry for the vague title, but I wasn't sure how to summarize this in one phrase. I have a situation with a lot of redundant C# code, and it really looks like some kind of crafty trick using some property of inheritance or generics would solve this. However, I'm not a terribly experienced programmer (particularly with C#) and just can't ...
I have a class that creates the object of type Smo. The object then calls a static method from another class. The static method requires that I pass the object to it that is calling it. How do I designate the calling object as the parameter to pass.
For example:
class Smo {
Smo() {
}
void sponge() {
car.dancin...
Possible Duplicate:
Pitfalls of Object oriented programming
I recently had an argument with a friend who believed that every application should be designed in an OOP manner. I know that there are definitely applications where OOP would not fit well over the design but could not think of any specific example. Can someone give m...
What I would like to do, is create a folder, where people can put in a file for testing, and have pyunit automatically expand in order to run the test as a separate test. Currently, what I'm doing is:
class TestName(unittest.testcase):
def setUp(self):
for file in os.listdir(DIRECTORY):
# Setup Tests
def te...
I just spent too long on a bug like the following:
>>> class Odp():
def __init__(self):
self.foo = "bar"
>>> o = Odp()
>>> o.raw_foo = 3 # oops - meant o.foo
I have a class with an attribute. I was trying to set it, and wondering why it had no effect. Then, I went back to the original class definition, and saw that the a...
From what I have experienced it seems as if objects cannot be shared data members in objective c. I know you can init a pointer and alloc the object in each method but I cannot seem to figure out how one can say define a NSMutableString as a data member and allow all of the methods to use and modify its data as in c++. Is this true or am...
Can someone please show me and example of an abstract class in Java? Something with a real world application (rather than a text-book sample) would be preferable.
Thanks!
...
I'm trying to populate a template with variables from a database. The data looks as follows:
id field content
1 title New Website
1 heading Welcome!
1 intro This is a new website I have made, feel free to have a look around
2 title About
2 heading Read all about it!
What I need to do with that data...
Can anybody please put some light on the need of the method "getTypeInstance()", which can be use by any product object?
Also what are the pros & cons of using this method?
...
Is there a name or nickname for a class that only contain attributes (like a c struct)? Like DialogParameters in this example:
public class MyDialog extends JDialog {
public static class DialogParameters {
public String dialogTitle;
public String helpId;
}
public MyDialog(DialogParameters parameters) {
...
}
}
...
Hi
I learning Python (coming from a dotnet background) and developing an app which interacts with a webservice.
The web service is flat, in that it has numerous calls some of which are related to sessions e.g. logging on etc, whereas other calls are related to retrieving/setting business data.
To accompany the webservice, there are ...
Hi,
During destruction of the derived class object, i first hit the derived class destructor and then the base class destructor (which is as expected). But i was curious to find out - at what point does the functions of the derived class go out of scope (are destroyed).
Does it happen as soon as the control leaves the derived class des...
I have a class that is used as a member in many places in my project.
Now, instead of this class I want to have a polymorphism, and the actual object will be created by some kind of factory.
I have to choose between:
Having to change all the places where I use the class - to call the factory and use a pointer instead of object directl...
Hi All,
I am building some material for OOP (object oriented programming) in VBA,
so can anybody list me the OOP concepts which are available in VBA?
for example from my reading I discovered that:
inheritance is not available in VBA !!!
encapsulation concept is there as you can use access modifier "private" and build a public propert...
I have an Order object to represent a Prospective Order/Receipt. This is an entity. It has an identity.
I have a Writer object to read the Order object's properties and display it nicely.
It is a bit of a chore to have individual getters for all the pieces of the Client's Billing Details.
So, I am thinking of letting the Writer object...
Hi,
I am working on design for a resource server. I want to gather some industry best practices on it.
Scenario:
A data driven portal application hosted on a web farm.
Whenever a request comes, controls are rendered and response is sent. For each image on the page, browser requests for the image separately using a webservice. Since ...
I'm looking for a good way to describe OO to beginners, though an analogy.
Currently I'm likening a Class to a shopping list, and a shopping trolley full of items to an object. But I feel it's a bit confusing.
Preferably the analogy would be reflected well in the code example (Ruby), currently I have this, and it feels klunky.
# First...