A template for declaring a type of object.

learn more… | top users | synonyms (1)

-1
votes
0answers
27 views

What classes should I use for API -> logic -> API?

I need to fetch some information from an API, parse through it and push the relevant data to another API. How should I design this? One class handling everything? One class per API and one for the ...
-6
votes
5answers
151 views

Java constructor: I can't understand [on hold]

I am learning Java and I have a problem understanding the concept of constructor for the field variables. What is the problem with the following code. It shows "null" as an output. public class ...
3
votes
1answer
126 views

C++ class design with invariant

I've been pondering a really basic question about how far to take enforcing a class's invariant. Maybe that's worded badly, so as an example, let's say that I want to write a class which stores a ...
5
votes
2answers
165 views

Idiomatic way to write JavaScript class that maintains state and tells you when that state has changed

I am an experienced C++ developer but new to JavaScript. I want to write an ES6 JavaScript class that maintains state. How do I tell when state has changed? I can think of two ways to do this. One ...
2
votes
2answers
175 views

Where is the class itself stored at runtime to be used as a reference

In C# or Java we find that the objects are stored on heap and their reference vars are stored on stack. But at run time where is the class definition stored to be used as a template for creating ...
3
votes
6answers
146 views

If Class is to define attributes and methods, and Interface is to define (a set of) methods, then how to think of interface needing new attributes?

