Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
0
votes
1 answer
Intercepting method progression based on condition checked by parent class
This is a very basic architectural question and it is thus very hypothetical.
Imagine this simple setup:
I have a class representing a web object, with only one method that renders the object. However, this class extends a parent class which…

SquareCat
- 5,699
- 9
- 41
- 75
0
votes
1 answer
Designing a Window class
I'm planning out a design for my Window class. The goal is to provide an abstraction for creating a platform agnostic window ready for OpenGL rendering. I'm thinking of having a class 'Window' be the public interface, and a 'WindowImpl' class handle…

user2941616
- 117
- 2
- 11
0
votes
6 answers
Global variable without having to redeclare every function?
I want to have access to a global variable without having to redeclare every function. Here is an example.
$mobile = 1;
class Database
{
private $connect;
function one($argumentarray)
{
global $mobile;
echo $mobile;
…

user892134
- 3,078
- 16
- 62
- 128
0
votes
1 answer
MVC Game Design Java
I try to create a simple game in Java with the Model-View-Controller pattern.
My currently implementation is that
Model
Country
Timer
Observable
Money
Observable
contains Map < Country,Integer>
increases Money on update from…

user547995
- 2,036
- 8
- 33
- 62
0
votes
1 answer
Flex: Forcing an array to contain only a specific class?
I'm trying to create a class that contains an array. However i want to require that the items in the array are themselves of a specific class. Im told there is some sort of tag you can add to do this, but for the life of me i cannot find what it is.…

zak kus
- 41
- 1
- 5
0
votes
2 answers
Resolve a filename from another file
I can currently to the following:
class SubClass extends SuperClass {
function __construct() {
parent::__construct();
}
}
class SuperClass {
function __construct() {
// this echoes "I'm SubClass and I'm extending SuperClass"
echo…

Henrik Paul
- 66,919
- 31
- 85
- 96
0
votes
4 answers
Events or abstract methods, best practices
A subclass needs to know when particular events occur withing its superclass, but there are more than one ways for the superclass to break the news. Here are 2:
dispatch an event
call an abstract method which the subclass could eventually…

Emanuil Rusev
- 34,563
- 55
- 137
- 201
0
votes
2 answers
Class design - where to put certain methods?
For an assignment I have to create a song/playlist organising program.
The song/playlist have the obvious members + constructors & getters/setters, and the driver reads from 2 files & creates an array of songs, and an array of playlists. (I can't…

Amir
- 2,082
- 4
- 22
- 28
0
votes
1 answer
Using constant fields vs initial data
I'm designing some new class diagrams for extending an existing office automation application. In a special case I have an option to use extra fields on Entity1 to determine something or use additional data rows in Entity2 to determine that. I…

Afshar Mohebi
- 10,479
- 17
- 82
- 126
0
votes
5 answers
Accessing a function in a class from other classes
What I want to do is access the query function in my database class form anther class. Evey time a query is done I track the time it takes and add the the query count, I want to do that for all query's.
The layout I have now is:
…

Scott
- 3,290
- 4
- 29
- 48
0
votes
2 answers
C++ Singleton/Active Object Paradigm
I was wondering how you would make a class where you create several instances i.e
Session o1 = new Session();
Session o2 = new Session();
You could then make these sessions the active session like…

James Campbell
- 3,511
- 4
- 33
- 50
0
votes
1 answer
Class Design - The responsibilities for the classes
Say, I have 2 classes which are Audio and AudioManager. My question is, should these functions
void Play();
void Resume();
void Pause();
void Stop();
void Load();
be within Audio class or AudioManager?
Well, what I did is put them all into…

Xeon
- 246
- 3
- 15
0
votes
6 answers
Standalone functions in ASP.net
Never seen this done in asp.net, but never the less, can I define functions without being part of the class?
What I would like to have is a utility library. Currently I have Utils class and every time I need to use it for things like populating…

sarsnake
- 26,667
- 58
- 180
- 286
0
votes
1 answer
Distributed updating of object collections
My objects structure in a current program is organized so that a Doc object contains a list of Mention objects, and each Mention object contains a list of Word objects. Words are identified by their position in the Doc's text and also store some…

ramcrys
- 643
- 4
- 14
0
votes
4 answers
Visual Studio 2008 Class Designer - associations
We are attempting to use VS2008 Class Designer for a UML-like class diagram. However, when we create an "association" link between two classes, VS2008 is adding lines to our code! We do not want this.
One reason we don't want this is that our…

alchemical
- 13,559
- 23
- 83
- 110