Hi all,
This is most certainly a language agnostic question and one that has bothered me for quite some time now. An example will probably help me explain the dilemma I am facing:
Let us say we have a method which is responsible for reading a file, populating a collection with some objects (which store information from the file), and t...
I have a class R00_Model_User, which, curiously enough, represents user as he is. Can $result->getIdentity() return me an object of this class? (Or maybe it's stupid?)
(There is a factory method in R00_Model_User which prevents from duplicating objects. I'd like Zend_Auth to use it instead of creating a new object, if it can)
...
So I want to be able to add/remove class methods at runtime. Before you tell me that's horrible pratice in oop, it might be, but I don't really care. The reason I want to be able to do this is because I want the application to be very modular, so some plugin could extend some base class and add methods to it without killing the the main ...
class Vehicle {
public int wheels;
public int lights;
}
class Car extends Vehicle {
public int wheels =4;
public int lights =2;
public void lights_on( int lights){
//Code to onlights
}
}
class BMWCar extends Car {
public int wheels =4;
public int lights =4;
}
public class TestCar {
public static void ma...
i need to write code for two "robots" that will chase each other around the screen ive managed to do most of it but what i need help with is the getName() command which returns the name of the robot (as a string) which will be overridden in the subclass.
can anyone help as im new to python and havnt done this before
...
Why the examples about hibernate use SessionFactory interface instead SessionFactoryImpl class to open a session on the given connection?
...
I am working on a sort of "bug finder" for Scheme (R5RS) and I want to try if and how well it would work for object-oriented programming. Therefore I was looking at some of the numerous object systems for Scheme (for example, Tiny-CLOS, Prometheus, and YASOS).
Of course, in order to find bugs, I have to have code in which I can search t...
I have a foolish doubt.Generally "System.Object" implements "Equals". When I implements
IEquatable interface i can give custom definition ( I believe so) to my "Equals".
so the professor class implementation is equal to
class Professor:System.Object,IEquatable
since there are different definitions of System.Equals ,and IEquatabl...
I would like to keep this one short. I build a HouseA that has two rooms, say BedRoom and StudyRoom, both deriving from a base class called Room.
BedRoom and StudyRoom have a same parent called House. Also, any room in a house can access any other rooms only through the parent. If BedRoom has to access any attribute of StudyRoom, it has ...
Hi
I would like to become really good at programming and in particular java and OO
The catch is, that while I like programming and I work as a programmer, I'm not really passionate about being a programmer or programming in general.
This leads to not feeling like doing any dev outside of work, which means that I rarely learn anything ...
In this text I read
Be alert for a component that is just
a glorified responsibility. A
component is supposed to capture an
abstraction that has a purpose in the
system. It may happen that what
appears at one moment as a meaningful
component is really just a single
responsibility left on its own. That
responsibility c...
Is there anyway to discover the base class of a class in Python?
For given the following class definitions:
class A:
def speak(self):
print "Hi"
class B(A):
def getName(self):
return "Bob"
If I received an instance of an object I can easily work out that it is a B by doing the following:
instance = B()
print B.__c...
I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time). I thought I'd write a simple check register program as an exercise. I put something together pretty quickly (python is a great language), with my data in some global variables...
Hi,
I have a class as follows :-
interface IFilterCondition
{
List<Name> ApplyFilter(List<Name> namesToFilter);
}
class FilterName : IFilterCondition
{
public NameFilterEnum NameFilterEnum{ get; set; }
public List<Name> ExcludeList { get; set; }
public char StartCharacter{ get; set; }
#region IFilterCondition Me...
I've read and understood the Head First OO books, including Design Patterns. I've read through the DP book a couple times now, and I really feel like I not only understand the patterns, but also have a pretty good "armchair-coder" grasp of why the patterns are the way they are...like why this pattern uses an interface or why that patter...
Hi,
This is a design question : when do I need to create/use a static method (in a domain class for instance) and when do I need to create/use a service instead? What is the difference between them ?
Thank you.
...
I've recently seen some code similar to that outlined below.
public void someMethod() {
Lecture lect = createLecture();
...
lect.getLectureSeries().delete();
}
public Lecture createLecture() {
LectureSeries series = new Series();
Lecture lect = new Lecture(series);
...
return lect;
}
The point being that some objec...
In JavaScript, I want to create an object instance (via the new operator), but pass an arbitrary number of arguments to the constructor. Is this possible?
What I want to do is something like this (but the code below does not work):
function Something(){
// init stuff
}
function createSomething(){
return new Something.apply(null...
I'm using the delegate pattern for one of my objects. My idea is that I will be able to swap the delegate out later for a different delegate implementing a different strategy. I suppose this is just as much the strategy pattern as the delegate pattern.
My question is, is it bad practice for my delegate to have a reference back to the ...
(Leaving aside the question of should you have them at all.)
I have always preferred to just use function overloading to give you the same name for both getter and setters.
int rate() { return _rate; }
void rate(int value) { _rate = value; }
// instead of
int getRate() { return _rate; }
void setRate(int value) { _rate...