The tag has no usage guidance.

learn more… | top users | synonyms

-2
votes
1answer
91 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 ...
-3
votes
1answer
108 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
323 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
123 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 ...
1
vote
0answers
26 views

Can the Flock of Features Algorithm track a arbitrary object?

I want use a mobile device to track an arbitrary object, I found the Flock of Features algorithm but it seems like its only working for hands. It uses also color information to track them, so im not ...
8
votes
4answers
206 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 ...
0
votes
0answers
23 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
99 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
190 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
207 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 ...
0
votes
1answer
57 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
90 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
141 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" ...
2
votes
2answers
102 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
86 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
1answer
165 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 ...
1
vote
4answers
9k 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 ...
1
vote
1answer
550 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
268 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("...
75
votes
13answers
8k 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
256 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
379 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 ...
0
votes
4answers
253 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 ...
28
votes
6answers
5k 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 ...
-2
votes
1answer
103 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
233 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
243 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
193 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
69 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
188 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
348 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 ...
0
votes
1answer
440 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# ...
0
votes
3answers
683 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 ...
0
votes
1answer
347 views

Job and workers, pattern / design

I have x number of worker classes which all implement a specific interface, i have a job descriptions Each job description States the different worker classes that should execute to complete the job ...
2
votes
2answers
424 views

What is the purpose of creating a member function with the same type as its class?

I'm sure I'll botch some of the specific terminology, but what is the difference between object and object2 in this implementation? Is the only purpose of the first method (prototyping the class's ...
0
votes
1answer
375 views

Android, using a Fragment to hold/edit complex object, accesible from any Activity

I'll do my best to describe the problem, but I'm still very new to several concepts that I think this problem requires to be solved (namely interfaces and threads). I should preface this by saying ...
0
votes
1answer
142 views

Should an object query its owner?

I have a World class World: def __init__(self): self.size = 10 self.n_busStops = 10 self.busStopMatrix = SpatialGraph(self.size, self.n_busStops, 1.0) self.buses =...
1
vote
2answers
945 views

Instantiating objects in Java [closed]

I'm learning now Java from scratch and when I started to learn about instantiating objects, I don't understand - in which cases do I need to instantiate objects? For example I'm studying from TutsPlus ...
1
vote
1answer
131 views

Replaceable parameter syntax meaning

Replaceable parameter syntax for the console object in C#. I am taking the O'Reilly C# Course 1 and it is asking for a replaceable parameter syntax and it is not very clear on what that means. ...
18
votes
11answers
4k views

When would you want two references to the same object?

In Java specifically, but likely in other languages as well: when would it be useful to have two references to the same object? Example: Dog a = new Dog(); Dob b = a; Is there a situation where ...
1
vote
1answer
484 views

Using class like an object in Python

I am learning from Learn Python the hard way where I have come across a study drill where they want to know that whether a class can be used like an object. As I have experimented: class A(object): ...
2
votes
2answers
353 views

Three variants of circular references between objects: how to choose?

I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least ...
4
votes
5answers
2k views

Why is there no deterministic object destruction in Java? [duplicate]

I understand and enjoy the benefits of the Garbage Collection in Java. However I don't understand why there is no way in Java to explicitly (and quickly) destroy an object. Surely this could be useful ...
6
votes
2answers
2k views

What is the process of determining which method in a class hierarchy should execute known as?

I thought I understood inheritance and polymorphism, but I was given this question, and I can't, for the life of me, figure out what the proper answer is or what they're trying to get at: The ...
-1
votes
1answer
359 views

Size of objects during Multilevel inheritance [closed]

Below is a pseudo declaration for a multilevel inheritance. Base class ( protected int data) derived1 : virtual public base ( protected int data1 ) derived2 : virtual public base ( protected int ...
1
vote
5answers
305 views

Clarification about Polymorphism / Inheritance

I am trying to better my understanding of polymorphism. Say I have a base class called baseClass with one method called foo() and I have three derived classes called derived1 , derived2 and derived3 ...
-1
votes
2answers
280 views

Difference between a pointer and a reference? [duplicate]

In Java and other high-level languages, a reference leads to an object. In C++, as far as I know, a pointer can also lead to an object. So what's the difference between a reference leading to an ...
4
votes
1answer
459 views

Modelling Login and Authentication on an iOS mobile client

I'm about to start working on a V2 of a mobile application and I'd like to adopt a more object-centric approach. Primarily because I think it makes for more maintainable code, but a secondary ...
14
votes
3answers
4k views

How many strings are created in memory when concatenating strings in Java?

I was asked about immutable strings in Java. I was tasked with writing a function that concatenated a number of "a"s to a string. What I wrote: public String foo(int n) { String s = ""; for (...
3
votes
3answers
2k views

Arrays vs Objects in view template

I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays {{$user->zip_code}} vs {{$user['zip_code']}} I'm ...