oop

What does the "static" keyword mean in OOP?

For quite some time, I have been unsure about what the Keyword "Static" does while it is used in OOP. I know that if we define a static variable, the value remains the same through out all instances of that class, what does it do when it is used with class or method. I mean, What is a static method and Static class? On what condition...

How can we get rid of unnecessary inheritance?

Hi All, I have got a question in my finished interview that I wouldn't get the right answer. Assume that we have 3 class, Base, Derivate1 and Derivate 2, Their relations are shown as follow public class Base {...} public class Derivate1 extends Base {...} public class Derivate2 extends Derivate1 {...} Then we found out that Deriv...

Calling member functions from a constructor

I know this question has a similar title to this: C++: calling member functions within constructor? but I am asking a more general question. Is it good practice to call member functions from within a constructor? It makes reading the code easier and I prefer the encapsulation type way of doing it (ie. each block of code has a single obj...

PHP OOP - How to handle authorisation?

I'm building a management system for an idea I have. I'm well versed in PHP (at least enough to do everything I need to do) but I'm not that experienced with using OOP. I use it as much as I can but a lot of the best practices I'm not familiar with so when I do things I worry I'm doing them in the wrong order. For this project I have a ...

Calling Destructor within Object Method in PHP

I have an object that can be used, or eaten, or whatnot in PHP. In any case, it ends up gone. I have an abstract protected method called activate(), which is called by a public method useItem(). Is it possible for useItem() to destroy itself after calling activate()? If not, what is the best way of making sure the item is permanently g...

When should POCO be used in EF4?

We have an ASP.Net MVC2 web site, and are utilizing EF4 for database access, etc. Being new to EF4, we have come across the EF4 POCO concept, however do not fully understand it. In general, I've heard POCO defined as objects "not dependent on an external framework". In the case of EF4, I'm guessing this means that POCO would imply som...

Java generics and inheritance

I have the following abstract classes: public abstract class AbSuperClass1<K,S> { //class definition } and: public abstract class AbSuperClass2<K,S> { public abstract <Q extends AbSuperClass1<K,S>> void method(Q arg); ... } I then have two concrete implementations public class Concrete1 extends AbSuperClass<String, Str...

Object oriented design of collection of objects representing other objects

I made up an example. I have a class class Person { //stuff } Objects of this class are used here and there etc. But I will like to make separate class, that will be responsible for drawing persons. So I will need eg. a location of Person object on the screen. I could inherit from Person: class PersonVis : Person { Point lo...

How to design configurable MVC panels?

I have to make a web application that produces pages that contain panels with different setting configurations for different sites the page is hosted under. For example, SiteA.com has a search panel with 3 select dropdowns and SiteB.com can have a search panel with 4 select dropdowns. Can anyone offer any advice on how I could proceed...

PHP: One giant database class or several smaller classes?

For the current app I am writing I have elected to place all database functionality into a single class, as it allows me to keep the database code away from the business logic and easily replace the database code if we ever have need to switch to another DBMS. However, recently my database class has become rather large (EDIT for info: a...

Looking for an overview: Java Socket Server Operational Code

I am scaling up a socket server written in JAVA using xSockets to support rooms (multiple serving sessions?), and am wondering how to execute multiple server loops at once. I have a room class, that when full needs to execute the application severing code. That is myRoomInstance.run() needs to run to synchronize the clients for the ent...

Turning my inherited classes in an Abstract 'factory' C#

Hi all, I'm not really pro and find my question quite hard to describe, so please ask if anything is unclear: I have an abstract class called BaseDevice. Other devices, as Beacon and Transponder, inherit from BaseDevice. For example the Beacon, it has the BaseClass methods PLUS its own properties and methods. Let's say, the difference ...

PHP/OOP Help - logic and design issue

Hi, I'm going round in circles trying to work out how best to do this, i don't think it should be too difficult but i'm making it that way! In my site, each time a member provides some data, I store it against an Entry for that member. The idea is that members who submit data consecutively from month to month will be rewarded at some sta...

Is casting to an interface a boxing conversion?

I have an interface IEntity public interface IEntity{ bool Validate(); } And I have a class Employee which implements this interface public class Employee : IEntity{ public bool Validate(){ return true; } } Now if I have the following code Employee emp1 = new Employee(); IEntity ent1 = (IEntity)emp1; // Is this a boxing co...

What is the Smalltalk equivalent of Java's static?

What is the Smalltalk equivalent of Java's static fields and methods? IOW, what do the Smalltalkers do when they need class level data and/or methods? ...

What are the key differences between OO in Smalltalk and Java?

What are the key differences between OO in Smalltalk and Java? Please note that I am a Java programmer trying to expand his horizons by exploring Smalltalk. Currently I know almost nothing about Smalltalk except that it's purer than Java. Therefore I'll prefer the answer that shows how various Java concepts map to corresponding Smallta...

What type should I cast to?

I have a form class with a method: IText getSearchField() The IText interface is something implemented by a subclass of JTextField called MyTextField. For reasons beyond my control, I cannot get the control from the form class typed as MyTextField, as JTextField, Component, or anything else in the MyTextField type hierarchy. I am ac...

Superclass and Subclasses in PHP

Consider the following PHP class code class SuperIdea{ . . . static function getById($id){ new SuperIdea(.......); } . . . . } class SubIdea extends SuperIdea{ } The problem I face here is that when I call SubIdea::getbyId($t); the object returned is of type SuperIdea but I would like it to be of SubIdea.Is there any way to achieve...

Shared Object Library with Persistence

Hello Everyone, I have a quick question that I am hoping is fairly simple to answer. I am attempting to develop a shared Employee object library for my company. The idea is to create a centralized database that contains information about our employees (Reporting Hierarchy, Office Locations, General Info, etc) and then create an shared o...

Why put import statements in package?

In AS3, why do we put our import statements in the package statement, and not inside the Class declaration? This is a typical (but rather pointless) AS3 class: package my.foo.package { import flash.display.MovieClip; import flash.events.Event; import flash.events.TimerEvent; import flash.utils.Timer; public class F...