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)

1
vote
1answer
91 views

Repository pattern implementation that knows nothing (Jon Snow) 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 ...
1
vote
2answers
563 views

Search and Replace in MVC

What would be a good MVC/OOP/GRASP/SOLID structure for a search/replace functionality. Methods: search/searchNext/replace/replaceAll. I'm interested only in the PHP arhitecture and how a professional ...
0
votes
1answer
271 views

PHP class data implementation

I'm studying OOP PHP and have watched two tutorials that implement user login\registration system as an example. But implementation varies. Which way will be more correct one to work with data such as ...
3
votes
2answers
200 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) { ...
5
votes
4answers
339 views

Adding field to the class at runtime - design pattern

Imagine your customer want's to have a possibility to add new property (e.g. color) to product in their eshop in their CMS. Instead of having properties as fields: class Car extends Product { ...
-3
votes
1answer
97 views

As I learn to program [on hold]

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
55 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 ...
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
119 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 ...
4
votes
6answers
6k views

When is C a better choice than C++? [closed]

I can't imagine that there's any reason not to use the OOP features of C++. It's is just as fast as C, and - what's more important to me - it's transparent, just as C. (I mean "transparent" that I ...
1
vote
1answer
128 views

How to structure a program into classes [on hold]

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 ...
2
votes
1answer
90 views

Interface hierarchy design for separate domains

There are businesses and people. People could be liked and businesses could be commented on: class Like class Comment class Person implements iLikeTarget class Business implements iCommentTarget ...
1
vote
3answers
256 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
141 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 ...
4
votes
1answer
397 views

Should I use JavaFx properties? [closed]

I'm usually very careful to keep my Model, View, and Controller code separate. The thing is JavaFx properties are so convenient to bind them all together. The issue is that it makes my entire code ...
17
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; ...
-5
votes
0answers
95 views

Real world Programming [closed]

When starting a new project are design patterns useful way of coding for rapid prototyping (small scale projects) or are they for production (full blown projects) or for all cases?
2
votes
1answer
138 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 ...
48
votes
2answers
4k views

Are there any OO-principles that are practically applicable for Javascript?

Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by: Writing the functions to be used as classes by yourself Use a nifty class system ...
2
votes
1answer
183 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 ...
-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 ...
3
votes
4answers
359 views

Is it good practice to declare and set properties in abstract classes?

I am using PHP and designing some abstract classes. I can declare properties with constant values within my abstract class and access/overwrite them from any class which extends this without re ...
1
vote
1answer
174 views

Handling array passed to object at creation

When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array ...
2
votes
1answer
75 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 ...
1
vote
2answers
220 views

Need advice on design in Ruby On Rails

For personal educational purposes I am making a site for a conference. One of the object that exist in a conference is a session, which has different states and in each state it has slightly different ...
0
votes
2answers
342 views

Object inheritance and method parameters/return types - Please check my logic

I'm preparing for a test and doing practice questions, this one in particular I am unsure I did correctly: We are given a very simple UML diagram to demonstrate inheritance: I hope this is clear, it ...
0
votes
2answers
143 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 ...
3
votes
3answers
173 views

Understanding UML composition better

The difference between Composition and Aggregation in UML (and sometimes in programming too) is that with Composition, the lifetime of the objects composing the composite (e.g. an engine and a ...
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 ...
1
vote
1answer
109 views

From a DDD perspective is a report generating service a domain service or an infrastructure service?

Let assume we have the following service whose responsibility is to generate Excel reports: class ExcelReportService{ public String generateReport(String fileFormatFilePath, ResultSet data){ ...
3
votes
3answers
286 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 ...
69
votes
5answers
9k views

Functional Programming vs. OOP

I've heard a lot of talk about using functional languages such as Haskell as of late. What are some of the big differences, pros and cons of functional programming vs. object-oriented programming?
7
votes
5answers
3k views

Why is using 'final' on a class really so bad?

I am refactoring a PHP OOP legacy website. I am so tempted to start using 'final' on classes to "make it explicit that the class is currently not extended by anything". This might save lots of time ...
0
votes
1answer
71 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 ...
43
votes
11answers
10k views

What is the ideal length of a method?

In object-oriented programming, there is no exact rule on the maximum length of a method , but I still found these two qutes somewhat contradicting each other, so I would like to hear what you think. ...
6
votes
8answers
1k views

How to split large, tightly coupled classes?

I have some huge classes of more than 2k lines of code (and growing) that I would like to refactor if possible, to have some more light and clean design. The reason it is so big is mainly because ...
6
votes
6answers
449 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 ...
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 ...
98
votes
11answers
18k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
0
votes
2answers
132 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 ...
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 - ...
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 ...
1
vote
2answers
186 views

I'm not sure how to add common functionality to my business objects using DTOs/DDD? [closed]

I have created a couple of projects to create a better division of my code: I have a Portable Class Library targeting all frameworks that contains just basic DTOs (auto-generated against a database). ...
2
votes
0answers
59 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
1answer
60 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 ...
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
226 views

Emulation of MMU accessing the contents of the registers

I'm having a play around with emulating a simple old CPU. I've set the structure up, so far anyway, as follows: The device is the main and creates an instance of the CPU. The CPU then creates ...
1
vote
4answers
213 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
337 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 ...