I thought a class is supposed to define, or give a blueprint, of attributes and methods for an object. And then, an interface is to provide a set of methods, as a contract for its clients. (and so a ...
2
votes
2answers
112 views

python - differences between reusable code vs. code for solving specific tasks

Reusable code (ex. libraries and frameworks) and code written to solve a specific task and not meant to be reused as a general tool (for example, code being used only by my 6 person team in a private ...
6
votes
4answers
306 views

Class design dilemma: Encapsulation vs Single Responsibility/Separation of Concerns

I'm working on a class that represents an object with multiple representations - one is an XML type representation used by an automatic ordering system, the other is a POJO-based representation used ...
1
vote
3answers
241 views

Using super keyword to access super class members

I have following questions about the super keyword in java: I have a code below with classes: A Extends no class contains integer variable i B Extends class A contains integer variable i C Extends ...
-1
votes
3answers
125 views

Python — Class and Object [closed]

I got a question that quite disturbs me a lot and I think it might help a lot if I had an answer to it. So I got this: class Klasse1: variable1 = "haha" class Klasse2: variable2 = "hoho" ...
-1
votes
2answers
114 views

java — multiple classes [closed]

So for my course programming with Java I want to exercise a bit. I made a project about planets. I got 4 planets with each of them containing information. I made a class Planet: public class Planet { ...
2
votes
2answers
67 views

Advantages of extending the default Exception class

I've seen that it's possible to extend the default Exception class in PHP, enabling one to throw an IncorrectParameterTypeException exception, or a ValueOutOfRangeException exception (maybe these are ...
0
votes
2answers
65 views

What is the difference between proxy class and delegation in Python?

Wiki: A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, ...
0
votes
1answer
81 views

Should I document expected call-sequences when call-order matters?

In dynamically and weakly-typed languages*, I often find myself with structures like the following pseudocode: class Stateful: # [ various datamembers / attributes / properties / fields / etc. ] ...
1
vote
3answers
147 views

Should I create a class for functions that uses of the database?

I have a PHP application which is pretty simple: It allows the user to create, edit and read a post. Basic stuff. I have a Database class which handles the connection and the queries execution. The ...
0
votes
0answers
33 views

Should a class method have access to data from the app delegate?

I'm working on an iOS app with a codebase that the majority of I did not write. For the task at hand, I'm in a situation where I need a class method to have access to data that's returned through the ...
0
votes
1answer
89 views

Function or class design in library API for efficient object reuse

I am currently building a library in C++11, where I spent a lot of time trying to design a good interface. After some small redesigns along the way, I've ended up with a design that I am happy with. ...
13
votes
4answers
3k views

Singleton or instantiate everytime I use? [duplicate]

I use a class that just extracts data from one known object, and distributes it to other known objects. No persistent configuration or such is needed in that class instance. How should I decide ...
3
votes
1answer
64 views

CharSequence to represent a named object

I always followed the opinion to not abuse interfaces in case of decomposition. Usually I only implement them if I am absolutely sure to have a "is-a"-relation and avoid implementing them if there is ...
2
votes
2answers
228 views

Is it OK to use (WTF) forms to validate against stuff from DB?

Form classes are intended (IMO) for submitted data against rules. For example: are passwords equal, is end date later than start date. submitted data--->|Form| Is it okay for Form classes to ...
2
votes
1answer
51 views

Should I be taking these as arguments or define them in a sub class?

So I am making a mario clone in pygame and I have a base class Character and two sub classes, Mario and Luigi. The methods that the Character class defines require a significant amount of attributes ...
1
vote
4answers
1k views

What are the differences between class variables and instance variables in Java? [closed]

I'm very new to Java and want to be difference between class variables and instance variables. For example: class Bicycle { int cadence = 0; int speed = 0; int gear = 1; } How are ...
-3
votes
1answer
220 views

Good practice to hold Constants in their own file? [duplicate]

I've noticed some projects like to store constants in their own file, i.e constants used globally and in the main program loop might clutter the main file so perhaps they look to place them elsewhere ...
68
votes
13answers
7k views

Do objects in OOP have to represent an entity?

Does an object have to represent an entity? By an entity I mean something like a Product, Motor, a ParkingLot etc, a physical, or a conceptual object, something that is well defined, with some core ...
2
votes
1answer
141 views

Python Classes and Design Questions

What is the best way to design a class to see if an update occurs on a property? I have a whole bunch of classes, and current am going through a re-design of the python package I created. ...
0
votes
0answers
97 views

Class design for Token, TokenType and regex constants

For use in a lexer class a have a class Token which represents a token of a specific type and its value, while the types are defined by the enum TokenType in which every token holds its own regular ...
4
votes
3answers
147 views

Unit of Design Versus Unit of Re-use. What is the difference?

Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design ...
1
vote
4answers
298 views

Why I need to make method of my class private, If I need to access it throughout my application?

I am going through the beginners tutorial for C# from a website http://www.homeandlearn.co.uk/csharp/csharp_s10p1.html On chapter of classes, it makes the method of class private and then use ...
5
votes
1answer
306 views

Nested classes via a getter (to emulate namespacing)

So, we all know that ES6's introduced syntax is definitely sugar over what we've been doing, previously. That being said, we still don't have namespaces (which would be nice...) The problem that I'm ...
0
votes
1answer
278 views

Setting up folders and importing modules in Python

I'm building an app to automate some processes that are annoying to do by hand (looking in a file, taking certain information out of a file, building another file with that information). My project ...
1
vote
1answer
53 views

What's the best way to store class/type info in a plugin system in your software?

There are lots of applications like 3ds Max, Maya, etc that allows you to use plugins, where even the default nodes are created as plugins. This is all good but if the developer changes the ...
1
vote
2answers
231 views

Are any side effects not concrete side effects?

In Chapter 23 of "Object Oriented Software Construction" (1988), Betrand Meyer makes a distinction between side effects, concrete side effects, and abstract side effects. Meyer defines a side effect ...
0
votes
1answer
173 views

Best OOP practice for object vs dataservice [duplicate]

I am working on a new project and am curious as to how I should go about doing something properly. Lets say I have a table called "leads" in my database. This clearly means that a single "lead" would ...
0
votes
0answers
46 views

Internal class variables convention

When I see some open source projects, specifically classes, I see that its variables starts with a 'm' minuscule. What does it mean? What means the 'm'?
2
votes
1answer
253 views

Static properties and implicit “self” property in structures and enumerations vs classes in Swift

I am currently reading the Swift language documentation and came across these sentences in the chapter about methods: Similarly, type methods on structures and enumerations can access static ...
1
vote
5answers
639 views

Are there too many parameters in this constructor? [duplicate]

Check this out: public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, ...
1
vote
3answers
244 views

OOP implementation doubts with databases

I was starting a project today and after designing the database structure and how the data would be stored etc, I started the implementation. I am doing this on php, but the language isn't really ...
4
votes
2answers
251 views

Should I use properties for the properties of properties?

Sometimes I use some indirect properties to set or get some other sub-properties, I give an example class Page { public string MainText { set { MainParagraph.Text = value; } get { return ...
0
votes
1answer
347 views

Should I prefer classes or singletons in JavaScript/Node?

This question applies especially to Node.js, but also to JavaScript in general. I started working on a simple web app in Node.js. I'm relatively new to Node and JavaScript, and come mainly from C# ...
15
votes
4answers
2k views

“Use map instead of class to represent data” -Rich Hickey

In this video by Rich Hickey, the Clojure creator, he advises to use map to represent data instead of using a class to represent it, as done in Java. I don't understand how it can be better, since how ...
3
votes
1answer
170 views

When to use nested classes and when to use namespaces?

I have really never made use of namespaces, and am considering them at the moment. My situation. I have a class Reverb. It contains as members instances of other classes, declared in the same header ...
0
votes
1answer
66 views

Comments for a class that isn't an entity

According to Java's commenting conventions, classes comments should describe a "thing", rather than "actions". It is easy when the class IS a thing (ex. a Clown), but what if it isn't? In this case, ...
0
votes
1answer
109 views

Why is it said that a class represents an abstraction? [closed]

I think that abstraction represents only the essential things needed for the purpose as there are so many unnecessary properties. So why is it said that a class represents an abstraction?
9
votes
5answers
2k views

class in OOP language and type

In programming language theory, a type is a set of values. E.g. the type "int" is the set of all integer values. In OOP languages, a class is a type, is it? When a class is defined with more than ...
1
vote
2answers
194 views

Class as resource handle & Bad Copy

I am reading Bjarne Stroustrup's book titled "A tour of C++". The following section is confusing to me: When a class is a resource handle – that is, when the class is responsible for an object ...
1
vote
1answer
258 views

Splitting single Class into multiple Classes

I am writing automated test scripts with Selenium Webdriver (Python) and I try to follow the correct programming practices, specifically the Object Oriented methodologies, where possible. At the ...
1
vote
1answer
216 views

How to represent “class” data type in C or any low level language? [closed]

I'm writing a simple language compiler,currently it's support functional programming only. I want to support OOP concept, but I don't know how exactly I can represent an object ? just where to start ...
4
votes
4answers
1k views

Refactoring: When to add a new class in the project?

When do you feel that you need a new class (maybe when you are developing or after development for refactoring purpose)? Maybe I can start from my existing variables and think how I can reorganize ...
1
vote
1answer
384 views

How to store/deal with data available to other classes

I'm writing a CAD program. Let's say I have in input class, this class reads various data from a text file and creates lots of lists/dictionaries and .... These data need to be accessed by other ...
1
vote
2answers
366 views

Is using multiple static classes with maximum one public method is a good idea

I'm writing a structural detailing (CAD) software for concrete buildings in C#. I have defined like hundreds of static classes each with one public method and if needed some private methods. Each one ...