Skip to main content

Questions tagged [class]

A template for declaring a type of object.

Filter by
Sorted by
Tagged with
1 vote
3 answers
224 views

I am creating a cinema website focused on client services, where clients can reserve tickets for movies and browse the cinema's schedule (both daily and weekly). The schedules will be managed by an ...
Moncef Drew's user avatar
2 votes
3 answers
2k views

Straight to the point, here's the original code: integer = input(...) size = len(integer) # Created three dicts for matching numbers as keys to corresponding words dic_ones = {...} dic_tens = {...} ...
Programmerthinker007's user avatar
-2 votes
1 answer
330 views

Introduction Components are an important building block of software. In terms of software architecture, there are a lot of principles regarding components that should be adhered to (high cohesion, low ...
dn1h's user avatar
  • 19
0 votes
4 answers
500 views

Class and component dependency cycles Assume, we have component A with class CA, and component B with class CB, with a cyclic two-way dependency between classes CAand CB. Hence, we have a cyclic ...
dn1h's user avatar
  • 19
-2 votes
1 answer
533 views

Say I have a class with a function do_thing that is comprised of multiple steps, which themselves segregate into functions (first_process and second_process). At what point would this be considered ...
Tim Kirkwood's user avatar
1 vote
1 answer
150 views

Say we have the interface interface IColoredSquare { int GetSideLength(); void SetSideLength(int length); string GetColor(); } and I implement it like this class ColoredSquare : ...
user avatar
2 votes
1 answer
2k views

Python is the language I use most in this period. My background in Java Before start learning Python I have programmed in Java language. In Java all code is written inside the methods of a class and ...
User051209's user avatar
2 votes
3 answers
225 views

there are a vehicle class and customer class . In short, in the customer class there is a function that shows 'can this person or company rent that car'.The function uses a object of vehicle and ...
Tunahan's user avatar
  • 31
0 votes
5 answers
2k views

I have a base class "People" which two other classes inherit from: Employee and Student. The Student class includes a GPA (type double) and the Employee class does not. I have an ArrayList ...
Delta88's user avatar
  • 19
1 vote
2 answers
797 views

I have a specific domain entity that has a given type and some attributes. Based on the type, it can have another set of type-depending attributes. Normally, I would create a class for each type and ...
Fischer Ludrian's user avatar
2 votes
2 answers
157 views

For example, for base and child classes, if all child class need a class member, eg: baseHp, which represents the base hp to calculate the actual hp of monsters in a game: public class Monster{ ...
wcminipgasker2023's user avatar
0 votes
1 answer
194 views

While writing the constructor for class A in Python, I calculate some of the class's fields using function fun(). This function is never used outside the constructor of instances of this class. In ...
Harm van den Brand's user avatar
2 votes
3 answers
1k views

I went through various blogs but nowhere I can find the reason of having virtual constructors in C++. Why is virtual constructor needed and lets say if we go through the wrong way of creating virtual ...
H Kumar's user avatar
  • 31
1 vote
0 answers
100 views

Context I'm designing the software architecture of a safety critical software written in C, under DO-178C (DAL A) and with a Code Standard based on MISRA-C 2012, but no fully compliant. It is the ...
Sam's user avatar
  • 31
9 votes
4 answers
4k views

I am working on a huge code base (more than a million lines of code with a sophisticated architecture) written in C++ over the span of a couple of decades. The task on which I'm working at this point ...
Dude's user avatar
  • 209
-2 votes
2 answers
595 views

I've read that you should pass in an interface instead of a concrete implementation so that the consumer doesn't need to know anything about implementation details. I don't understand how injecting a ...
james's user avatar
  • 113
1 vote
1 answer
412 views

I am making a game of monopoly. Inside my game I have a Board class. The Board class has an array which contains 40 squares. Each square is a different class e.g. ChanceSquare, PropertySquare ...
Kevin Greetham's user avatar
-1 votes
2 answers
180 views

This question has always bothered me I am finally ready to ask it out here. I am creating a hotel reservation app, and I am in the phase of deciding what classes I will have. Among classes such as ...
multigoodverse's user avatar
9 votes
4 answers
2k views

Java is often (rightly IMHO criticized) for overusing the class keyword, as it can denote: a factory to instantiate objects (traditional classes) a collection of global methods (when all methods are ...
Ray Toal's user avatar
  • 1,335
0 votes
1 answer
196 views

Let's say we have a class( My_Func_Dec ) that models a 'function header declaration' as it might appear in a .h file. const std::string func1 ( const std::string& arg1_, const std::string& ...
Mote's user avatar
  • 9
1 vote
3 answers
4k views

Suppose I have two abstract classes called Color and Animal And I can create classes Green/Red/Blue derived from Color and classes Dog/Cat/Pig derived from Animal at runtime using factory pattern. ...
Xie Qing's user avatar
0 votes
1 answer
303 views

I'm struggling on how to name classes for use cases. Because I know that is "bad" to use verbs in classes names(Uncle Bob) but at the same time names of use case classes should explain what ...
Carlos Figueroa's user avatar
3 votes
2 answers
517 views

In Python, I have a class C which embeds objects from classes A and B. Is it considered good practice to creates shortcuts from the properties of embedded objects of classes A and B as attributes of ...
Daniel Arteaga's user avatar
0 votes
1 answer
136 views

In the following image, regarding a CD shop that rents its music CDs. My question is regarding the correct multiplicity of X. I can think of several possibilities for X: X= 1..1 as each copy of ...
Karl 17302's user avatar
27 votes
9 answers
9k views

I have always wondered whether public, protected, and private has security implications post compilation. Hypothetically: class Foo { public: int m_Foo; // Completely vulnerable and dangerous ...
Anon's user avatar
  • 3,649
2 votes
2 answers
427 views

I am trying to understand the relationship between actors and their representation in the system. Please see the below figure In the figure on left, I have an abstract representation of my system. In ...
Afia R. S.'s user avatar
2 votes
5 answers
2k views

I am relatively new to C# and OOP concepts in general, but am building a standalone application and have run into a question and want to make sure I'm doing it the "right way". I have a few ...
adc395's user avatar
  • 39
-2 votes
1 answer
758 views

Should i include the different functions of open account, close account , withdraw in the customer class(as shown in the picture) or should i include it in the account class
Moaaz Siddiqui's user avatar
0 votes
1 answer
1k views

I would like to create a dynamic appointment system between teacher and student to easily allow them to make an appointment. In this system, teachers select their 30 minutes time slot availabilities ...
anthonya's user avatar
  • 109
-2 votes
1 answer
1k views

I'm looking for an efficient way to create appointments between teachers and students. I want teacher to be able of make their students know their availabilities : For example, A Teacher writes on the ...
anthonya's user avatar
  • 109
0 votes
0 answers
899 views

I googled this and found questions like "How to use Protobuf message as java class without a java outer class?" (https://stackoverflow.com/questions/60312156/how-to-use-protobuf-message-as-...
Matt Welke's user avatar
1 vote
1 answer
640 views

This question pertains to properly structuring a class. The object of a class I have is instantiated with multiple parameters. Many of these parameters are then manipulated with each other to derive ...
matsuo_basho's user avatar
0 votes
2 answers
118 views

classes and method should do one thing like the code below: class A { public int a() { b(); } private int b() { c(); } private int c() { } } The code mentioned below I found it ...
Sajied Shah Yousuf's user avatar
0 votes
3 answers
138 views

Let's say I have an instance of a superclass and at a later stage this object needs to be converted into a subclass instance (based on additional information that are stored in the object). Is it ...
MaxxOr's user avatar
  • 67
-1 votes
3 answers
443 views

i'm trying to design a game program, but when thinking about which objects to introduce there seems to be far too many. For example for main object "Player" there are a lot of peripheral ...
user avatar
1 vote
2 answers
517 views

A typical introductory example to OOP, classes, and constructors is object Car, with properties such as float fuel, bool is_engine_running, etc etc, and a class and constructor definition might be as ...
SRSR333's user avatar
  • 335
1 vote
2 answers
477 views

I'm creating a class representation of a mathematical tuple (or simply, an ordered set of numbers). Being a list-like object that could benefit from an iterator representation, I have decided to give ...
Angel E.'s user avatar
  • 129
10 votes
3 answers
7k views

I'm a beginner in C++, and I was wondering if it is best practice to define a member function directly in a class, such as: // something.hpp class C { inline int func() { return ... ; } } rather ...
Angel E.'s user avatar
  • 129
-1 votes
3 answers
450 views

I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design. I'd like to hear the differences between Class Oriented Design ...
jeffbRTC's user avatar
  • 167
-1 votes
3 answers
2k views

I was reading some C++ object-oriented programming notes that mentioned that we should avoid wrapping functions in classes if it is not required, since wrapping 'things' in classes would reduce ...
The Pointer's user avatar
1 vote
0 answers
132 views

My team works on an HTTP web server in C++. The codebase has aged over time, and has a widespread problem of 12+ parameters being passed to every function. A fake example: We need to build a Car, but ...
DonutGaz's user avatar
  • 281
5 votes
4 answers
415 views

My question is about the way to represent data models created at runtime. To illustrate, let's say we would like to create a CMS-like app in which end-users may create custom forms. Those forms are ...
ibi0tux's user avatar
  • 241
0 votes
3 answers
86 views

If there is Class A and Class B and there is an association that B can be assigned to A.And the multiplicity is 1:M or M:1 from A to B.Example: 1.Room has Collection of Keys, and Key can can assigned ...
rahul sharma's user avatar
2 votes
3 answers
718 views

I am reading about OOD and came across Parking lot design problem.Parking lot has parking floors which has parking spots.The parking spot class looks as follow: public enum ParkingSpotType { ...
rahul sharma's user avatar
2 votes
0 answers
36 views

Consider the following: import typing class MyClass(object): def __init__(self): self.my_member: typing.Optional[dict] = None def update_member(self): self.my_member = {} ...
Jimmy Thrasibule's user avatar
1 vote
4 answers
1k views

Short answer that I've come to accept: Firstly, it helps with readability, being able to see which is the superclass apart from interfaces. Secondly, though 'extends' and 'implements' do the same ...
xtratic's user avatar
  • 456
1 vote
2 answers
162 views

This may be too general of a question, but basically whenever I try to find an answer for something that would work from a Javascript approach, the answer heavily implies that you wouldn't do it that ...
sheepdeets's user avatar
1 vote
2 answers
408 views

Is there a statically typed programming language that implements Polymorphism without using a superclass or an interface (if such implementation is even possible)?
Steve's user avatar
  • 119
0 votes
2 answers
5k views

I am studying the programming language Kotlin, and I just came across the idea of a Data Class. I have a background in Java programming where classes can have fields and methods. I have heard ...
Steve T's user avatar
  • 141
0 votes
1 answer
170 views

I'm working on a programming language design ans I'm struggling with how I should type the concept of Class. Let me show you some code to illustrate my problem : class MyClass { } function ...
ibi0tux's user avatar
  • 241

1
2 3 4 5
7