Questions tagged [object]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
193 views

Opaque objects on the stack / in structs

I have a collection of opaque objects and related functions API. Such objects are typically created on the heap, but that involves a non-trivial amount of overhead. And when aggregate together, that ...
user avatar
  • 607
4 votes
7 answers
4k views

How do interactions between objects work?

I am getting confused when objects interact using OOP. Here i'm trying to model the interaction between a vending machine and a coin. The coin is inserted into the vending machine. The interaction is ...
user avatar
1 vote
1 answer
127 views

If methods are actions that an object can perform, how do we represent abstract objects?

I have read that objects contain the actions it can perform as functions and its attributes as variables. But i am getting confused with objects that don't seem to perform any actions such as an ...
user avatar
2 votes
2 answers
225 views

How to model relations in UML Class and Object diagram for simple Graph structure

I'm trying to model a simple Graph structure as an UML Class Diagram and Object Diagram. A Graph can have multiple Nodes and knows it's starting Node. Every Node has a predecessor and a successor Node....
user avatar
  • 123
1 vote
3 answers
101 views

Constructing an Object from Multiple Services

I have an object that contains several dozens of properties. A portion of property values come from Service A, others from Service B, and the remaining from Service C. This object is a flat model that ...
user avatar
  • 165
-2 votes
1 answer
55 views

Simple OO/normalization question - common fields in new table/separate object?

I am working on an app and creating models now. I think this is a basic 1N normalization question but am not sure. Should I break location/address out as a separate table? Let's say I have Parents ...
user avatar
1 vote
3 answers
144 views

Should we consider immutability for local scoped variables

I have the following code: const string endPoint = @"foo{0}?pageNum={1}&itemsPerPage={2}"; const int itemsPerPage = xxx; InvoiceCollection response = await _apiClient .GetAsync<...
user avatar
  • 215
3 votes
5 answers
770 views

Design pattern for objects in invalid states

General design pattern for object error state Consider a simple class Wallet that models a wallet. A Wallet contains a certain amount of Wallet.Cash and it is possible to take money out / put money ...
user avatar
  • 169
1 vote
1 answer
42 views

Determine array of objects collective identity and be able to inspect it

I have an array of objects and I'm trying to see, through each request, whether or not a new member appeared in my collection. The way I currently do it is, I require each member of the collection to ...
user avatar
  • 641
1 vote
1 answer
1k views

HashMap versus Object ? Which one is better to finally generate JSON output with KEY and VALUE

I do have this use case. callers(APIs in same microservice or different microservices) wants to report different KEYS and VALUES as an audit as part of their methods. There is a high possibilities ...
user avatar
  • 119
0 votes
1 answer
4k views

Ordered vs sequence in association in UML

I am trying to understand UML class diagrams. Imagine two classes that are related with each other by association. What is the difference between {ordered} and {sequence} for the association?
user avatar
1 vote
2 answers
503 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?
user avatar
0 votes
0 answers
877 views

Examples for bidirectional and unidirectional relationships between objects

To better demonstrate the difficulties of reading/updating objects in a multithreaded environment, I'm looking for examples for groups of objects with a bidirectional or unidirectional relationship ...
user avatar
  • 267
17 votes
4 answers
1k views

Unable to solve mystery of functions in Javascript

I am trying to understand behind the curtain scenes of Javascript and kind of stuck in understanding the creation of built in objects, specially Object and Function and the relation between them. ...
user avatar
3 votes
1 answer
269 views

Object creation based on type from parallel hierarchy without instanceof (Java)

I have two parallel hierarchies: B and C implement interface A D and E extend the abstract class F I want to be able to do: F f = createObject(A a) where createObject should follow the behaviour: ...
user avatar
  • 141
2 votes
3 answers
9k views

How to avoid != null statements? [duplicate]

I use code object != null to avoid NullPointerException. Is there a good alternative to solve this as follow ? if (someobject != null) { someobject.doCalc(); } This will not work for ...
user avatar
0 votes
2 answers
2k views

