New answers tagged

1

I don't particularly see an issue with allowing either a string or a list of strings as an argument, as long as you handle both cases gracefully. For example, the pandas.DataFrame.groupby method does exactly that, allowing you to call it as any of the following: df.groupby('foo') df.groupby(by='foo') df.groupby(['foo', 'bar']) df.groupby(by=['foo', 'bar']) ...


2

It might be confusing to users of this library if the function takes parameters as a single string or list of strings. Search logic is prone to complexity due to the number of criteria. Introducing a parameter object gives users of this library something concrete to use when calling the search function. Since you can search by a single name or multiple names,...


3

The Use Case and Activity diagrams are high level things showing how the users (Actors) are going to interact with the system. At this stage there will be no classes or methods. Class Diagrams and Sequence Diagrams are the details of what's going on in your system to implement the high level stuff. You can't really have a sequence diagram without the methods....


0

In a class diagram, how do I know what class methods to add? That depends entirely on why you are creating the diagrams in the first place. If you are creating the diagram with the purpose to generate code from it, then you need to add all the methods of the class to it. Otherwise, the code generator doesn't know it needs to generate those methods. If you ...


0

Already some very good answers here, in particular Helena's. I'd nevertheless would like to add a couple of ideas missing in the other answers. Member function or not? The C++ Core guidelines, recommend: Make a function a member only if it needs direct access to the representation of a class In your specific case, IHittable are shapes, and you need to ...


4

Based on the extra information, this sounds quite similar to a problem in GUI design: avoiding unnecessary refreshes. An example might be having an event that changes the content of a textbox and another that changes the color of the textbox. Here's a discussion of the problem in React, for example. It's quite difficult to avoid in general. Possible ...


0

You are completely missing the point. If I change the width of a rectangle then the height is unchanged. Your square class breaks that. As long as you are aware of the LSP violation, feel free to make square a subclass of rect. Change the implementation of setWidth and setHeight to assert(). If you like add a method setWidthAndHeight() which asserts if the ...


0

The question is: will you have any benefit from using classes. A class is a template. If you have more than one instance at the same time, it maybe worth using classes. Or you have internal structures in different objects, that are very similar, but not identical. Then you can use classes and inheritance to avoid redundant code. But if you can do something ...


0

The only OO paradigm i know is, that objects can care for their own needs. Why not use both and let the object decide, which applies best? Initially, you only store the user name and leave the reference empty. First time, the object is used, it finds the reference empty and can retrieve the user reference. So, you only need to fetch the reference once. And ...


0

The DOM itself applies far better to object oriented structures than most people think, at is is stateful itself. So, if you let JS-Objects create your DOM elements, you can access the DOM state directly without any overhead. But this means: one JS object for one DOM object. Currently, you are using a class, but inside this is more or less functional ...


7

Using references to other objects, has the advantage of using OOP spirit and ensuring very fast navigation. But it requires all related objects to be in memory. And this is a very hard constraint for many real life applications: performance constraint: you need to upload thousands of related users and posts (even very old and unrelevant ones), just for ...


1

In O.O.P. references / pointers are preferred to the most imperative / procedural index usage, since it's more related to the O.O. paradigm ( "way to solve things" ). Yet, in some circumstances, indices or text keys may be used, depending on the requirements, like an array collection, or a text dictionary collection.


Top 50 recent answers are included