Hello everyone!
I'd like to know if there's a way to access to the class (or its fields) where an object is instantiated. Let's say I have:
def Class1:
def __init__(self):
self.title = "randomTitle"
self.anotherField = float()
self.class2Field = Class2()
and the class whose type will be the class2Field:
d...
Sorry, I am being both thick and lazy, but mostly lazy. Actually, not even that. I am trying to save time so I can do more in less time as there's a lot to be done.
Does this copy the reference or the actual object data?
public class Foo
{
private NameValueCollection _nvc = null;
public Foo( NameValueCollection nvc)
{
...
Hi all,
My question is rather simple and probably already answered, but I can't come up with a search term that gives me an answer. Anyway:
Is there software to design/draw the objects and their connections in a graphical way? I'm working on a project and i'm starting to loose track of all the little things. Is there a piece of softwar...
Possible Duplicate:
Detect if a method was overridden using Reflection (C#)
Is there a way to tell if a method is an override? For e.g.
public class Foo
{
public virtual void DoSomething() {}
public virtual int GimmeIntPleez() { return 0; }
}
public class BabyFoo: Foo
{
public override int GimmeIntPleez() { retur...
Say I have this XML
<doc:document>
<objects>
<circle radius="10" doc:colour="red" />
<circle radius="20" doc:colour="blue" />
</objects>
</doc:document>
And this is how it is parsed (pseudo code):
// class DocumentParser
public Document parse(Element edoc) {
doc = new Document();
doc.objects = ObjectsParser.pars...
I know that title didn't make sense, Im sorry! Its hard to word what I am trying to ask. I had trouble googling it for the same reason.
So this isn't even Ruby specific, but I am working in ruby and I am new to it, so bear with me.
So you have a class that is a document. Inside each document, you have sentences, and each sentence has...
In Ruby on Rails, how is an ActionView object able to access the instance variables of ActionController object (how is view code able to use instance variables that are set inside the controller code)?
...
Is there a manner in which to catch requests to a class which does not exist.
I'm looking for something exactly like __call() and __static(), but for classes as opposed to methods in a class.
I am not talking about autoloading. I need to be able to interrupt the request and reroute it.
Ideas?
...
Gentleones,
I've got a UIImageView that I have in a UIView. This particular UIImageView displays a PNG of a graph. It's important for this particular view controller and another view controller to know what the graph "looks like," i.e., the function described by the PNG graph. These other view controllers need to be able to call a "func...
Hi all
Working my way through the Head First Design Patterns book.
I believe I understand the simple factory and the factory method, but I'm having trouble seeing what advantages factory method brings over simple factory.
If an object A uses a simple factory to create its B objects, then clients can create it like this:
A a = new A(n...
I am trying to override Ruby's <=> (spaceship) operator to sort apples and oranges so that apples come first sorted by weight, and oranges second, sorted by sweetness. Like so:
module Fruity
attr_accessor :weight, :sweetness
def <=>(other)
# use Array#<=> to compare the attributes
[self.weight, self.sweetness] <=> [other.we...
In the below code the Consumer class can access the protected method of Parent class.How is it possible since there is no relation between Parent and Consumer class.Please explain
class Parent {
public void method1(){
System.out.println("PUBLIC METHOD");
}
private void method2(){
Syst...
I am having a problem with my virtual methods in a derived class. Here are my (simplified) C++ classes.
class Base
virtual method accept( MyVisitor1* v ) { /*implementation is here*/ };
virtual method accept( MyVisitor2* v ) { /*implementation is here*/ };
virtual method accept( MyVisitor3* v ) { /*implementation is here*/ };
...
Can you do this in PHP? I've heard conflicting opinions:
Something like:
Class bar {
function a_function () { echo "hi!"; }
}
Class foo {
public $bar;
function __construct() {
$this->bar = new bar();
}
}
$x = new foo();
$x->bar->a_function();
Will this echo "hi!" or not?
...
I'm writing a class that has two objects as private members, one of which is conceptually referenced by the class, and the other is conceptually owned by the class. However, the code itself gives no clue that this is the case.
public class WorklistSearchResults
{
//This is "owned" and will be disposed
private RecordSet ...
I've used procedural for sometime now and trying to get a better understanding of OOP in Php. Starting at square 1 and I have a quick question ot get this to gel. Many of the basic examples show static values ( $bob->name = "Robert";) when assigning a value,
but I want to pass values... say from a form ( $name = $_POST['name']; )
clas...
I find that I write a lot of code within my classes to keep properties in sync with each other. I've read about Events in Classes, but have not been able to wrap my head around how to make them work for what I'm looking for. I could use some advice here.
For example, in this one I always want to keep myColor up to date with any change w...
what's the General difference between structural program and object oriented program?? what OOP offers??
thank you all
...
Hello,
Suppose I have 3 classes as follows (as this is an example, it will not compile!):
class Base
{
public:
Base(){}
virtual ~Base(){}
virtual void DoSomething() = 0;
virtual void DoSomethingElse() = 0;
};
class Derived1
{
public:
Derived1(){}
virtual ~Derived1(){}
virtual void DoSomething(){ ... }
virtual v...
I haven't coded in java for a long time, and after coding in C, I'm having issued organizing my code for OOP. More specifically I'm not sure when to create a new method, and when to create a new class, and when to just lump everything together.
Are there some general rules or guidelines on how it should be done?
...