Object vs Primitive: Not use long primitive because... the default value is zero?

Today my college presented to me an argument about not use some primitives that I never heard before. I would like to see what you guys think about it. We have a class in our project like: class ...
user avatar
  • 2,257
1 vote
1 answer
85 views

Can I avoid using variable types that bypass type checking when using a library that provides largely identical but unrelated models?

I have a situation whereby I'm using a library that's been generated to provide an XML interface in C# based upon an XSD file run through xsd.exe. The XML is structured as so. -Results -ModelA ...
user avatar
  • 119
0 votes
1 answer
4k views

Object constructors with dynamic parameter lists

I had a quick question and I was hoping someone could help me figure this out. I'm new to Java and I'm trying to learn about classes and objects and I see you can call parameters in the constructor of ...
user avatar
1 vote
1 answer
265 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 ...
user avatar
1 vote
2 answers
953 views

multiple getters for some fields

I have 2 DTO which have equivalent fields so what I did is I make them implement one interface to treat them same way as a type of interface (avoid duplication) so I put in the interface some Getters ...
user avatar
-1 votes
1 answer
3k views

Where to put the behaviour of DTOs ? Object vs Data structure clean code

Similar question was posted here https://stackoverflow.com/questions/21064164/clean-code-how-to-design-this-class I still don't find an answer though, I'm confused! I read the book "clean code" too....
user avatar
1 vote
1 answer
572 views

Abstract factory design pattern

I need help with an abstract factory pattern design.I have and calculation engine which calculates for different channels like captive, captiveTemplate or Headquarter and in the future different ...
user avatar
3 votes
3 answers
901 views

Should only static functions print to screen?

