Questions tagged [class-design]

Refers to structural definition of class unit in object-oriented languages.

1125 questions
-1
votes
2 answers

How to call a method in one object from another object in the same structure

I have the following situation: class B { public: void methodInB(); }; class C { public: void methodInC(); }; class A { public: void methodInA(); private: B objB; C objC; }; void…
Kian
  • 1,654
  • 1
  • 14
  • 22
-1
votes
1 answer

Is there a better design practice than to add a new virtual function in base that is not implemented by all derived classes

I have class hierarchy as shown below. It's a simplified version of actual code. class Base { public : // user_define_type is a output parameter virtual void Fill(user_define_type); } class A : public Base { public : void…
Anand Shah
  • 133
  • 10
-1
votes
1 answer

How should property types be used correctly in class design

Having two classes - e.g. Shop and Products public class Shop { public int ShopId {get;set;} public string ShopName {get;set;} public ICollection Products {get;set;} } public class Product { public int ProductId {get;set;} public string ProductName…
Subliminal Hash
  • 13,614
  • 20
  • 73
  • 104
-1
votes
2 answers

Moving through classes without creating a new instance

Does anyone know of a way to show another class without creating a new instance? It seems a bit crazy from a memory management point of view that each time you want to display a different form / page you need to use StartActivity which then creates…
-1
votes
1 answer

Trying to create a system design represented by a UML class diagram. Potentially using the adapter pattern?

I need to describe a general design for a system that will handle the different types of tollbooths and their components, for a homework question: You’re the lead developer for a company that has cornered the market on high-way tollbooths. Your…
Hello
  • 219
  • 2
  • 7
-1
votes
1 answer

Some guidance with C++ and creating objects using composition

Basically my issue is with compositions. I understand the principle, but I'm struggling with the execution in one of the tests. From the code of Computer and Monitor below, I have to create a final class Complect which will have its own name , the…
B. Baxter
  • 133
  • 1
  • 10
-1
votes
1 answer

How to implement a hierarchy class system

I'm a bit new to C++ way of handling this situation, so instead of using singleton pattern right away, I decided to ask this question instead to see if there's a better alternative. Is there any other way to implement a system, where we got a main…
buttons.png
  • 77
  • 1
  • 9
-1
votes
1 answer

Pass a list or variable number of arguments as method parameters

I was wondering what the best (most pythonic) solution is to pass a list or a variable number of arguments to a function/method. For example I have to following class: class Dataset(): def __init__(self, *args): self.data_set = args and this is…
-1
votes
1 answer

Problem in class design with multiple base model

I have a base class for all the ENTITIES of my project which is inheriting from below model : public class BaseModel { public int Id { get; set; } public int CreatedDate { get; set; } public override string ToString(); …
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
-1
votes
1 answer

How to decide which design pattern best for the concept

How to decide which design pattern best for the concept. Ex. Metro railway , ticket reservation,
user3032819
  • 595
  • 1
  • 5
  • 6
-1
votes
5 answers

What is a good name for a date, time, location type PHP class?

I am currently coding a library/framework to use in my future projects. I am trying to decide on a good name for a date time type class. Most likely I will be extending PHP's Datetime class, but add my own methods to it. Some methods…
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
-1
votes
2 answers

Correct way to design data class to handle polymorphic data

I need to design a struct data which will hold pointer to Base data type. User should be able to easily create object of this data struct and pass around without handling much of memory management issues. I have created few structures, please…
Daemon
  • 1,575
  • 1
  • 17
  • 37
-1
votes
4 answers

Data structure design is static-typed language

I use C# to write a (hypothetical) application - online store. I have a database of products, each product has following information associated with it: Product Number (required) Name (required) Price (required) Rating (optional) Sold Quantity…
THX-1138
  • 21,316
  • 26
  • 96
  • 160
-1
votes
2 answers

Class variable which is object of this class

The title can be confusing, but I'm wondering is it possible to create program like this one: class family_tree { private: string name, surname; family_tree father(); //fragile point! public: family_tree(); family_tree(string n,…
lvp
  • 2,078
  • 18
  • 24
-1
votes
1 answer

What is a good design pattern in C# to instantiate referenced objects of different subclasses?

I have a manager that read objects from a repository. The objects reference other objects of a known base class, based on a stored enumeration property. What's a good design pattern to know which manager/repository to query on the reference object?…
Villason
  • 11
  • 6
1 2 3
74
75