Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
-1
votes
2 answers
Issues about creating good interfaces on Javascript functions
How could I implement high-quality routines (mentioned by Steve McConnell, on Code Complete, chapter 7) on some Javascript code? For example, in this case:
$('#variable').on('click', function(){
//do some stuff
});
This is…

José Augustinho
- 110
- 1
- 10
-1
votes
2 answers
Class design: Access two keys as properties using a constant?
Now:
2 classes each with the same constant name, e.g. ERR123
class1 got public const int ERR123 = 123;
class2 got public const string ERR123 = "Error 123, something went wrong.";
So I call it like
int code = class1.ERR123;
string message =…

UNeverNo
- 549
- 3
- 8
- 29
-1
votes
6 answers
Garbage with pointers in a class, C++
I am using Borland Builder C++. I have a memory leak and I know it must be because of this class I created, but I am not sure how to fix it. Please look at my code-- any ideas would be greatly appreciated!
Here's the .h file:
#ifndef HeaderH
#define…

Shishiree
- 165
- 2
- 11
-1
votes
1 answer
designing classes based on database-design
i have a little problem with my ojt-project. i was given a database design and have to do a class design for it. however i have never designed classes based on an exisiting database so i am confused of which classes i should design.
here's a little…

LeonidasFett
- 3,052
- 4
- 46
- 76
-2
votes
2 answers
Does it make sense to use interfaces as type of private members?
When I write a class in C#, I'm often not only using interface types in the public API/signatures, but also as types of the private members:
public class Foo {
private readonly IDictionary m_Bars; // <-- here
public Foo() {
…

LWChris
- 3,320
- 1
- 22
- 39
-2
votes
4 answers
How to use self class method on iPhone? (conceptual question)
I write an instance method in ClassName.m:
-(void)methodName:(paraType)parameter
{...}
And call it using [self methodName:parameter]; A warning will pop up, but the code still runs successfully.
Is this because I haven't created an instance of the…

Chilly Zhong
- 16,763
- 23
- 77
- 103
-2
votes
1 answer
Thread safety among classes with other classes for private variables
I'm writing a game engine (for fun), and have a lot of threads running concurrently. I have a class which holds an instance of another class as a private variable, which in turn holds and instance of a different class as a private variable. My…

hromer
- 151
- 1
- 13
-2
votes
1 answer
c++ abstract base with datatype will be defined in derived class
I want to have a base class with datatypes that will be defined in derived class.
pseudo code
class Base{
public:
void Enroll(vector v){
feature_list.emplace_back(ExtractFeature1(v));
}
vector Compare(vector v){
…

D R
- 21
- 7
-2
votes
1 answer
C# how delegates and interfaces can play a role in this example
I would like to understand if/when to use delegates and interfaces in my code. The structure is pretty simple. The main class initialize a windows form:
class MainClass
{
public static void Main()
{
InputForm InputForm1 = new…

mickG
- 335
- 5
- 13
-2
votes
1 answer
design pattern such that access to the Derived class is only possible through a library
Trying to achieve a design where the classes that implement interfaces should only be callable from a Library. In other words, the access to the implemented interfaces should be through the library (TopLib). Seems like the case where delegate should…

Vibgy
- 577
- 6
- 15
-3
votes
1 answer
Public vs Private members for factories implementing an interface
Summary
Is there harm in exposing concrete class data as get-only public properties solely for the purposes of writing better unit tests?
Background
In general, I prefer to keep as much, if not all, of my data as private readonly. This ensures…

mhand
- 1,231
- 1
- 11
- 21
-3
votes
1 answer
c++ breaks on class function
i have created this class for mesh loading it works but i added this new function to help speed up the loading. when i call the function my program breaks/stops.
here is my function
bool CXFileEntity::LoadXFile(const std::string &filename, int…

Ramilol
- 3,394
- 11
- 52
- 84
-3
votes
3 answers
How do I set properties in a constructor that has only a self argument. I also do not know how to define methods without implementation,Inside a class
This is the Question: It blew me away; my attempt is in my next post.
Create a class called bank account that has the methods withdraw and deposit with no implementation.
Create a class called savings account that inherits from bank account.…

user6793231
- 3
- 3
-4
votes
2 answers
Which OO Design is better and why?
I am developing an image editor app so which approach is better for class design from mentioned below? Any one of three or any new?
First
class Image{
string path
rotateLeft(){};
rotateRight(){};
changeBrightness(){};
}
or…

Kevan
- 1,085
- 1
- 9
- 15
-6
votes
1 answer
Accessing private members of a class from another class
I have 3 classes
class A {
B *b;
}
class B {
C *c
}
class C {
....
}
What is the best way to access instance of class C inside class B from class A? Please also suggest a way to write the constructor for each of these classes?

Shyam
- 37
- 1
- 8