My question is more about trying to figure out if my belief is correct or valid in that a static method should be the only one that prints to the screen (let's say in a terminal). I am using Java and ...
user avatar
0 votes
2 answers
468 views

How do I determine the visibility of "objects" as defined in the C programming language?

This question was asked by my professor in an exam and I couldn’t find an answer on Google, so here I am. I don't understand what objects are in C at all.
user avatar
  • 121
4 votes
1 answer
3k views

(Dis-)Advantages of storing objects in relational database?

In an off-hand comment on this question about storing PHP objects in a MySQL database I mentioned that it is probably not a good idea to do so. My reasoning is that MySQL is explicitly a relational ...
user avatar
  • 153
-2 votes
1 answer
116 views

C++ Loop object "pairs" with one in common

I could not think of a better name. I have a class called MoveObjects which holds position and move info. Then I have two classes, Items and Attacks. Both have MoveObjects in common. What I am ...
user avatar
1 vote
1 answer
9k views

How do I remove all instances of a key from a JavaScript Object? [closed]

I've got a Java Script object like this: let obj = { selected; true, level1: { level2: { selected: true } } level1: { selected: true, ...
user avatar
  • 145
4 votes
3 answers
4k views

Why instantiate and initialize an object without saving it into a variable?

Sorry if I got the wording wrong in my title, but it would be easiest to provide an example in JavaFX primaryStage.setScene(new Scene(grid, 300, 275)); Now from what I understand, this code is ...
user avatar
  • 41
4 votes
2 answers
187 views

A question about implementing objects in a language written in C

I'm fairly new to programming (about four months learning), and have decided to mess about with an attempt at writing a language in C for both fun and practice, and am wondering how objects are ...
user avatar
7 votes
4 answers
305 views

When in your language classes are objects too, does the Liskov substitution principle apply to their interfaces?

According to Wikipedia the Liskov substitution principle states that objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program ...
user avatar
  • 321
3 votes
1 answer
126 views

PHP OOP, structuring my objects properly

I have an architecture similar to this: User (Name, Email, ID...) ---- Studios (Name, Location, Description...) ---------- Videos (Title, Description, URL, Length, Views...) Simply put, a user can ...
user avatar
  • 131
2 votes
1 answer
4k views

Destructing an object of a class correctly

I have a scenario, where I draw multiple graphs in same applications and each graph is an object of graph class. I want to delete the graph using event handling (button click event) and the event ...
user avatar
  • 131
3 votes
2 answers
4k 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 ...
user avatar
1 vote
1 answer
3k views

Summing values from JSON end point based on category [closed]

I have a JSON end point for projects in a county. I am able to call a list of any of the object properties. What I want to do is to add together either all the values of budget property or the ...
user avatar
0 votes
1 answer
170 views

Object oriented programming - subobject vs globals (use case) [closed]

I am developing a nethack-like game, and I would like an advice how to approach the design part. For now I got class like Location, Npc, Item etc. But I've got a problem how to easily access parts of ...
user avatar
-1 votes
3 answers
170 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" ...
user avatar
3 votes
2 answers
582 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 ...
user avatar
2 votes
1 answer
124 views

How to decouple SELF as a special word within Rebol objects?

Rebol has no keywords. It's a concept that forms a part of what makes the language so versatile—any word can be reassigned, any word can be assigned the value of a 'built-in' function—and one that in ...
user avatar
  • 355
1 vote
0 answers
482 views

When to use trait components, objects, package objects in Scala

When I am adding dependencies in Scala, I tend to use mixin trait components for those that are inherit to the class itself. For example, DaoGenerator extends Generator However, for trait components ...
user avatar
21 votes
4 answers
236k views

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

I'm very new to Java and want to understand the difference between class variables and instance variables. For example: class Bicycle { static int cadence = 0; int speed = 0; int gear ...
user avatar
5 votes
1 answer
11k views

Performance of sharing single object with multiple threads in Java

In Java, if I create an object that has a method to do something, and I pass that object to multiple threads which call the method, is there a performance difference from creating an individual ...
user avatar
  • 153
1 vote
0 answers
454 views

Why is deep plucking a bad idea?

Both underscore and lodash refuse to implement deep plucking, despite many requests from users and gists or modules that implement the feature. _([{o:{a:1}},{o:{a:43}},{o:{a:234}},{o:{a:23}}]).pluck("...
user avatar
85 votes
14 answers
14k 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 even a clear-cut non-physical conceptual object -- something that ...
user avatar
  • 8,021
2 votes
2 answers
276 views

interpretation of the statement in java

I am confused over the interpretation of the following statement Fruit x= new Fruit(); My interpretation is that the new operator along with Fruit(); creates a new object somewhere in the memory. ...
user avatar
-3 votes
1 answer
8k views

Java - Best way to set properties of an object [closed]

I don't know if there is any difference in performance, or its just a matter of choice, but I am a perfectionist like that, and I'd like to know. Lets say you have the object HolySheet. You can set ...
user avatar
  • 101
1 vote
4 answers
641 views

Is collection object better being immutable? [closed]

As per this link, it is an advice that: A good object should never change his encapsulated state. Remember, an object is a representative of a real-life entity, and this entity should stay the same ...
user avatar
  • 2,225
31 votes
6 answers
12k views

Can you implement "object-oriented" programming without the class keyword?

Say we want to provide an abstraction of an "account" in a bank. Here's one approach, using a function object in Python: def account(): """Return a dispatch dictionary representing a bank account....
user avatar
  • 2,225
-3 votes
1 answer
379 views

DDD - map or object [closed]

What is correct by DDD - should I create map of two objects eg Map or should i use more meaningfull object that will contain this pair MoreMeaningfullName{Obj1, Obj2} ? If using first approach, I don'...
user avatar
3 votes
1 answer
275 views

How do I design a Javascript Object to not use any public properties?

I have been playing with the Object creation outlined by Douglas Crockford in his new talk "The Better Parts" function constructor(spec){ var that = otherConstructor(spec), member, ...
user avatar