oop

How do you name your "reference" implementations of an interface?

Hi StackOverflow! My question is rather simple and the title states it perfectly: How do you name your "reference" or "basic" implementations of an interface? I saw some naming conventions: FooBarImpl DefaultFooBar BasicFooBar What do you use? What are the pros and cons? And where do you put those "reference" implementations? Curren...

(Java newbie) Instantiating unknown number of objects

Java/OO newbie question: main instantiates Track class. Now I want that object--track1--to instantiate many Clip objects, the number of which will not be known until runtime. From inside the Track class I can make a new Clip like this: Clip clip1 = new Clip(); // this is track1.clip1 from main But when I want to add more clips based...

Object Oriented Design Interview Question

Any advice on solving this problem? ...

Thought I understood static classes

Trying to construct a helper class that will return an arraylist, but I'm getting the following error, having to do with the xml document I need to create: Util.oDocument': cannot declare instance members in a static class I think I understand why you wouldn't want to create a new xmldoc object each time this method gets called, bu...

interface vs abstract class

In php :: Please explain when i should use interface and when i should use abstract class? And how i can change my abstract class in to an interface? ...

Why does my method print "isObjectName=SCALAR(0x1289df0)"?

New to OOP with Perl, and just had a quick question. I have this function in a class: sub Print{ my $text = shift; print "my text is", $text; } I try to print the text out, by doing this: my $object = ObjectName->new(); $object->Print("Print this text") It prints this: my text isObjectName=SCALAR(0x1289df0) My question is...

Do I need to use a class to use its methods in my subclass in Perl?

Alrighty, coding in Perl and just had a quick question. I have class created called SubtitleSite which is basically an abstraction, and a class called podnapisi that inherits SubtitleSite like this: @ISA = qw(SubtitleSite); My question is, do I have to use: use SubtitleSite; in order to have access to all the methods in SubtitleSit...

Java NullPointerException When I call a method on a custom class

I get a null pointer exception when a call a method on a custom class. I do not see why my object p of class Player is null. (Player is a class of Players of my game) play is the method. This class should create n number of p objects of the Player class and run the play method on them. import java.util.*; public class PsychicGameMore ...

abstract method override in Derived class, how to make private

Hi I have a class "A" with as abstract method protected abstract List<Contributor> GetContributors(List<SyndicationPerson> contributersList); I want to override this method in derived class "B" with following conditions It should be private to B class. compiler does not allow me to declare this Method as private in derived class "...

Hobbyist - Developer Book Recommendations

It will be a gift for a family member. He's older, a retired school teacher and likes to tinker with programming mostly as a mental exercise to stop the old brain cells from gelatinizing. I've seen him make some pretty creative and moderately complex games in BASIC (QBASIC to be precise), and I believe he's making the hop to VB.NET this...

Erlang (Functional Programming) vs Object Oriented Programming in terms of thinking

I am learning Erlang and I am trying to create a very sample blog program. However my mind currently is trapped in the OO world (var p = new Post(); p.Title = ""; p.Save();). I would like to understand some basic thinkings in Erlang. Instead of creating Post object what I should do in terms of data structure (p.Title, p.DateCreated, p.Bo...

order and sub order

Hello, I have an already existing order class with many properties and methods. I need to now create a suborder class which is a subset of the order class. It not only has many of the fields that order class has, it also would have many of the same calculation methods maybe with one or two lines of difference in some places. The orde...

What happens at this object Initialization?

I do an object initialization as done in the code below: namespace PatternPractice { public class TestClass { private DecoratorClass decoratorClass; public TestClass() { } public void addTest() { decoratorClass = new DecoratorClass(); testMethod(decoratorClass); } public void testMeth...

Reflection or Dynamic Dispatching

I'm writing a abstract file parser (C#) which is extended by two concrete parsers. Both need to perform several checks. Currently there is a validate method in the abstract parser, which uses reflection to call all methods with a name starting with 'test'. That way adding checks is as easy as adding a method with a name that starts with ...

Should I ever use Enums as discriminators?

When do Enumerations break down? To support a new feature in an existing system, I was just considering implementing some form of discriminator to an entity table in my database schema. In wanting to begin by doing the least thing that will work I first of all decided on an integer column and a C# enum at the business entity layer fo...

OOP: When is it an object?

I'm trying to understand object orientation. I understand it a little bit of course, but sometimes I'm not 100% clear. How do you decide what should be turned into an object (small object part of another big whole object) or what is not worth being an object, or maybe it should be just a property of that big whole object? For a door, I...

DAO/Repository/NHibernate And Handling Edge DB Cases

One thing that keeps stumping me, and I do not see much mention of it in books/blogs, is how to handle DB operations in a system that really don't fall under the jurisdiction of DAOs or Repositories. I like using the approach of generic DAOs/Repositories to handle common DB operations, but what about dealing with things that aren't entit...

Is using __PACKAGE__ inside my methods bad for inheritance?

If inside my code I'll have calls like: __PACKAGE__->method; will this limit the usability of this module, if this module is inherited? ...

Python - Exists a function that is called when an object does not implement a function?

In Smalltalk there is a message DoesNotUnderstand that is called when an object does not understand a message (this is, when the object does not have the message sent implemented). So, I like to know if in python there is a function that does the same thing. In this example: class MyObject: def __init__(self): print "MyOb...

What is so special about Smalltalk?

In every technical publication, and on this site too, people are always comparing OO languages to Smalltalk. My experience is in Java: is Smalltalk so important that I should study it? ...