Using C#, is there any overhead in having one larger object containing a whole lot of string variables - half of which are never used in the same instance, instead of 2 objects containing half the number of string variables in which all variables will be used in all instances?
My question might actually be: what overheads are there in h...
Possible Duplicate:
C# member variable initialization; best practice?
In C#, is it better to initialise a variable at the time of declaration, or within a constructor?
eg.
public Foo{
Bar b = new Bar();
public Foo() { }
}
OR
public Foo{
Bar b;
public Foo() { b = new Bar(); }
}
...
So, I know that the general idea in PHP is that the whole application is loaded and executed every time the page loads. But for optimization of a sizable object-oriented PHP app that needs to be portable…is it possible to load an object into memory that can be used for every request, not recreated for each one?
I've seen people using th...
What is the best way to store complex models in ZF? In the example below, should each attribute be a separate model entirely, or should the item be a multi dimensional array (as shown below)?
object(Application_Model_Item)#79 (4) {
["_id":protected] => int(45)
["_name":protected] => string(5) "Bolts"
["_description":protected] =>...
I know this maybe simple and I know the code I am posting is wrong but I am getting close I think.
I am wanting to get the function below from the file pageDAL.cs to return the object page with the values for whatever pageID I pass in. If I do not need to use a DataSet or DataTable that is fine. What is the best way?
public page g...
I am getting into OOP and I run into the following dilemma. I have the a class:
class Recipe {
var $title;
var $time;
var $ingredients = array();
var $instructions;
var $category;
function __construct($title, $time, $ingredients, $instructions, $category) {
$this->title = $title;
...
}
...
In order to keep my code clean and organized, I split my classes up into a bunch of different files and folders, here is what a typical project structure will look like for me:
> Project
__init__.py
main.py
ui.py
> lib
foo.py
bar.py
In my ui.py file, I usually define some sort of info function if the ap...
I came across the following piece of code during a code review.
My intuition is telling me that this isn't following proper OOP.
I'm thinking that instead the LoadObject method should return a new SomeObject object, instead of modifying the one passed into it. Though I can't really find a proper explanation of why this is better.
Is ...
Ok I have some code that boils down to a pattern like this
class Foo(object):
def get_something1(self):
# in the actual code it asks a web server but here I replaced that with "foo_something1" instead of the code from a web server
self.something1 = "foo_something1"
def get_something2(self):
# needs the result of get_someth...
Why is Java the most used programming language ? Why are the most programmers jobs for Java ?
Don't get me wrong here ? I like Java and I work in Java ? I don't have anything against it ?
Also, I'm trying to learn some other stuff out of the OOP box, like Clojure with its functional programming.
But, I'm wondering, why is Java number...
I want this code to "just work":
def main():
c = Castable()
print c/3
print 2-c
print c%7
print c**2
print "%s" % c
print "%i" % c
print "%f" % c
Of course, the easy way out is to write int(c)/3, but I'd like to enable a simpler perl-ish syntax for a configuration mini-language.
It's notable that if I ...
Disclaimer: In this question tab, page, an dialog actually mean the same thing, sorry. My excuse: I am not sure what the final product should look like - a bunch of separate windows or all in one.
I am looking to improve an existing, hard-to-maintain Wizard baked with WinForms. I need to try to keep the look and feel about the same, but...
Sometimes, I felt method overloading may create confusion.
class a {
public:
void copy(float f);
void copy(double d);
};
a me;
me.copy(1.2); // Not obvious at the first sight on which version we are calling.
A workaround on this is.
class a {
public:
void copyFloat(float f);
void copyDouble(double d);
};
How...
Hi all, i know this question has been already asked, but i didnt get it quite right, i would like to know, which is the base one, class or the type. I have few questions, please clear those for me,
Is type the base of a programing data type?
type is hard coded into the language itself. Class is something we can define ourselves?
What i...
So I think I have a pretty basic question. Say there's an open source Java program called com.cow.moo that you include in your project com.bee.buzz.
moo has a bunch of great classes, most of which you don't want to touch, but there are a couple you do. Now at this point, the best thing to do would be to extend the classes you want to mo...
In VC++, how to find the parent or the Class which it belongs to on the Debug mode using the Watch Window?
...
i have something like this
class A {
virtual void doBla(A *a) = 0;
};
class B : public A {
virtual void doBla(B *b) { // do stuff ;};
};
and i want to do something like
A* a = new B();
B* b = new B();
a->doBla(b);
or: all children of A are supposed to have a method doBla which takes a parameter of the type of the child. ...
OOP is probably the most used programming paradigm in today's software design. My question is -- what other paradigm(s) can compete with it and can stand in the place of oop? To clarify that question, I'm not asking about what other paradigms there are. There are many of them and I'd like to know which one:
Has been used in practice, n...
Possible Duplicate:
Language for non-programmers to start learning programming
Hi, I'm 12 years old, I live in Poland, and I would like to start programming. What programming language (object oriented) would you suggest for the beginning, I'm not interested in visual basic.
...
I'm working with classes in PHP. When I'm writing a class, I'm always thinking "This object is basically a one-off; it's not going to last beyond the page load." Consequently, all the logic in my classes basically construct themselves, do a few state changes, give some feedback, and die. Brine shrimp.
Because of this, I've taken to usin...