A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

learn more… | top users | synonyms (3)

0
votes
2answers
21 views

What is the difference between an abstract method and an interface

An interface requires implementation of the specified functions in a class that implements the interface. An abstract function from an abstract class requires implementation in a class that extends ...
0
votes
1answer
162 views

Avoiding long list of interfaces

Motivation Let a project where... ... exists a lot different behaviors. For each behavior, there is an interface which has its possible actions. One object could perform a lot different behaviors. ...
1
vote
2answers
73 views

How can I have objects interacting and communicating with each other without forcing a hierarchy?

I hope these ramblings will make my question clear — I'd totally understand if they wont, though, so let me know if that's the case, and I'll try making myself clearer. Meet BoxPong, a very ...
-3
votes
0answers
43 views

Examples of modern, well designed C++ projects that don't use object-orientation? [on hold]

Does anyone know of any open-source, well-designed and moderately modern C++ projects that do not use an Object-Oriented approach? It could be either done in a functional fashion, or in a more ...
-4
votes
0answers
37 views

C# console app which calculate a volume of a box [on hold]

I'm new in C# and I'm trying to make a program which calculate the volume in decimals of a box. I made something but is not working. I would like to know what is wrong and see a solution. I need to ...
1
vote
2answers
44 views

Expressing interface inheritance in natural language [duplicate]

In object-oriented programming, when you extend a class you establish an is-a relationship between a new subtype and its parent(s), i.e. B is an A (aka code inheritance). When you compose a class with ...
20
votes
5answers
3k 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
2answers
86 views

How would you structure your code for a Neural Network? [on hold]

I understand how Artificial Neural Networks work. However, implementing one in code is quite another thing. How would you go about designing the classes and data structures? I found one great ...
-4
votes
0answers
32 views

Shadowing vs Inner class's access only to final variables [on hold]

In Java : Shadowing allows us to modify any variable with same name in an inner block but how is it possible when we have access only to final variables in an inner class?
1
vote
2answers
81 views

In javascript, should object properties be declared on top of the function?

I learned that it's good practice to declare variables before they are used. For example: function myFunction() { var i; var j; } Does the same thing go for object properties, and is there a ...
3
votes
2answers
103 views

Domain object model: query by id vs object

Let assume I have two simple model classes: Product and Brand It is obvious I have a query method in Product class like this Product product = Product.findById(123); What if, I want to query ...
8
votes
4answers
393 views

Is Visitor Pattern valid in this scenario?

The goal of my task is to design a small system which can run scheduled recurring tasks. A recurring task is something like "send an email to administrator every hour from 8:00 am to 5:00 pm, Monday ...
2
votes
2answers
223 views

Lesser of two evils regarding return types

I'm implementing a system in PHP where values are represented with objects that implement an Amount interface. I'm building two different implementations of this interface, one using a simple integer ...
0
votes
2answers
76 views

Refactoring case-when statement [duplicate]

The Product model which can have 2 price tables. The method price calculates the price of the product based on product's price table which is defined by price_table field. class Product < ...
2
votes
2answers
164 views

return a object without returning the reference

i'm having some trouble with returning objects and lists of objects. To problem is I want to return a object in my example an developer but I don't want to give the reference. What's the best ...
-1
votes
2answers
199 views

which one is recommended object-oriented design? [closed]

I made simple object-oriented prgram, and think about design. I wonder which one of belows is recommended object-oriented design. Most left side class is "Main" class. Black arrow means they are "Has ...
52
votes
7answers
8k views
+50

How do you avoid getters and setters?

I'm having something of a hard time with designing classes in an oo way. I've read that objects expose their behavior, not their data; therefore, rather than using getter/setters to modify data, the ...
19
votes
3answers
3k views

The principle of least knowledge

I understand the motive behind the principle of least knowledge, but I find some disadvantages if I try to apply it in my design. One of the examples of this principle (actually how not to use it), ...
0
votes
2answers
62 views

Are static methods of a class part of its type?

As far as I understand it, classes –as they are supported in OOP languages such as C++, Java, and Scala – define the type of each object I can instantiate with that class. Not all features of a class ...
1
vote
2answers
46 views

Module based project vs Normal project [closed]

I am writing code on top an established Enterprise application. I see that the application has 4 modules as shown below. -Srk -SrkEJB -SrkUtils -SrkWeb I have gone through the code and I see that ...
2
votes
4answers
155 views

How wrong it is to have multiple associations between classes?

I'm modeling a college process, in which I have three classes: Student, Subject and Degree Degrees have their own subjects, students have a list of subjects they have passed, and also students should ...
3
votes
2answers
292 views

How do I override the Type of members in a base class from the derived class?

I have two classes that know each other in a many-to-many relationship. Now I want to have two additional classes that inherit from the existing classes. The association between the inherited classes ...
-1
votes
0answers
6 views

eclipse acting weird when creating methods [migrated]

I don't see what could be wrong here, I was working on a different method but had some problems so I tried to simplify it to check where could the mistake be but I ended going up into this very simple ...
2
votes
1answer
69 views

C++: Make classes immutable or compatible with STL containers

Making types immutable is often desireable, especially for multi-threaded applications. There's no need to worry about concurrent access and no need for any synchronization. The common STL containers ...
-2
votes
0answers
59 views

OOP vs ADM Comparisom

This is the ADM equivilant to the example code given in Correct placement of Methods in OOP In this example we have resolved the Method placement question by moving ALL methods away from the data, ...
3
votes
1answer
86 views

OO design in a data processing pipeline

I'm wondering how to design a fairly simple class whose properties are complex to compute. Also, the properties depend upon each other for computation. An example using graphs and graph processing ...
3
votes
1answer
260 views

Correct placement of Methods in OOP

