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)

3
votes
1answer
44 views

Separating functionalities in a food delivery app

I am creating object oriented design for a simple app through which users can order food from restaurants. User can browse nearby restaurants, explore menu, add items to cart, and finally checkout. ...
3
votes
3answers
254 views

Tell don't ask vs constructor doing work

When you browse for the phrase "constructors must not do work", then in various blog posts you will find the advice to not let the constructor do work. Despite this, I am having some trouble ...
1
vote
2answers
51 views

Conflict in getter and setter method names in ruby api design

I am inheriting an api decision in an SDK I am writing where I am required to fetch domain objects (entries) from the server like this: blogEntries = client.content_type('blog').entries As you can ...
-3
votes
0answers
57 views

How to build a tool using XML to draw a GUI and to generate an output stream? [on hold]

I have an assignment without particular technical specifications to deliver a software solution... Maybe someone here (students or programmers) would like to have a look at it and could give me some ...
1
vote
2answers
132 views

Immutable vs Mutable objects - Design

I have a class that models LogicalExpressions. The leaves are classes that implement an interface IEvaluable, that has a method called Evaluate which returns a boolean as the result. public class ...
6
votes
2answers
86 views

Business logic outside shared ORM models

I have a set of ORM models that are shared between the main business application and a couple minor side applications (such as an administrative web interface). I don't want to put the object's ...
4
votes
2answers
166 views

How to create a safe namespace for my application in JavaScript

I'm working on an application in the browser and I would like to make sure that my code does not conflict with code from other libraries or with possible calls added by browser manufacturers in the ...
6
votes
4answers
1k views

Why aren't OOP design patterns included in the standard libraries?

I have a question similar to this other question Why aren't design patterns added to the languages constructs? Why isn't there java.util.Singleton and then we inherit it? The boilerplate code ...
1
vote
1answer
108 views

Can the has-a relation in OOP become ambiguous or difficult to know?

Assume I have the following code. class D { static Integer i1 = 42; } Is it true that D has an Integer? Or is it only for instance variable that we can have a has-a relation? I also wonder about ...
1
vote
1answer
66 views

Designing interactions in Object Oriented Design

I am creating an object oriented design for a cab-calling app like Uber. I have some of the classes listed. I am having trouble in designing behavior between the classes. For example, I have these two ...
0
votes
0answers
45 views

What problem is solved in Java with equals() and hashCode()? [duplicate]

I learnt about hashCode and equals in Java and their uses and contracts. I'm trying to understand why we do it this way and why they simply are not the same. IIUC, the reason is a technical ...
4
votes
3answers
151 views

Strategy for avoiding defensive copies while keeping correct encapsulation

I want to keep a dependency decoupled, but at the same time, once it's passed to the constructor, I want to allow changes only through Whatever (in the following example) because changing the ...
-5
votes
2answers
196 views

Why are interfaces in Java called that way?

I have been a developer for past 3 years and I have been seeing interface in most of the places as a contract for the developers to write their own implementation or a marker (eg. Serializable). But ...
3
votes
1answer
43 views

Implementation of observer pattern with one observer/multiple publishers and multiple events?

I'm in a bit of a tricky situation where I need to use the Observer pattern but I don't really know the best way to go about it. Here's a quick briefing on my application: I'm implementing a GUI ...
0
votes
2answers
77 views

How to handle “reverse dependencies” between classes with proper object-oriented design?

I'm trying to learn proper object-oriented design, with class relations and avoiding anemic domain models[1]. I'm creating an application to store and retrieve information about "cyberattacks". There ...
-2
votes
1answer
149 views

Turn based game class design

I wrote abstract base for some turn-based games (like chess or tic-tac-toe) and wrote game based on this base. And I stuck with choosing how to design class hierarchy. Here is two variants for wich I ...
0
votes
1answer
41 views

Static field injection into subclasses

Say that I have a C++ class with some fields with static storage duration, call it class A. Is there some way to use inheritance to "inject" these static fields into classes which derive from class A?...
0
votes
0answers
33 views

Relationship Between Driving Simulation Objects

I am working on a very basic driving simulation. I am trying to decide the relationship between the following objects: Freeway, Vehicle, Driver, ProximitySensors. My real-world analysis suggests the ...
85
votes
14answers
14k views

Should we eliminate local variables if we can?

