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
0answers
24 views

software design for client/server, over sockets, with JDBC

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
148 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
336 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 ...
4
votes
5answers
200 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
2answers
324 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
231 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) { ...
-3
votes
1answer
134 views

As I learn to program [closed]

Ok, life story in two sentences. I have been to college and have one semester left but I have obtained absolutely nothing from it (life lessons and the like don't count- I'm talking lucrative skills ...
1
vote
0answers
67 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
236 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
128 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
132 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 ...
1
vote
3answers
260 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
148 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
126 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
140 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
186 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
148 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
246 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
72 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
451 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
72 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
64 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 ...
0
votes
2answers
64 views

putting methods in base class that doesnt make sense/belong there [closed]

I've been lately thinking over design principles and patterns and a question did strike me. Let us say, I want to design a racing game. I want to design the classes for a variety of cars. each car ...
0
votes
1answer
61 views

delegating program logic to lower-level objects

I'm writing a library for use in scientific computing and ran into a bit of a quandary. The types at work here are a class M which consists of some data and a reference to a container class C. There ...
1
vote
4answers
215 views

Combinatorial explosion of interfaces: How many is too many?

I'm a relative newcomer to OOP, and I'm having a bit of trouble creating good designs when it comes to interfaces. Consider a class A with N public methods. There are a number of other classes, B, C, ...
4
votes
3answers
340 views

Is method overriding always a violation of Liskov Substitution Principle?

Overriding a method originally defined in the super class, by definition means this method will do different things when invoked on an object of the base class or an object of the subclass. So does ...
1
vote
4answers
216 views

Circular dependency and object creation when attempting DDD

I have a domain where an Organization has People. Organization Entity public class Organization { private readonly List<Person> _people = new List<Person>(); public Person ...
4
votes
1answer
351 views

Is there an imperative language with a Haskell-like type system? [closed]

I've tried to learn Haskell a few times over the last few years, and, maybe because I know mainly scripting languages, the functional-ness of it has always bothered me (monads seem like a huge mess ...
1
vote
3answers
212 views

What alternative is better to diagram this scenario?

I was creating and discussing a class diagram with a partner of mine. To simplify things, I've modify the real domain we're working on and made up the following diagram: Basically, a company works ...
2
votes
1answer
76 views

Do objects maintain identity under all non-cloning conditions in PHP?

PHP 5.5 I'm doing a bunch of passing around of objects with the assumption that they will all maintain their identities - that any changes made to their states from inside other objects' methods will ...
0
votes
3answers
100 views

In which object should I implement wait()/notify()?

I'm working in an Android project with multithreading. Basically I have to wait to the server to respond before sending more data. The data sending task is delimited by the flag boolean ...
1
vote
1answer
85 views

Liskov substitution principle with abstract parent class

Does Liskov substitution principle apply to inheritance hierarchies where the parent is an abstract class the same way if the parent is a concrete class? The Wikipedia page list several conditions ...
3
votes
3answers
205 views

is it valid that a state machine can have more than one possible state for some transition?

I have a requirement for a workflow which I am trying to model as a state machine, I see that there is more than one outcome of a given transition(or activity). Is it valid for a state machine to ...
1
vote
1answer
153 views

Object-Oriented equivalent of LISP's progn function?

I'm currently writing a LISP parser that iterates through some AutoLISP code and does its best to make it a little easier to read (changing prefix notation to infix notation, changing setq assignments ...
1
vote
7answers
621 views

Significant amount of the time, I can't think of a reason to have an object instead of a static class. Do objects have more benefits than I think? [closed]

I understand the concept of an object, and as a Java programmer I feel the OO paradigm comes rather naturally to me in practice. However recently I found myself thinking: Wait a second, what are ...
3
votes
3answers
287 views

Infinite loop with a singleton - does this type of issue have a name?

I ran into an unusual error while working on my project. To better learn from and remember it, I'd like to know if this type of error has a name or some definition. (The error itself OutOfMemoryError ...
4
votes
2answers
215 views

How should I refactor switch statements like this (Switching on type) to be more OO?

I'm seeing some code like this in our code base, and want to refactor it: (Typescript psuedocode follows): class EntityManager{ private findEntityForServerObject(entityType:string, ...
4
votes
1answer
535 views

Why are most GNU's software written in C [closed]

I am a Java developer, and I rarely write GUI program in C. However, I noticed that many GNU's projects, such as PSPP, R, Dia, etc., are written in C, instead of Java or C++. I personally don't mind ...
3
votes
3answers
251 views

How to safely copy an object?

This question is going to be a little long. Please bear with me. Something that happened in a project of mine made me think about how to safely copy objects. I'll present the situation I had and then ...
1
vote
1answer
44 views

Handling Types for Real and Complex Matrices in a BLAS Wrapper

I come from a C background and I'm now learning OOP with C++. As an exercise (so please don't just say "this already exists"), I want to implement a wrapper for BLAS that will let the user write ...
-1
votes
2answers
126 views

what's the point of method overloading? [duplicate]

I am following a textbook in which I have just come across method overloading. It briefly described method overloading as: when the same method name is used with different parameters its called method ...
1
vote
1answer
200 views

Confused about implementing Single Responsibility Principle

Please bear with me if the question looks not well structured. To put you in the context of my issue: I am building an application that invoices vehicles stay duration in a parking. In addition to ...
1
vote
6answers
227 views

“Default approach” when creating a class from scratch: getters for everything, or limited access?

Until recently I always had getters (and sometimes setters but not always) for all the fields in my class. It was my 'default': very automatic and I never doubted it. However recently some discussions ...
0
votes
2answers
105 views

What are the benefits of using a 'decorator factory' that decorates objects?

In a project I decided to implement the Decorator pattern. I have a class Thing with methodA(), and a class AbstractDecorator that inherits from Thing and that all decorators inherit from: ...
1
vote
4answers
253 views

“Collection Wrapper” pattern - is this common?

A different question of mine had to do with encapsulating member data structures inside classes. In order to understand this question better please read that question and look at the approach ...