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
1answer
57 views

Pattern that prevents events to trigger themselves

I am working at the client-side part of a web application, that is responsible for getting answers from users for specific questions and storing and restoring them from the database (or cookies) and I ...
1
vote
1answer
137 views

Java and rest OOP languages - when to use super or this keywords

I have been programming java for like a year or more, and i have always used the this and super keywords. And yesterday my mate read one source of mine, and told me not to over use it unless you are ...
0
votes
4answers
111 views

Should each method have a seperate JUnit test class?

I am writing JUnit unit tests for my classes. Is it better to have a separate class for each method, or have just one test class for every actual class?
0
votes
0answers
35 views

Domain-specific Interfaces

Are there any real benefits of using interfaces over abstract classes in a domain model? Does anyone have any experience using interfaces in a domain model in a real project? From a technical ...
-1
votes
6answers
401 views

How does polymorphism help a programmer? [on hold]

I have been trying to understand the importance of the concept of polymorphism in Java, and I understand that it means to use a interface's object to call subclass methods. I've been reading an ...
0
votes
1answer
73 views

OOD: class hierarchy with method arguments forming another hierarchy

I'd like to find out how do you guys handle the following situation: you have a class hierarchy, call it H1, with some polymorphic method that is supposed to accept an argument which type forms ...
1
vote
1answer
177 views

Which is the more testable C function implementation?

I write code in C. I have been striving to write more testable code but I am a little confused on deciding between writing pure functions that are really good for testing but require smaller functions ...
-3
votes
0answers
84 views

C# Implementing filtered Iterator without using yield return [migrated]

I'm trying to display elements of a list with filter and without filter. Here, I use the filter in such a way to display the elements which are divisible by 3. I'm going to use Enumerable and ...
1
vote
2answers
96 views

Should an abstract class always abstract its methods to an interface?

I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this - abstract class a{ public int i; public int ...
20
votes
1answer
297 views

How are mixins or traits better than plain multiple inheritance?

C++ has plain multiple inheritance, many language designs forbid it as dangerous. But some languages like Ruby and PHP use strange syntax to do the same thing and call it mixins or traits. I heard ...
-4
votes
0answers
61 views

Best book to learn OOP in Java if you know C/C++ at beginner level? [closed]

Which is the Best book to learn OOP in Java if you know C/C++ at beginner level? Or What is the best way to learn JAVA and OOP in case one knows C/C++?
-2
votes
1answer
119 views

Implementing IEnumerator without using 'yield return' in c#

I'm new to C# programming, I was experimenting with iterators concept in C#. Here, I'm trying to display all the terms in a list, for that I'm trying different ways to obtain the results. In the below ...
2
votes
3answers
315 views

What is a good design for a method that can return several logically different results?

The question title is probably too abstract, so let me provide a particular example of what I have in mind: There is a webservice that encapsulates a process of changing passwords for users of a ...
4
votes
2answers
194 views

What are the key differences between Java's and Python's OOP support? [closed]

The only language I've ever used is Java. I like it a lot but decided it's time to learn another language :) . I'm interested in learning Python. It seems like a good choice because it's partly ...
2
votes
2answers
118 views

Calling same method on different object - Recursion?

