Questions tagged [class]

A template for declaring a type of object.

Filter by
Sorted by
Tagged with
-3
votes
1answer
58 views

How do I find out all modifications made by installing software? [closed]

So I want to find out how to get a list of all modifications made by installing a piece of software. For example. If I install Word, I want to see all directories created, classes registered, dlls, ...
-3
votes
0answers
20 views

creating a class attribute after initialisation in python [migrated]

I have a class in python, defined as follow: class MyClass: def __init__(self, x, y): self.x = x self.y = y I need the object to have an additional attribute, z, that depends on ...
-2
votes
3answers
73 views

Accessing one class variable from another class in C++

Suppose I'm in some function of class A, in this function I define an object of class B, say b, and call some function using b.func() which updates some values and arrays, say x and A. Then, I create ...
-1
votes
2answers
95 views

Do I name classes based on the object type they represent or the responsibility they have?

The more I read about the Single Responsibility Principle the less I see a class as an object type, but rather as a servant that does something. For example, let us suppose we have a new requirement ...
0
votes
1answer
74 views

Inheritance but with two different shared traits?

I am facing a dilemma with designing an api gateway. Currently, I am using the pipeline pattern, with different stages being the requests made to various services, (http, sockets, amqp, ...). I have ...
-2
votes
1answer
155 views

Why would you make a struct without typedef?

Since I cut my teeth on code with OO, I’m biased toward using structs as classes without methods. However, there’s probably a good reason that typedef isn’t the default behavior of struct. What is it?
3
votes
3answers
257 views

Struct or class for wrapping an int when 0 isn't a valid value

I have a business object which is basically a wrapper around a value of type int. There are some constraints for the value/object: Not every value in int's range is valid1 The valid values are not a ...
0
votes
1answer
93 views

Responsibility-driven design

