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
3answers
48 views

Dependency inversion without static methods?

It's clear that the dependency inversion principle and the use of interfaces makes software components less coupled and promotes maintainability. On the other hand, these principles make using static ...
21
votes
9answers
3k views

What's the proper way to model this real-world activity that seems to need circular references in OOP?

I've been wrestling with a problem in a Java project about circular references. I'm trying to model a real-world situation in which it seems the objects in question are interdependent and need to ...
0
votes
0answers
31 views

Design of a Smartcard listener [duplicate]

I have the task to write a listener which detects smartcards inserted into a terminal and notifies all registered classes. The listener needs to be accessible from different parts of a large ...
1
vote
1answer
178 views

Why can a constructor be used without `new` keyword in Javascript?

I found Date can be used without the new keyword. Date(1) > "Thu May 28 2015 15:54:20 GMT+0800 (CST)" new Date(1) > Thu Jan 01 1970 08:00:00 GMT+0800 (CST) I was wondering whether there is ...
0
votes
1answer
88 views

Passing same argument to multiple small functions versus doing everything in one big function?

I have inherited a class method from another developer, which looks like below: (Note: Class:X means X is a member of Class in the OOP paradigm.) Class:BigFunction() { ImportantValue = ...
0
votes
0answers
56 views

Addicted to Interfaces - Good or bad? [duplicate]

After 2 years of programming, I usually found myself using the following design pattern: public interface ISomeInterface { void SomeMethod(); void OtherMethod(); } public abstract class ...
4
votes
3answers
231 views

When is an object of real world a (computational) object of your program?

In an OOP design phase strategy, Any physical/conceptual object of a system can be modeled(considered) as computational object in your OOP designed program based on below two conditions: First ...
0
votes
2answers
117 views

What is the difference between an abstract method and an interface [duplicate]

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 ...
1
vote
1answer
273 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
92 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
54 views

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

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
42 views

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

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 ...
21
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
89 views

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

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
33 views

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

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
86 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
117 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 ...
9
votes
4answers
491 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
225 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
77 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
165 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
200 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 ...
55
votes
9answers
9k 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
63 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
47 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
156 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
294 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
71 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
62 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, ...
4
votes
1answer
88 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
262 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
322 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
402 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
260 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
67 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
325 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
208 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
683 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
94 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
149 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 ...