I have an object that contains a reference to another object of the same type. Example in PHP: class A { protected $child; public function __construct(A $child = null) { ...
4
votes
1answer
74 views

Keep or discard tests that use methods now private [duplicate]

When writing object-oriented code from scratch, I try to follow these steps: Write a test that fails. Write a function that makes the test pass. When enough tests and functions are complete, ...
1
vote
3answers
217 views

How are OOP “objects” and “classes” organized in memory in terms of assembly language?

How object is organized in memory? For instance, I know, that function is piece of code at the memory, which expects parameters via stack and/or registers and handles their own stack frame. But ...
1
vote
2answers
127 views

Sanity check for design pattern used with an intricate calculation model

I am working on a project that generates technical brochures in batch. The 3rd party API that is being used expects POCOs with property names that match field names used in each of the brochure ...
3
votes
1answer
730 views

does this model-pattern have a name?

A few years back, I wrote this answer to a question from which the following idea emerged. I call these "Type Descriptors", as I have never been able to find this pattern documented or formally ...
2
votes
2answers
242 views

Does it make sense to use interfaces if you don't have polymorphism?

Suppose I have distinct classes that have the same behavior, which can be represented like this: public interface Behavior { void operationA(); } public class ImplementerA implements Behavior { ...
3
votes
2answers
295 views

Have there been studies on the effectiveness of OOP in managing software complexity?

OOP is often regarded as an effective strategy of managing complexity in software, as opposed to non-OOP procedural programming. Have there been any studies testing this notion? Is it proven that OOP ...
1
vote
2answers
84 views

How specific should be an interface about its implementation details?

Perhaps I should have picked a better title, but anyway... Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different ...
0
votes
0answers
19 views

How to deal with multiple output modes of multiple types?

Note: The business domain being a bit complicated to explain, I replaced the names of actual classes by more illustrative examples. I'm writing an application in which the business layer returns a ...
2
votes
4answers
138 views

Subclass only have methods without variables

Is it ok to have subclass which does not declare its own variables (instance variables) and inherits from super class or base class? It has methods and there are some common methods which it overides ...
0
votes
1answer
70 views

software design for client/server, over sockets, with JDBC [closed]

What's a reasonable architecture and design for a client/server application, over sockets, using JDBC? Right now I have the server query the database and instantiate a Queue of records. Clients may ...
1
vote
3answers
176 views

Sequence diagrams and the Implementation

In the design phase we create UML Sequence diagrams (in OOD). My understanding is that after creating an Use Case diagram if we need to show further information in terms of time sequence of events of ...
8
votes
2answers
372 views

Why shouldn't I make variables public, but should use public getters/setters? [duplicate]

I'm watching a C++ tutorial video. It is talking about variables inside classes and assert that variables should be marked private. It explains that if I want to use them publicly, I should do it ...
2
votes
5answers
297 views

Classic inheritance problem?

I keep seeing the following pattern when people learn about OOP: Problem: How do I put objects of different but related types into a container? Solution: Inherit from a common base class. New ...
3
votes
3answers
425 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
3
votes
2answers
242 views

What's a good simple way to combat the n+1 problem?

I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this: $posts = Posts::getPosts(); foreach($posts as $post) { ...
1
vote
0answers
76 views

Do serialization functions belong in a model or a controller?

I'm developing an application where: Models keep data as a multi-dimensional array, which are saved as-is to a MongoDB database. The model is used to provide methods to manipulate the data, and ...
2
votes
2answers
249 views

Repository pattern implementation that knows nothing about the database table and column names

I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a ...
0
votes
2answers
131 views

Is it a good idea for JS objects to draw themselves when the page loads?

So normally I would only use JS to modify the dom after the user interacts with something or some event goes off. This seems right for some reason. But I'm developing a widget based app where widgets ...
1
vote
1answer
136 views

How to structure a program into classes [closed]

So after a while of working in programming field I still haven't figured it out how exactly should programs be structured, in a large set I mean. Which I think it's also because of working in an ...
3
votes
3answers
364 views

Why shouldn't an object reference have access to a static member in C#

Context of my question: I am reading C#. Trying to understand Static keyword. I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class ...
4
votes
3answers
149 views

Is it a good idea to return a default value if a field in a query cannot be found?

At the place I work we are using a SafeReader class that wraps an IDataReader. One of the 'features' is that if the field you are trying to access wasn't in the query then it just returns a default ...
18
votes
3answers
1k views

Why is a private member accessible in a static method?

The following is pseudo code, I tried it in Java and PHP and both worked: class Test { private int a = 5; public static function do_test(){ var t = new Test(); t.a = 1; ...
-6
votes
1answer
128 views

Does one really need multiple instances of a class? [closed]

Generally I'm extremely skeptical of anyone who criticizes the singleton design pattern in software. In the MVC (model-view-controller) design pattern, views and controllers are usually singletons and ...
2
votes
1answer
144 views

Structuring a storage system for a game

I am working on a multiplayer game, where a player has many storages to store items in. Storage Storage is the system that allows the user to deposit items, and take them back. Example of storage ...
2
votes
1answer
190 views

Design Patterns for creating tasks

I am developing software where each action in my entities need create tasks that will be execute in my infrastructure. When I create a task it is only records in the database. Afterwards, a windows ...
0
votes
2answers
152 views

Good architecture for passing data to multiple APIs

I have a hypothetical scenario where I need to pass data to APIs from multiple different providers, depending on the 'vendor identity' provided by one of the pieces of data. If I have the data as ...
2
votes
2answers
251 views

Project based prefix for class names

My project leader uses project based prefixes for class names, lets say projects name ABC, he create User class name as ABCUser. and he says he do this becasuse if he wants to make User.aspx Users get ...
0
votes
1answer
76 views

When to used static visibility? [duplicate]

I can't attain the primary used of Static Visibility. My question is why they used static method & properties in this code? class PassHash { // blowfish private static $algo = '$2a'; ...
12
votes
8answers
1k views

Mental Models or Real-World-Metaphors for Functional Programming

Does anyone have a good mental model or metaphor for functional programming which references something in the real world? Object Oriented programing intuitively makes sense to me. There are things ...
6
votes
6answers
472 views

How to avoid downcasting?

My question is about a special case of the super class Animal. 1. My Animal can moveForward() and eat(). 2. Seal extends Animal. 3. Dog extends Animal. 4. And there's a special creature that also ...
0
votes
0answers
63 views

Why use subtyped functions?

Say you have arguments A1 >: A2 (contra-variant), and return types B1 <: B2 (covariant). The corresponding functions are such that: A1 => B1 <: A2 => B2 Sometimes, this makes sense to me - ...
35
votes
11answers
4k views

Are error variables an anti-pattern or good design?

In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to ...
0
votes
2answers
133 views

Expected error handling

Let's say I have a social media website. On this website, users can upload several pieces of information about themselves, including their phone number. To implement this, I have a class called ...
1
vote
1answer
73 views

Should state machine with synonym states be shown explicitly?

I am new to state machine modeling and while trying to model a system, I have a question. An example will explain it better: Considering a system that does calling (probably a customized cell phone ...
2
votes
0answers
67 views

The inheritance argument of zope.interface (providedby vs isinstance)

What limitations does inheritance of an interface through an abstract base class present that are addressed by zope.interface? In the following talk given in 2010 by Jeff Rush about interfaces, at ...