oop

Business Object desgin

I have a question about how I setup my BO's. I setup the BO's to contain all of my properties of the object as well as the business logic to satisfy the business rules. I decided to make all of the methods static, but I'm not sure if that was the right decision. Someone told me to split my BO's into an Entity Object of just properties...

Workaround for abstract attributes in Java

In Scala I would write an abstract class with an abstract attribute path: abstract class Base { val path: String } class Sub extends Base { override val path = "/demo/" } Java doesn't know abstract attributes and I wonder what would be the best way to work around this limitation. My ideas: a) constructor parameter abs...

How to achieve interaction between GUI class with logic class

Im new to GUI programming, and haven't done much OOP. Im working on a basic calculator app to help me learn GUI design and to brush up on OOP. I understand that anything GUI related should be kept seperate from the logic, but Im unsure how to implement interaction between logic an GUI classes when needed i.e. basically passing variables ...

Creating an object relational schema from a Class diagram

Hi Ladies and Gents. I'd like some help converting the following UML diagram: UML Diagram The diagram shows 4 classes and is related to a Loyalty card scheme for an imaginary supermarket. I'd like to create an object relational data base schema from it for use with Oracle 10g/11g. Not sure where to begin, if somebody could give me a ...

Is it bad OOP practice to have objects reference each other?

Pardon my noobness. I'm making a game in which several characters have relationships with each other and they need to be able to interact with each other and store some relationship data regarding how they feel about each other. I have an object for each character. Is it bad for each of those character objects to have an array of all ...

C++ class derivation and superconstructor confusion

Hey, in a tutorial C++ code, I found this particular piece of confusion: PlasmaTutorial1::PlasmaTutorial1(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), // <- Okay, Plasma = namespace, Applet = class m_svg(this), // <- A member function of class "Applet"? m_icon("document") ...

Can a Simple Model just Extend Zend_Db_Row (essentially Active Record)?

I know Domain Models and Data Mappers are the OOP snob's choice (using 'snob' in a complementary way, as Martin Fowler calls himself one) - however, even Fowler says in POEAA that "Active Record is a good choice for domain logic that isn't too complex..." I have a simple product and invoice domain model, not too many tables/objects...

Detect if an object property is private in PHP

I'm trying to make a PHP (5) object that can iterate through its properties, building an SQL query based only on its public properties, not its private ones. As this parent object method is to be used by child objects, I can't simply choose to skip the private properties by name (I won't know what they are in the child objects). Is the...

A Question on Encapsulation.

Hi, I know that encapsulation is binding the members and its behavior in one single entity. And it has made me think that the members have to be private. Does this mean if a class having public members is not following 100% Encapsulation rule? Thanks ...

Idea for a small project, should I use Python?

I have a project idea, but unsure if using Python would be a good idea. Firstly, I'm a C++ and C# developer with some SQL experience. My day job is C++. I have a project idea i'd like to create and was considering developing it in a language I don't know. Python seems to be popular and has piqued my interests. I definitely use OOP i...

Design issue when having classes implement different interfaces to restrict client actions

Let's say I'm defining a game class that implements two different views: interface IPlayerView { void play(); } interface IDealerView { void deal(); } The view that a game sees when playing the game, and a view that the dealer sees when dealing the game (this is, a player can't make dealer actions and a dealer can't make play...

Inheriting database connection in PHP OOP

My abstract class Database is made for database interaction and any child of this class (UserDatabase, ActionDatabase, EventDatabase) inherits its database connection which is defined as static. abstract class Database { public static $connection; public function __construct( ) { ... $this->connecti...

OO Design for communication methodology that will change

I am on a project where I will be creating a Web service that will act as a "facade" to several stand alone systems (via APIs) and databases. The web service will be the sole method that a separate web application will use to communicate with these external resources. I know for a fact that the communication methodology of one of the AP...

How do I write a writer method for a class variable in Ruby?

I'm studying Ruby and my brain just froze. In the following code, how would I write the class writer method for 'self.total_people'? I'm trying to 'count' the number of instances of the class 'Person'. class Person attr_accessor :name, :age @@nationalities = ['French', 'American', 'Colombian', 'Japanese', 'Russian', 'Peruvi...

Dizzy-like game level representation (format)

How would you store game level for a Dizzy-like adventure game? How would you specify walkable areas and graphics? Is it tile-based, pixel-based or walkable surfaces can be described by vectors? ...

disadvantages of builder design pattern

What would be the disadvantages of using the builder design pattern. Are there any?? edit - I want to know whether there is any bad consequence of using builder design pattern? As in the GOF book, they have mentioned the good and bad consequences of design patterns. But they haven't mentioned any bad consequence for builder design patte...

how can I get around no arrays as class constants in php?

I have a class with a static method. There is an array to check that a string argument passed is a member of a set. But, with the static method, I can't reference the class property in an uninstantiated class, nor can I have an array as a class constant. I suppose I could hard code the array in the static method, but then if I need to c...

nesting classes in php

here is my sample class to why i want to nest. include("class.db.php"); class Cart { function getProducts() { //this is how i do it now. //enter code here`but i dont want to redeclare for every method in this class. //how can i declare it in one location to be able to use the same variable in every method? $db = new mysqlDB; $que...

Can can I reference extended methods/params without having to cast from the base class object returned

Hi, Is there away to not have a "cast" the top.First().Value() return to "Node", but rather have it automatically assume this (as opposed to NodeBase), so I then see extended attributes for the class I define in Node? That is is there a way to say: top.Nodes.First().Value.Path; as opposed to now having to go: ((Node)top.Nodes.Fir...

Is this bad Object Oriented Design? (derived class used in base class)

Hello, Can someone tell me if this class structure is bad? class abstract Parent{ public Child Foo(){ return new Child(); } } class Child : Parent{} I've heard that referring to a derived type from a base type is always bad and signs of bad design. Can someone tell me why this is bad or even if it is bad? ...