Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
0
votes
2 answers
Inheritence Class Design (in Java)
for a small game I want to design two classes which should draw my Units. I have the classes Unit and Settler which extends Unit.
To draw them I have the classes UnitView and SettlerView.
Now UnitView has a method public void draw(Graphics g) and…

Elrond1337
- 424
- 1
- 5
- 16
0
votes
2 answers
How to map foreign key attribute tables to a business entity
I have a table in a database that I'm mapping to a main entity class. The table has some columns that hold foreign key values to other attribute tables.
How do I map these to the business classes? Do I create a new class for every attribute table…

Chris Burgess
- 5,787
- 13
- 54
- 69
0
votes
2 answers
Class Design: Demeter vs. Connection Lifetimes
Okay, so here's a problem I'm running into.
I have some classes in my application that have methods that require a database connection. I am torn between two different ways to design the classes, both of which are centered around dependency…

Mike Hofer
- 16,477
- 11
- 74
- 110
0
votes
0 answers
Class Design Dilemma - Usage of base class to "common out" repeating code in derived classes
I have a lot of Page classes to work with, for my test automation. Each of them has three following essential elements:
WebDriver
Uri
Essential element of that page.
I decided to make a base class for all the page class as follows:
internal class…

bhootjb
- 1,501
- 1
- 21
- 33
0
votes
1 answer
Do you create all object references in the main class or in the appropriate relationship class?
I have my main class PayUnit where I create my main object references, such as touchScreen, scale, and barcodeReader as these are has-a relationships to my PayUnit. This machine also has-a billDispenser but billDispenser is really 'is-a'…

KiloJKilo
- 465
- 1
- 6
- 16
0
votes
4 answers
Which class design is more appropriate - dependency, association, or composition
I have three possible designs and I'm trying to determine which one is better and in which cases they would be better. The general idea of all the designs is that there is a data object that stores some data and there is an analyzer object that…

gsgx
- 12,020
- 25
- 98
- 149
0
votes
2 answers
domain design with nhibernate
In my domain I have something called Project which basically holds a lot of simple configuration propeties that describe what should happen when the project gets executed. When the Project gets executed it produces a huge amount of LogEntries. In my…

bitbonk
- 48,890
- 37
- 186
- 278
0
votes
4 answers
Is it bad practice to only create static methods that take instances of that type
Take this class for example:
public class Account
{
public string Code { get; set; }
public string Description { get; set; }
public DateTime CreatedOn { get; private set; }
public void Create()
{
// Invoke with new…

The Muffin Man
- 19,585
- 30
- 119
- 191
0
votes
2 answers
Parameterized Constructor Cascading
Consider the following situation
class URISplit {
var $REQ_URI;
//some more variables
function __construct($uri) {
//some code
$this->REQ_URI = $uri;
//some code yet again
}
}
and the following
class…

OrangeRind
- 4,798
- 13
- 45
- 57
-1
votes
2 answers
Issue with Call Hierarchy
I have a situation where I am calling function/method in cascading style. See following example for illustration and question. I wish I knew some technical word for this situation. It would be easier for people understand what I am talking about. …

Shai
- 529
- 7
- 20
- 36
-1
votes
1 answer
Does combining composition with association still follow the rules of OOP?
When it comes to class diagrams, can an association or aggregation exist between two objects that are in composition with one base object?
Example:
Class Car has a composition relation with class Engine and class Fueltank. So Car has An Engine and a…

R.H.dev
- 21
- 3
-1
votes
2 answers
How can I do temperature conversion in a class with only one field?
Temperature is measured mainly in three units: in degrees Celsius,
degrees Fahrenheit and in kelvins. It’s easy to convert any of them to
the two others:
Kelvin to Celsius: C = K - 273.15
Celsius to Kelvin: K = C + 273.15
Kelvin to…

Shulhin Denys
- 11
- 2
-1
votes
1 answer
What is an appropriate MVC-based OOP design for my case?
Suppose the following baseline design: I have a class CarElement which holds properties and methods related to both visual representation and data model/logic representation of a car:
class carElement
{
// UI related properties and methods:
…

SenZe
- 3
- 2
-1
votes
1 answer
Class Design (UML Class Diagram)
Could somebody please give their input into the following scenario:
I'm creating a math quiz system. I need to generate several math problems and show them in the screen. There are many of them. Like:
Times tables: 9 X 9 = ____
Addition…

oscar.fimbres
- 1,145
- 1
- 13
- 24
-1
votes
2 answers
OOP UML Class Diagram, One person Has a multiple roles. How should its structure be?
There are three types of roles in a system.
Referees
President (There will be only 1 president)
Authors
A person can be both a referee and a author.
If a person has the role of President, they cannot have another role.
How should a UML Class diagram…

Raşit Şahin
- 55
- 3