oop

Data Access Layer design patterns

Hello, I have to design a Data Access Layer with .NET that probably will use more than one database management system (Mysql and Sql Server) with the same relational design. Basically, it has to be simple to switch from one database to another so I would like you to recommend me some web-sites or books that has been useful for you, with...

Calling the overridden protected method of a class higher up in the hierarchy

Consider the following classes in Java class A { protected void methodA() { System.out.println("methodA() in A"); } } class B extends A { protected void methodA() // overrides methodA() { System.out.println("methodA() in B"); } protected void methodB() { } } public class C extends B // ...

Dealing with multiple-inherited constructors in Moose

Greetings, I'm learning Moose and I'm trying to write a CGI::Application subclass with Moose, which is made difficult by the fact that CGI-App is not based on Moose. In my other CGI-App subclasses, I like to have a parent class with a setup method that looks at the child class's symbol table and automatically sets up the runmodes. I f...

Accessing parent properties and overridden methods in PHP

I have parent and child classes as follows: abstract class ParentObj { private $data; public function __construct(){ $this->data = array(1,2,3); var_dump($this->data); $this->method(); } public function method(){ echo "ParentObj::method()"; } } class ChildObj extends ParentObj { p...

Instantiating child classes from parent class (PHP)

I have a class with a factory-pattern function in it: abstract class ParentObj { public function __construct(){ ... } public static function factory(){ //returns new instance } } I need children to be able to call the factory function and return an instance of the calling class: $child = Child::factory(); and prefe...

Turning off inline constructors with MooseX::Declare

Greetings, As a followup to my previous question about Moose, I've now run into a new problem. I've got a Moose class which uses Recipe 12 in order to extend a non-Moose parent class. Here it is: package MyApp::CGI; ### TODO: make this work with MooseX::Declare? use Moose; extends 'CGI::Application'; sub new { my $class = shif...

Passing Files as Parameters

Hello. I have created an example to introduce my question. public class Algorithm { // This is the best, but circumstances prevent me from doing this. /*public static void computeSomething(Data data) { // Compute some stuff }*/ public static void computeSomething(DataFileReader reader) throws IOException {...

Is there any full aspect-oriented programming language?

When I say "full" I mean a language that's not an extension to some already existent language like Java or C++. When OOP started it begun with extensions for procedural languages like C and Pascal. Is there any Aspect-Oriented programming language "by itself"? ...

Object doesn't do anything after instantiation - bad code smell?

Hi, I should probably know things like this by now - but for some reason this one passed me by! I have an object that I instantiate - it's quite nifty as it also extends a superclass and does some stuff in the contructor - in fact all the vital parameters and method calls are handled in the constructor. After this I never call the o...

Object.DoSomething() vs DoSomethingWith(Object)

This may simply be a matter of preference, however, I am interested to know what is the best-practise way of when to use either approach. e.g. var person = new Person(); person.Run(); as opposed to var person = new Person(); Excercise.Run(person); The above example may not be the best, but my general point is when should you decid...

How do I handle combinations of behaviours?

I am considering the problem of validating real numbers of various formats, because this is very similar to a problem I am facing in design. Real numbers may come in different combinations of formats, for example: 1. with/without sign at the front 2. with/without a decimal point (if no decimal point, then perhaps number of decimals can ...

Sharing Static Data Outside of the Class

Hello. First, here is a motivating example: public class Algorithm { public static void compute(Data data) { List<Task> tasks = new LinkedList<Task>(); Client client = new Client(); int totalTasks = 10; for(int i = 0; i < totalTasks; i++) tasks.add(new Task(data)); client.submit(tasks); } }...

Persisting the fact that a Tree has Apples

If I have a Tree that has Apples, how should I model the fact that the Apples are had by Tree. Consider that there would be 3 database tables: tree, apple, tree_apples. It seems to me that there would be a AppleDecorator class so that Tree can have multiple AppleDecorators and call ->save() for each one which would write the associatio...

How would I control this textgame and how would the classes get a better structure to do this?

If i have a textgame that has a world object that has objects of type room which has objects of items and enemies and then a gamehelper object that has user objects for the actual player. (this game doesn't have wandering enemies since that would complicate my question to much for me :-)) How should I go about either killing an enemy or...

Object Attribute in Random List Not Accessible in Python

Hello. I'm working on my first object oriented bit of python and I have the following: #!/usr/bin/python import random class triangle: # Angle A To Angle C Connects Side F # Angle C to Angle B Connects Side D # Angle B to Angle A Connects Side E def __init__(self, a, b, c, d, e, f): self.a = a self.b = b self.c ...

How does an object reference itself in Lua?

C# has this and VB has ME. What is the Lua equivalent? I am trying to reference the parent of the script class in Roblox. ...

Oh, virtual, new,... modifiers in c# have different rules....so what is the best way or best-practices for learning OOP rules and use them easily...?

I found C# very interesting...but unfortunately (or fortunately ! ) it has many features to implement OOP rules....they have different machanisms and make me sometimes confused.... so what is the best way or best-practices for learning OOP rules and use them easily...? ...

Casting as sub-class in Actionscript

I have the following classes in ActionScript: public class A { } public class B extends A { } and these variables (in another class): public var InstanceOfA:A; public var InstanceOfB:B; How do I cast an instance of A as a class B? I tried: InstanceOfA = new A(); InstanceOfB = InstanceOfA as B; trace(InstanceOfB); I get an obj...

Should tag system interact with data logic or business logic?

I have introduced tag system for convenient and quick search in my hobby project. The question is whether this system must interact and search through business-logic objects or data-logic ones? I think the first option will be much more flexible, so I can change data-logic independent from changes in tag system. ...

Standard Entitlements Model

I am currently building a Java financial application that I need to add entitlements to, and was wondering what approaches people have taken to solve this problem, and whether there are any third party Java libraries that people would recommend. Currently I have a number of users that can be broadly categorised into roles (e.g. "trader"...