oop

Define inherited class in base class library or new project

I've written a abstract base class TCPIP sever in its own namespace/library. Currently I have the derived class (more specific TCPIP server; with DataHandler) in the .exe project of the solution. I'm almost 100% certain this is how I will go, but part of me wants to put the derived class in the base class project. What are some good r...

About the problems of using the new operator inside a class that'll be Unit-Tested

Intro Currently I have something of the form: Tetris class ---> FallingPiece class ----> Piece class A Piece can be a Square, a T, etc. It has info about its shape and the shapes of its rotations, its size, etc. The FallingPiece class basically contains an attribute with a reference to a Piece (the currently falling piece in the Te...

Python Object Oriented Design with Twisted defereds

My question is about how to design code that works well with object oriented design and asynchronous deferreds (instead of blocking code) Ok two ways I am thinking about designing the class (are any of these good designs or am I forgetting something) First Way class Grooveshark(object): def get_session(self): d = # implementation ...

How to convey the importance/role of application architecture to business heads & junior developers.

Hi there, This question is subjective and can reasonably only be answered by those seasoned developers with leadership experience and management personnel with a sound technical proficiency. For the past year I've pursued educating myself extensively in OOD to become a stronger programmer. In particular, reading and applying knowledge ...

Few OOP design clarifications

I was wondering about few of the below OOP concepts 1) abstract class cannot have final constructor. Why cant subclasses have same same constructor without rewriting them 2) abstract method cannot be private . We can still implement the abstract class in same file. So why not allow this ...

How do people get around subclass init methods needing different numbers of arguments to their super classes?

Imagine I have a game with a base Entity class, with an init method that takes no arguments. Now I have a Wizard class, but I want to pass in 2 parameters, say speed and strength. In AS3 (and I believe Java and C#) I will not be allowed to do this - it is an "incompatible override" because the method signatures won't match. Now I could j...

using mysqli to fetch data

i've been trying my hand at mysqli. using procedural mysql, the code displays the results fine. however, after making the switch to OOP mysqli, i tried converting the code to mysqli, and it says there are no quotes. is there anything wrong with the code? /* the database object */ private $_db; public function __constr...

How do I prevent my unit tests from requiring knowledge about implementation internals when using mock objects?

I'm still in the learning stages regarding unit-testing and in particular regarding mocking (I'm using the PascalMock and DUnit frameworks). One thing I now stumbled over was that I couldn't find a way around hard-coding implementation details of the tested class/interface into my unit test and that just feels wrong... For example: I wa...

oop: Composition or Inheritance in concrete case

We've just had a discussion with college about is the following style acceptable for oop or not. We've a class, which has one public function, and requires a reader in the constructor: public class Converter { private readonly IReader _reader; public Converter(IReader reader) { _reader = reader; } public b...

access a variable of another class via a property

hi all, I have two classes,In classA I create a variable that I need to use in classB , should i use property ? is there anyone to explain me easier ,how to set StringValue of variable in one class to the textfield of another class? thanks ...

Codeigniter objects in views

Hi There, I have started a new project at work today and a fellow developer has asked me to look into changing the way I work and implementing objects into my views to I can do checks within my view using the object. To me this seems wrong, as surely this is the work of the Model and/or controller? Or am I wrong? I assume he is wanting...

mysqli resultset displays null

i'm trying to use mysqli to display data, but it displays nothing. what is wrong with my code? php class: /* the database object */ private $_db; public function __construct($db=NULL) { if(is_object($db)) { $this->_db = $db; } else { ...

Difference between a class and an object in Javascript

What's the difference between var myView = function () { //something goes here }; and var myView = function () { //something goes here return { a: x, b: y }(); I think the first snippet creates a "dynamic" class, so that you can say var anotherView = new myView(); and the second snippet is similar to a sing...

Adding a prototype to an object literal

I have some object, say son, which I'd like to inherit from another object father. Of course I can make a constructor function for father, like Father = function() { this.firstProperty = someValue; this.secondProperty = someOtherValue; } and then use var son = new Father(); son.thirdProperty = yetAnotherValue; but this is not ...

C++ Templates and Subclasses?

So, I'm learning C++, and I've run into something which I know how to do in Java, but not in C++ :). I have a template for a container object, which is defined as such: template <class T> class Container { vector<T> contained; public: void add(T givenObject) { this->contained.push_back(givenObject); } T g...

Coming from a relational database background, how should I model relationships in db4o (or any object database)?

I'm experimenting with db4o as a data store, so to get to grips with it I thought I'd build myself a simple issue tracking web application (in ASP.NET MVC). I've found db4o to be excellent in terms of rapid development, especially for small apps like this, and it also negates the need for an ORM. However, having come from a SQL Server/M...

Overriding inheritance on intrinsic attributes in C#

After wrestling with a bunch of uncaught exceptions when trying to serialize my classes and subclasses, I've finally understood what my problem had been: [Serializable] isn't inherited by subclasses when applied to a base class. I'm still really fuzzy about C# Attributes in general, but I do understand that when creating a custom Attribu...

Storing price in PHP. What is better double or string?

I've been making "Product Object" for my app and I've been setting attributes, when suddenly I got to price attribute and stumbled upon it with question what type better to choose? I understand, that for PHP it doesn't matter so much, but lets say for MySQL it does. Any suggestions? ...

Some questions about abstract class with private, public and protected constructors

My first question: What is the difference between an protected and a public constructor in an abstract class? My second questions: Does it make sense, if the abstract class has an private constructor? Thanks in advance! ...

To bless or not to bless, that is my question!

Hello everyone, first post from a newbie-user. Every question I google seems to bring me here and I always get a great answer to what I'm looking for; so naturally this was my first stop when I began pondering the usage of blessing in Perl. I've just gotten into Perl's OOP and just today read the post asking what bless does. I now under...