For example, to keep a CPU on in Android, I can use code like this: PowerManager powerManager = (PowerManager)getSystemService(POWER_SERVICE); WakeLock wakeLock = powerManager.newWakeLock(...
0
votes
2answers
105 views

How to implement business logic with Web Services?

I'am little confused about how business logic should be implemented using web services. For example, think about an education management application. There are simply students, teachers and courses. ...
0
votes
1answer
86 views

Factory needs list of available objects. Should it be static or not?

I have a list of IReader that I read at the beginning of my program. Later on I need ReaderFactory to get appropriate IReader based on Extensions it can use. The problem is the factory needs to know ...
0
votes
0answers
16 views

Extend inherited object structure from library

I created a base library/package containing the class Type and its childs ObjectType and PrimitiveType. In addition to that, I have 3 different use cases for this type classes that logically belongs ...
4
votes
2answers
187 views

Is this an indication of high coupling

I am doing a code review for a commercial software system. I noticed that some user's story and even sub-tasks when are implemented they result in a large code commit and usually end up in changing ...
-1
votes
1answer
26 views

Need Help to build a Custom Notification read logic for Individual user basis

I'm building a custom Notification section, which provides notification or messages to multiple users on any particular object update, I've created a HTML page like Dashboard where I have added a ...
9
votes
5answers
503 views

What is a good design practice to avoid asking a subclass type?

I've read that when your program needs to know what class an object is, usually indicates a design flaw so I want to know what is a good practice to handle this. I'm implementing a class Shape with ...
8
votes
7answers
664 views

Should rectangle inherit from square? [duplicate]

So, we're all probably familiar with the example provided in most textbooks of the Liskov substitution problem involving a square inheriting from rectangle. The objection to this approach is that ...
5
votes
2answers
77 views

Would you use object proxy, extend the class, if else conditions or make a duplicate class for supporting two different API's?

This is not an easy one but here goes. I'm working on adapting a JavaScript project (ACE Editor) to support two different targets but maybe more. Any way I look at it, it looks like a large task and ...
1
vote
2answers
48 views

Call class method only if condition is met

Everytime I make a http request I must make sure there is internet connection. public class InternetCheck { public static boolean isOnline() { } } class Httphandler { public static ...
4
votes
1answer
210 views

is it common sense to convert database data to object first?

In the framework I am using, I shall group things into models, controller, and views (I added services). When getting things out from database, it is pure data in array form. So they won't have ...
6
votes
1answer
143 views

In a multi tier project where should interfaces be defined?

I have a multi tiered project made up of three sub projects, i.e. Data access project, Business Logic project and Presentation project, where should interfaces be defined? I'm guessing that there ...
4
votes
2answers
142 views

How to OOA/OOD a rather complex concept?

I'm a novice at Object-Oriented Designing and have read some OOD books & tutorials recently. Now I'm planning to implement a video player(based on existing media api, AVFoundation or MediaPlayer ...
3
votes
2answers
74 views

Value object that depends on multiple aggregates' lifecycle in DDD

During prototyping a simple ddd application from public transit domain I've faced a problem with one value object - Transit Pass: Each Customer can buy a transit Pass thatallows a passenger of the ...
4
votes
1answer
151 views

Why shouldn't a static class have an internal state?

While working on a project, I decided to create a database class to manage my DB connection. I started looking for the best practice to do that, which is usually either a static class or a singleton ...
8
votes
1answer
186 views

Separate object used in business layer, data layer and presentation layer

I'm building an application that is responsible for reading data from files and displaying them in charts. The whole application is responsible for manipulating data from files, which means I have to ...
1
vote
2answers
258 views

Is singleton the right way to go in the case of a game?

I've been reading the top posts of stackoverflow and SE and all over the place it says how bad singletons are but I am unsure how to rewrite my code. As of now I have two projects that bind into a ...
4
votes
5answers
202 views

Should I encapsulate an object inside another object as methods or just access it directly?

Suppose I have a class: public class A{ public void a(){ } } and class B use A: public class B{ private A a; } Should I encapsulate A in B: public class B{ private A a; public ...
18
votes
4answers
653 views

What does it mean when one says “Encapsulate what varies”?

One of the OOP principles I came across is: -Encapsulate what varies. I understand what the literal meaning of the phrase is i.e. hide what varies. However, I don't know how exactly would it ...
1
vote
1answer
122 views

Pass result in API Chaining

We have set(6-8) of API and it will be invoked in a sequence . there are cases, want to use output of first/second API in the third/fourth API . We have request object which is passed as input to all ...
7
votes
4answers
248 views

Composition of two classes with common inheritance root

Hope your day is going well. I want to make the following composition of two objects with the same inheritance root: There will be 3 basic operations on the Wallet class: add, getCards and ...
3
votes
4answers
237 views

Is using inheritance to set properties bad?

A coworker and I are having a debate. In our app, there are components that behave slightly differently based on how we want it to be presented. Thus far, we have agreed our inheritance should look ...
1
vote
1answer
83 views

How to design the system which executes two process independently with different configuration?

I have two process ProcessA and ProcessB. I want to run these two process independent of each other. There is no relation between them at all. Each process should have a different Properties object. ...
4
votes
2answers
167 views

How can I avoid both objects A and B using class C (or is it unavoidable)?

I have the following setup: An object A running as a separate service with its own address (implemented via Pyro package in Python). An object B running as a separate service with its own address. ...
0
votes
0answers
36 views

Where to place custom classes in Slim3 PHP application

I'm currently developing an application using Slim3 and at the same time learning how to structure applications correctly. I'm a bit lost when it comes to structuring the application correctly. My ...
2
votes
1answer
151 views

Is this an example of Composition?

The following code is given: class Warren { private const int MaxRabbitsInWarren = 99; private Rabbit[] Rabbits; private int RabbitCount = 0; private int PeriodsRun = 0; private bool ...
8
votes
6answers
453 views

Demonstrate Object Oriented Principles to non-programmers using physical props [closed]

We're about to embark on helping with a new-to-coding boot camp at my work, where people from other departments can come learn how to code from the IT folks. While this is great and all, I'm in a ...
14
votes
5answers
870 views

OOP Coding style: initialize everything on constructor?

I still consider myself as an apprentice programmer, so I'm always looking to learn a "better" way for typical programming. Today, my coworker has argued that my coding style does some unnecessary ...
5
votes
2answers
74 views

Static services and testability

Where is the figurative line drawn for using static services in a project? I am a coop student working and learning how to write .net MVC projects. I've been developing trying to stick to TDD. In my ...
5
votes
1answer
48 views

Can class DBQuery be merged with or extend class DBConnection?

This is question about class relationships not class functionality. Currently my DBConnection and DBQuery classes are two separate objects class DBConnection { public $dbh; __construct() { ...
5
votes
2answers
297 views

Modelling an account manager in OOP

I have this task of modelling a system where given a group of users each can keep track of their expenses. The basic requirements are as followed: To be able to give credit to an user. Find all the ...
2
votes
0answers
63 views

PHP OOP best practice to split low level class into two

What i got now is low level object that has bunch of methods and its difficult to navigate trough i want to break it down, however functions logically have same functionality just different ...