Which Class should contain a method which has dependencies on multiple classes? I've coded up a specific example to avoid generalizations. In this example we have an initial requirement : ...
3
votes
3answers
318 views

Functional vs object-oriented style in C#

I'm learning functional programming and face the following confusion when applying it to my C# projects: I begin by writing pure, static functions and use function composition. After the code ...
0
votes
0answers
69 views

Is using Interface implemented by single class a not recommended practice? [duplicate]

I have several classes in C#, not just POCO class but with methods and implementations. Each of those classes implement one Interface. e.g. IPerson implemented by Person class. Employee implements ...
9
votes
6answers
392 views

Does it always make sense to “program to an interface” in Java?

I've seen the discussion at this question regarding how a class that implements from an interface would be instantiated. In my case, I'm writing a very small program in Java that uses an instance of ...
2
votes
1answer
256 views

Should all functions be fully self-contained (is it bad practice to share a variable between functions)?

There are two ways to do the same thing (pseudo code) Define databaseHandle in the parent function, and use it as a global in this scope: function API() { function openDatabase() { ...
2
votes
1answer
54 views

Which approach for coding a 'texture atlas'?

For a game project, I have a couple of textures coming from multiple sources and I need to pack all these within a single texture atlas. Example for a racing game circuit, there are textures for : ...
0
votes
1answer
65 views

Strategy pattern can use this pointer?

I want to use strategy pattern, but I wander if it is correct to use "this pointer" with the strategy pattern interface. This is required in order to get internal information which is required for ...
4
votes
4answers
323 views

Legitimate cases of having .equals() behaving inconsistently with .compareTo()?

Java documentation says it's "strongly recommended" to have them behaving consistently. But are there legitimate cases of java/c#/python/etc Object.equals() method behaving inconsistently with the ...
1
vote
4answers
195 views

Is there a name for refactoring technique that turns hardcoded values into configurable parameters?

What is that technique called when you take values in the code that are hardcoded and make them variable, possibly constructing elaborate OO constructs to make that variable properly configurable? ...
2
votes
2answers
207 views

When it makes sense to implement C# explicit operator?

Follow-up of Is my usage of explicit casting operator reasonable or a bad hack? One of the users commenting on that question said that it's really bad if the casting operator creates a new object ...
22
votes
5answers
3k views

Is my usage of explicit casting operator reasonable or a bad hack?

I have a big object: class BigObject{ public int Id {get;set;} public string FieldA {get;set;} // ... public string FieldZ {get;set;} } and a specialized, DTO-like object: class ...
34
votes
2answers
2k views

Why do methods that take an unlimited amount of parameters often define overloads with fewer parameters?

For instance, the System.IO.Path.Combine method in .NET has the following overloads: Combine(params String[]) Combine(String, String) Combine(String, String, String) Combine(String, String, String, ...
-2
votes
1answer
36 views

ClickHandler for button = strategy pattern? [closed]

If you provide a implementation of a ClickHandler interface to a button (defining some behaviour), is this the strategy design pattern?
5
votes
4answers
680 views

How to add a property to an object you can't change?

Let's say that I'm using a library and I would like to add a property that doesn't exist to an existing class. In this case, I'd like to add Color as a property of Fruit. namespace Library { ...
1
vote
2answers
93 views

Should method names getX and setX only be used for fields and have no other effects? [duplicate]

Should I avoid using getX() and setX() as names for methods that aren't "traditional" getters or setters? (Let's define traditional as it only gets/sets the field and has no other effects.) I guess ...
-2
votes
0answers
27 views

PHP Static and Normal Functions Calling [migrated]

Can someone explain how these line of code are working class DemoStatic { function normalFunction() { echo "This is the normal function"; } static function staticFunction() { echo "This ...
1
vote
2answers
139 views

Is MVC controller an use case controller?

In GRASP (http://en.wikipedia.org/wiki/GRASP_(object-oriented_design) ), a controller (use case controller) is defined as: A use case controller should be used to deal with all system events of ...
4
votes
4answers
875 views

Is it always a good idea to divide large classes into smaller ones? [duplicate]

I've heard time and time again that in object-oriented programming, you should try to split objects that 'do too much' into multiple classes, to avoid the "God Object" problem. This seems like fine ...
-1
votes
2answers
173 views

Mermaid problem (OOP) [closed]

A Mermaid is half fish and half human. It has upper human body and lower fish body. When under water its upper part swims like a human while its lower part swims like a fish. Please explain how can it ...
2
votes
1answer
48 views

Keeping lists of Objects, some with, some without inheritance

Let's say I have two classes, Foo and ExtendedFoo where ExtendedFoo inherits from Foo. Foo has a method .getValue() which returns a number, ExtendedFoo also has .increaseValue() which adds to the ...
2
votes
1answer
166 views

Advantages of having numeric data types as classes rather than primitives [closed]

I was wondering about why some languages choose to implement numeric types (boolean, integers, floats, characters etc.) as classes/objects (eg. Kotlin) and some as primitive types (eg. Java). I am ...
0
votes
1answer
103 views

Access fields of super class from derived classes [duplicate]

There is an abstract BaseGame class that will be inherited by specific game classes. This class has an attribute requestHandler that will be used in all subclasses and should be initialized in the ...
0
votes
0answers
46 views

Should URL params and request params be stored in the Request object

Is it acceptable if GET parameters don't reside in the Request object, but in the URL? I am writing a small library in PHP, which is to represent the Request/Response as different entities and ...
4
votes
2answers
159 views

Why is it bad to have one mechanism for inheritance and subtyping?

It is quite well-known that (class) inheritance and subtyping (sometimes called interface inheritance) are different things: inheritance is a mechanism for sharing code, while subtyping is a ...