Questions tagged [object]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
0answers
27 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 ...
1
vote
1answer
54 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 ...
-2
votes
1answer
323 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?
1
vote
2answers
166 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
0answers
362 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 ...
16
votes
4answers
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. ...
3
votes
1answer
219 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: ...
1
vote
3answers
5k 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 ...
0
votes
2answers
1k 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 ...
1
vote
1answer
69 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 ...
0
votes
1answer
3k 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 ...
1
vote
1answer
250 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
394 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 ...
0
votes
1answer
1k 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....
1
vote
1answer
436 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 ...
2
votes
3answers
595 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 ...
0
votes
2answers
179 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.
4
votes
1answer
2k 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 ...
-2
votes
1answer
111 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 ...
-1
votes
1answer
4k 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, ...
4
votes
3answers
3k 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 ...
4
votes
2answers
164 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 ...
7
votes
4answers
271 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 ...
1
vote
0answers
26 views

Optimizing/monitoring number of objects created by $(this)

I have an application where a lot of objects are created and referenced by $(this) similar to the following: someFunction() { var myName = $(this).find(".name"); var myTown = $(this).find("....
3
votes
1answer
121 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 ...
1
vote
1answer
3k 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 ...
2
votes
2answers
1k 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 ...
1
vote
1answer
390 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 ...
0
votes
1answer
143 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 ...
-1
votes
3answers
163 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" ...
3
votes
2answers
449 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 ...
2
votes
1answer
112 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 ...
1
vote
0answers
434 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 ...
15
votes
4answers
199k 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 ...
3
votes
1answer
7k 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 ...
1
vote
0answers
417 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("...
82
votes
13answers
12k 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 ...
2
votes
2answers
272 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. ...
-3
votes
1answer
5k 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 ...
1
vote
4answers
396 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 ...
29
votes
6answers
7k 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....
-3
votes
1answer
277 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'...
3
votes
1answer
255 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, ...
1
vote
1answer
637 views

Under what cirumstances would type 'System.Object' qualify for serialization?

I'm in charge of a comprehensive serialization format with support to serialize runtime objects (any derived type of Object). I can't find a sane scenario where one would choose to serialize an ...
0
votes
1answer
252 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 ...
1
vote
1answer
84 views

Object Storage where Object Type is variable

From time to time, we come across a problem where we must store an object, but we don't know in advance what kind of object we're going to store. I'm going to give a very simple example. Requirement: ...
4
votes
3answers
283 views

Better way of manipulating large objects

I am doing a lot of work with SOAP Api in PHP and the objects that are returned are quite big. I am then updating the objects from local db changes and pushing them back. So more often than not I ...
1
vote
5answers
704 views

Understanding basics of object declaration in Java

Is there a case when an object is declared without a call to the constructor? as in, for example: ArrayList<Integer> grades; Or is it always the case that ArrayList<Integer> grades (as ...
2
votes
1answer
2k 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# ...
2
votes
3answers
2k views

Overriding equals() method in Java

Short question: Why does Java allow overriding equals(), why is it not final? I am reading Effective Java 2nd edition by Joshua Bloch. I am a bit baffled by the conclusion that There is no way to ...