Hello guys,
I need to design a simple piece of software, and i was wondering the best to do it.
First of all, sorry for the novice question: what is the best way to work with lists? i tried a few times and did not perceived the correct way to instanciate them and how to use them in OOP. Can anyone clear it up for me?
The second questi...
I want to make a singleton class which extends DBI. should I be doing something like this:
use base 'Class::Singleton';
our @ISA = ('DBI');
or this:
our @ISA = ('Class::Singleton', 'DBI');
or something else?
Not really sure what the difference between 'use base' and 'isa' is.
Thanks.
...
There's one specific feature that I wish was in the .NET framework, but isn't. I wish there were a DBDataReader.GetString (or GetDateTime, GetInt32, etc.) overload that accepted the field name instead of the index. Using the field name makes for easier maintenance IMO, but the GetXxx methods only accept the field position.
I can add th...
I have a "best practice" question. I'm developing a OO MVC framework in PHP, and most of the classes interact easily - they are literally declared in the code and used. For instance:
// In class 'getDetails'
$db = new mysqli(.....);
$db->query(.....);
However, there are times when the class and function names are dynamically built. Th...
I thought I'd start learning a real programming language from scratch. I can manage to code in C++, but I haven't been brushing up on my C++ skills at all.
This time I'm teaching myself. And I've decided on python. Is it the right language for me? I'm just being an enthusiastic kid, and I'm not learning for any strict purpose (rather th...
here is my implementation , wonder if there any improvement , or share your ideas.
//* global variable *//
//I put all the variable into $('body');
$base_url = $('body').data('base_url');
$logged_in = $('body').data('logged_in');
//...
//* Object. like namespace *//
lzyy = {};
//* constructor *//
//correspond with mvc's c(controller)
...
When come to create an interface, do u create it based on behavior, follow the -able standard, e.g.
interface Comparable
interface Enumerable
interface Listable
interface Talkable
interface Thinkable
Or based on object, e.g.
interface Comparator
interface Enumerator
interface List
interface Human
And why?
UPDATE
This question is ...
I can't figure out the use for this code. Of what use is this pattern?
[code repeated here for posterity]
public class Turtle<T> where T : Turtle<T>
{
}
...
I am new to programming and am having difficulty with understanding object lifetime / instantiation.
I have a windows from with a datagridview and a panel.
The datagridview has a checkbox column and a list of names which is populated from a database.
The panel has a few text boxes (e.g. name, age, favourite sports team) and a 'save c...
Hello,
I am facing a continuing problem distinguishing delegation, composition and aggregation from each other, and identifying the cases where its best to use one over the other.
I have consulted an java OO analysis and design book, but my confusion still remains. The main explanation is this:
delegation: When my object uses another ...
I want to have a constructor with an argument that gets inherited by all child classes automatically. But Java won't let me do this
class A {
A(int x) {
///
}
}
class B extends A {
}
class C extends A {
}
#Implicit super constructor A() is undefined for default constructor.
I dont want to have to write B(int x) and C(int x) e...
I think I read somewhere that some modules only have object oriented interfaces ( though they didn't create objects, they only held utility functions ). Is there a point to that?
...
Note: I'm relatively new to Objective-C and am coming from Java and PHP.
Could someone explain to me why I always have to first allocate and then initialize an instance?
Couldn't this be done in the init methods like this:
+ (MyClass*)init {
MyClass *instance = [MyClass alloc];
[instance setFoo:@"bla"];
return instance;
}...
I have these two modules :
package G1;
sub new {
my $class = shift;
my $self = {
one => 1,
two => 2,
three => 3
};
bless $self,$class;
return $self;
}
sub three {
my $self = shift;
print "G1 green is ",$self->{three};
}
1;
package G2;
our @ISA = qw(G1);
#use base qw(G1);
sub new {
my ...
How do I make chained objects in PHP5 classes? Examples:
$myclass->foo->bar->baz();
$this->foo->bar->baz();
Not: $myclass->foo()->bar()->baz();
See also:http://www.talkphp.com/advanced-php-programming/1163-php5-method-chaining.html
Thanks.
/Kristoffer :-)
...
Have a base class A, and a derived class B which overrides function template Func:
class A
{
A() {...};
~A() {};
template <class T>
void Func(const String &sInput, T &tResult)
{...}
};
class B : public A
{
B() {...}
~B() {};
template <class T>
v...
I noticed that when you call a superclass's methods, you need to do something like this :
my $self = $class->SUPER::new();
Why isn't that:
my $self = $class->SUPER->new();
...
Hi,
I can't find if it's possible to call a non-static method from a static one in Python.
Thanks
EDIT:
Ok. And what about static from static? Can I do this:
class MyClass(object):
@staticmethod
def static_method_one(cmd):
...
@staticmethod
def static_method_two(cmd):
static_method_one(cmd)
...
Suppose i have the code snippet as follows : ( clarification purpose/not well formed)
class Employee
{
#region fields
protected string _empID;
protected string _empName;
protected readonly string _ssn;
#endregion
public Employee(){}
public Employee(string _empID,string _empName,string _ssn)
{
...
Consider the following nested type:
public class Book
{
private class Chapter
{
}
}
As the chapter type is controlled by Book, is it a means of composition or is it a bad assumption to think composition here?
I am not sure, so to understand this I raised the question.
...