I am quite confused about the responsibility-driven design concept. Mainly because of ever so slightly changing definitions depending on the source. Quoting BlueJ (the book I am learning that ...
-2
votes
4answers
342 views

Is judicious & plausible selection of class fields a valid refactoring step?

I'm a great fan of refactoring but I've been wondering about the issues raised by refactoring. Fowler advises refactoring to make code readable to all users to make the code structure more sensible, ...
28
votes
9answers
9k views

In OOP, isn't the 'protected' keyword required?

Some modern languages (e.g. Swift, Dart) do not support the protected access modifier keyword. Swift is a protocol-oriented language, but I've heard that Dart is a completely object-oriented language. ...
-2
votes
2answers
106 views

C# Static & Constructor Logic [closed]

I learn C# and try to understand the logic between static and Constructor right now. One thing I need ask you about an example which I will give at below. (please ignore the quality of code or how ...
-2
votes
1answer
314 views

UML class diagrams - how do I draw a class diagram that shows a self-reference? [closed]

So I have the following case. I have an interface A and an implementation AImpl. Now I have another implementation of A, called A2Impl, which references any instance of A besides implementing A ...
0
votes
1answer
507 views

Class structure: How should a binary tree and it's node class be implemented in Java in terms of class files?

In implementing a binary tree in Java, should the node class be a separate class file independent of the BinaryTreeclass, or should it be a default class in the same class file as the BinaryTree class?...
1
vote
4answers
143 views

Should supporting algorithms be in their own class?

My Widget class has a method called loadWidget. This method needs to shuffle an array to work properly, among other things. In Widget, I could implement a Fisher-Yates shuffle as its own static method ...
0
votes
2answers
159 views

2 way multiplicity constraints in code

my goal is to convert this class diagram into Java code. How should I approach this, given that I want the constraints to hold at all times? It creates a chicken-egg problem where the first Course or ...
2
votes
2answers
191 views

How to organize my test functions? (Part II: Keepin' it classy)

What are the best practices to organize your unit tests in classes? I see different possibilities: 1) One would be to write one "container" class for each function you want test and then ...
0
votes
2answers
103 views

Where should the logic concerning a class's behavior reside? In the class itself or in the calling subroutine?

I have a car object. The car cannot be driven unless it is turned on. When should I check to see if the car is on before I try to drive it? In the main program? class Program { static void Main(...
1
vote
2answers
244 views

Why are classes named “class”? [closed]

Could it also have made sense to call it a "Form", as in the Platonic sense of the ideal form that represents the thing which earthly objects strive to emulate?
0
votes
2answers
205 views

Which option is good in terms of software design?

I have one request interface IRequest and two classes ClientAddress and ClientOrder are implementing it. The same design is followed for Response with inteface IResponse and classes ...
-3
votes
3answers
202 views

Java - OO - Understanding Subclass of Class Object

While a fundamental concept, I don't understand the statement "every CLASS in Java is a subclass of the class object," which is often quoted in JAVA tutorials usually in the inheritance section. I ...
1
vote
1answer
371 views

How many test-cases need to be created at least (valid and invalid equivalence class)?

Assume there is any program that is supposed to be tested and you like to perform an equivalence class analysis on it. Let's say you identified six valid and four invalid equivalence classes. Then, ...
0
votes
2answers
450 views

What are the advantages of proxy classes?

I've been learning about proxy classes in c++. I really don't see the advantages of using proxy classes, as they're not any better at concealing information than private members are. What advantages ...
-4
votes
1answer
219 views

Inheritance of Constructors from parent into child class [closed]

Is the Default Constructor of Super or Parent class Can be Inherited into Child class ?
3
votes
3answers
833 views

Factory pattern or builder pattern ? which one is suited for reading Finite Element Model data from a text file?

A follow up to another question (Making a design decision about reading model data from an input file). I wish to ask another question regarding builder or factory pattern. (I read that builder is ...
2
votes
1answer
112 views

Making a design decision about reading model data from an input file

I am writing a finite element software in C++ and Qt. I want to load the input data to the model. I have a Model class that holds the data and does the work. I have created a simple lexer and parser ...
-1
votes
3answers
2k views

Multiple classes working on an object

This might be a bit of a wide question but I want to understand if it's the correct way to do it. Assume I have a couple of classes all doing operations on an object. First class takes the object, ...
-2
votes
1answer
25 views

Data Sharing Levels of Privacy

I've been looking through class and friends and similar c++ arrangements to share data, and cannot find how to program levels of share. No players can know what the other players have in their gold-...
0
votes
3answers
156 views

Java, pattern to restrict field usage in subclasses to after calling specific method

I want to extend class Base which is defined in specific API and the extend the extended again. As you can see below, draw method of intermediate class calculates variable top and I need to use it in ...
0
votes
2answers
121 views

Using new [className] without a return

I have started using the following in my automation code in instances where I'm not interested in keeping the object 'alive'and just using it as a means as a type of precondition. For example: ...
4
votes
1answer
709 views

What's the best way to handle a large multi-file class in Javascript?

I have a very large class of 59 methods and about 3000 lines of code. I know that's far larger than most people would want, but the class represents a virtual machine, and most of the methods are run ...
5
votes
4answers
612 views

Proper way to name a class which has just methods and not fields

GOAL: naming a class which has the responsibility to save data in Android database. The class structure is like this ClassName { public void saveSync(...){ /* implementation*/ } public ...
1
vote
1answer
92 views

An interface for designing Arduino code

Often I want Arduino board to control several peripherals. Writing program for all of them in one document using #define SOME_PIN 4 constructions seems pretty inconvenient to me. Especially in such a ...
1
vote
3answers
384 views

When to use Parameters and When Not to C#

I am have an application using MVVM pattern. It takes a user ID and returns a table with the user's bookmarks. I am trying to decided if it is better practice to include parameters in my model's ...
3
votes
5answers
3k views

Use POJO or Map when there is a finite number of known keys?

I have some set of data with key-value pairs, but there is only a finite and known set of keys, all of the key should always be present on that data, and they all have the same type for the value. ...
-1
votes
1answer
215 views

Does Interface Segregation Principle apply to parameters/request objects?

I have recently seen an example of what I think is a clear violation of ISP, but my colleague argued it is easier to use. This is what happened: We had Options class that had 2 fields sent as a ...
-2
votes
1answer
101 views

What to name my config classes

What name should I give classes which are just for configuration? For example, when using JAX-RS, every application is required to have an Application class which extends the superclass javax.ws.rs....
0
votes
1answer
91 views

Ext JS: Designing a base class and override it

I'm trying to define a base class and override it's items on different inherited sub-classes. I'm following MVVM pattern to fetch records from backend. Created several stores and formulas within ...
7
votes
1answer
309 views

Should every method in a class be defined in an implemented interface?

I can see how interfaces are very useful to force different classes to have the same functionality. But there are also actions that are bound to a specific class (like updating an unique variable ...
0
votes
1answer
65 views

PHP User, Customer, Business Relationship

I am creating an invoice management system that has a User Class that handles the login system. Currently each User is associated with a Customer and the Customer class handles obtaining Monthly ...
1
vote
0answers
63 views

Program and Class Design

I am hoping you may be able to give me some advice on class design and what would be best for the program I'm currently writing. This is being done in Java and the goal is to generate letter data ...
0
votes
4answers
167 views

How to insert code in a method in a derived class [duplicate]

I have a base class with a method called Update: Start Update Code block 1 (An If statement) Code block 2 (Setting a variable based on the If result) Code block 3 (A switch which is ...
1
vote
1answer
366 views

UML - Design Class Model diagrams

I have several questions about UML diagrams as I am not finding them very clear (they are new to me). 1) When making a diagram with generalizations/specialization: if I do not have all of the ...
10
votes
4answers
10k views

Using vectors of shared pointers to objects in my C++ code to prevent object duplication

In my C++ project, I have three classes, Particle, Contact, and Network. The Network class will have N particles (std::vector<Particle> particles) and Nc contacts (std::vector<Contact> ...
10
votes
5answers
5k views

How to resolve class interdependence in my C++ code?

In my C++ project, I have two classes, Particle and Contact. In the Particle class, I have a member variable std::vector<Contact> contacts which contains all contacts of a Particle object, and ...
1
vote
1answer
252 views

Should I be creating more objects in Java?

I am very new Java and have been messing around with a program that essentially prints a random line of characters based on random char values and array manipulation. I am having a lot of trouble ...
0
votes
2answers
361 views

Dynamically choose whether to use __slots__ in a class

I've got a generic container class: from typing import Container, Generic, TypeVar, NamedTuple import sys fixed_typing = (sys.version_info >= (3, 6, 2) or (3, 5, 3) <= sys....
21
votes
4answers
29k views

How to best to organize class and interface files?

OK .. after all the discussion I'm changing my question slightly to better reflect a concrete example that I am dealing with. I have two classes ModelOne and ModelTwo, These classes perform ...
2
votes
2answers
451 views

Is “A programmer-defined type.” a right definition of “class” in Python?

In Think Python 2e "class" is defined as "A programmer-defined type. A class definition creates a new class object." But isn't a built-in type considered a class too? Using Python 3.4.0, the ...
7
votes
4answers
458 views

Encapsulation and Displaying Information

This site and SO contain many pages about getters/setters and if they break encapsulation or enforce it. My question is for those developers that agree that getters/setters break encapsulation and ...
0
votes
1answer
480 views

Instantiate a class from a config file. Where should the parse function go?

I have a class in python that is instantiated from the values of a (json) config file. I was wondering what is the best practise to do that (if there is a best practise and is not just a matter of ...

1
2 3 4 5 6