Questions tagged [object-oriented]

A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

Filter by
Sorted by
Tagged with
0
votes
1answer
16 views

Can other behavioral OOP design patterns be expressed in terms of Strategy and Template Method Patterns for behaviour parameterization?

I'm studying OOP design patterns in a solution-oriented way which I mean not concentrating just one pattern but with a comparative analysis like their combined or hybrid usages and equivalents in ...
-5
votes
1answer
96 views

Use Case Diagram for Vending machine

I want to create a use case diagram for a vending machine which has the following states: Accepts coins of 1,5,10,25 Cents Allow user to select products Coke(25), Pepsi(35), Soda(45) Allow user to ...
-6
votes
0answers
85 views

What is Rust's excuse for not having proper classes? [closed]

Why doesn't Rust have proper classes? What's the end-game here?
1
vote
4answers
170 views

Is thinking of an OOP object as a “small program” a good analogy?

I have read that we can think of an OOP object as a "small program" that send messages to other "small programs" (objects), but I am not sure if this is a good analogy. One reason ...
1
vote
5answers
305 views

Why OOP languages use the syntax “object.function()” to send a message?

In C++ and Java and many other OOP languages, in order to send a message to an object, you have to use the object.function() syntax, for example: myCar.start(); // send the start() message to the ...
1
vote
1answer
78 views

Design Patterns: Factory Pattern Vs. getInstance Inside Abstract Class

I'm working on an app where we need to use different authentication flows depending on how the user is accessing the app. I want to make sure that there is only one instance of the authentication ...
-4
votes
0answers
43 views

Getting started with design patterns

For context I've been studying Object Oriented programming for around 6 months, learning independently with the help of textbooks/stack exchange/blog posts. I want to start adding a bit of design ...
0
votes
1answer
73 views

Extension of classes - Where to put behaviour - How much direct-access is allowed

At this point i would exclude the inheritance.... So the question is about more like extend into a seperate class or into the class which should be extended, both play in the composition-league. So ...
1
vote
1answer
56 views

Object oriented service best practice when changing a methods behavior for given context?

I expect this is a common problem and/or pattern question for beginners to OOP. Somehow I find myself wondering again and wasn't able to find a decent answer. So at the risk of creating a dupe... What ...
3
votes
2answers
277 views

What does “common interface” mean in OOP?

I have seen the term "common interface" used a lot while reading books about OOP. For example, the book The Essence of Object-Oriented Programming with Java and UML says the following: ...
-4
votes
1answer
34 views

Dynamically assign attributes to objects from outside

In python the following code works perfectly fine. class Table: pass table = Table() table.fruits = ["apple", "orange"] But as soon as we check it out with some kind of ...
1
vote
4answers
259 views

Is checking the type of a variable antithetical to OOP?

As an example, in PHP you can run gettype($myVariable); to obtain the type of a variable $myVariable. Is such functionality antithetical to OOP principles?
-5
votes
0answers
25 views

How to use multiple pipe filters in Angular?

I need to filter list of object by some criterias: status, activity,position, category. I have decioded to create separated pipes: StatusPipe, ActivityPipe, PositionPipe, CategoryPipe. I confused if ...
0
votes
1answer
86 views

what is the correct OOP way to read/write binary data if meta information of how data is encoded is stored inside data itself?

I have a Buffer which wraps a stream of binary data. The first byte indicates order, either big endian or little endian, which is needed to unpack the data. class FooBuffer implements Buffer is ...
0
votes
0answers
21 views

How to support alternative behaviour at the end of a pipeline when the new behaviour is decided at the beginning?

Let's assume we have a few loosely coupled components that form a pipeline. At the end is an file generating component. A new requirement comes in that requires an parallel alternative behaviour for ...
4
votes
2answers
173 views

How to design a SOLID pipeline with different inputs

I regularly have the situation that I have some complex logic that I break into steps. For example an import of an Excel file where I need to apply some logic or a complex calculation that I break ...
0
votes
3answers
129 views

OOD vs MVC; Live Objects vs Everything in Database

How to make memory-efficient code, but still have all the possible code nicely encapsulated ? I have a feeling that the OO (object oriented) approach is more intuitive and the code is nicely ...
1
vote
2answers
35 views

What does this statement about implementing forwarding methods of components mean?

I can't wrap my head around this statement here: One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be ...
1
vote
1answer
62 views

Can a GoF Builder implementation be considered valid without an explicit getProduct()?

For studying purpose, I've tried to create a simple PHP implementation of Builder GoF (not the Joshua Bloch's one) inspired on this slide. The main goal of this example is to encapsulate the ...
1
vote
1answer
61 views

How to design a class holding information about a relationship between two interchangable objects

I'd like to design a class that holds comparison results about to objects. Given I have a class Thing and that Thing has a bunch of properties. Now I have an engine that compares Thing instances (...
1
vote
4answers
200 views

OOP design: how to find one Subclass object in an array of Superclass objects?

Say I have a Group object which maintains a list of its Members: private $members; Now the class Member has a range of subclasses such as OrdinaryMember and GroupLeader. Every group has precisely ...
0
votes
1answer
78 views

How to define values dependant on the derived type?

My base class must provide an interface to get a value that is dependent solely on the type of the derived class. I can think of two ways of implementing this: Solution A, virtual functions: class ...
3
votes
1answer
81 views

Should a service object be transient or persistent?

In a typical server software design, business logic will generally invoke "services" (such as a database or web service). When I design such a system, I tend to think of each service as a singleton ...
2
votes
2answers
205 views

OOP - How to identify inheritance abusage?

In looking for a simple heuristic to see when inheritance can be abused, I came up with the following hypothesis: If subclass B overrides method foo, but does not call base.foo(), it seems like ...
1
vote
1answer
43 views

Inheriting DBModels and UI Models from Domain Models

I made a pretty simple CRUD API to store customers and some related information in a database. My customer has 20 properties like Name, Telephone etc. that are all stored in an anemic domain model. My ...
2
votes
1answer
58 views

How to determine whether the postcondition of overridden methods is weaker or stronger if there is no return value?

To reiterate the question - what does it mean to have a weaker or stronger postcondition when overriding a method that only does side effects with another one that only does side effects? P.S. What ...
0
votes
1answer
93 views

Object Oriented Design of Callback Methods

Assume that there is a library and it provides an interface to its users in order to callback them. Users implement this interface and receive notifications from the library. Let's say, ICallback is ...
-5
votes
1answer
54 views

Class diagram using UML syntax [closed]

Draw a class diagram using the UML syntax to represent the fact that the fleet of vehicles at a travel agency consists of vehicles of the types Tata Indica, Maruti van, and Mahindra Xylo. The regular ...
2
votes
2answers
132 views

How can I improve this design to achieve a more loosely coupled system and better testability?

My question I built an inverted pendulum on an Arduino using C (ie. everything was done procedurally). I'm trying to self study application design and would like to refactor my code into a more OO ...
3
votes
3answers
124 views

What is meant by “Polymorphism is the ability of an object to take on many forms”?

Based on many tutorials that I have read, the following is the definition of Polymorphism: Polymorphism is the ability of an object to take on many forms Now let's assume that we have an Animal ...
1
vote
6answers
316 views

In what ways is Polymorphism used (other than in arrays)?

I have read many tutorials on Polymorphism and all of them show examples of Polymorphism used in arrays, for example you would have an Animal (parent class) array, and its elements are Cat and Dog and ...
0
votes
1answer
110 views

Mixing IoC container use with “poor mans” DI

I'm finding the use of IoC containers to be quite the shift in my application design, and its for the better. I'm using a framework called injector that aims to mimic (albeit not entirely) the Guice ...
1
vote
3answers
125 views

Best way to Model Classes associated with other Classes?

I'm trying to make a sports stats app in Java/Android + Realm. I have the following classes: Season Player Matches I would like the Season to contain a "list" of all the players that played that ...
-10
votes
1answer
60 views

Find design issues via a class diagram? [duplicate]

Given a class diagram , how can we find design issues in it. I am not talking about the relationships it should be representing as they exist in the real world but i am talking about design issues ...
0
votes
3answers
145 views

How to find design defects by using a class diagram? [closed]

What are the design defects that can be spotted by using a class diagram, and how? I am not concerned about syntactical/ representational defects, but in things like the following: Do the classes/...
-3
votes
1answer
47 views

How to know if the UML class diagram design is good (well-planned) or not in java

I've learned the UML recently and I am trying to build a MonsterDuel system. However, there are a lot of classes in this project, and I am confused about the abstract class and its usage. Now, I have ...
19
votes
10answers
6k views

What is polymorphism if you can already have methods that are the same defined in different types?

I often read definitions for Polymorphism such as the following: Polymorphism is the ability to have objects of different types understanding the same message But the above definition also apply ...
4
votes
4answers
186 views

De-coupling business logic from POJO de-serialization design pattern

I've a JSON file which I'm trying to de-serialize into POJOs. public abstract BaseClass { private String baseClassField; abstract String execute(); } ClassA extends BaseClass public ClassA ...
-2
votes
1answer
87 views

should the join method be in the Course class or the Student class?

The rule I was taught: "the method should be in the Object that it is invoked on" a student joins a course => the join method should be in the Course class a player drives a car => car.drive(..) ...
1
vote
2answers
85 views

What goes on behind the scenes when data is passed through the use of interfaces?

I understand an interface is a contract and if a class implements that interface, it must define those abstract methods from the interface. What I don't understand is, how is data passed between two ...
0
votes
1answer
61 views

DDD design: Tracking price calculation progress and fallback price calculation

I am pretty new to DDD, so any help/ideas will be appreciated. I will explain my initial design and problem below. The user can ask the system to generate products proposal, proposal is basically ...
1
vote
4answers
174 views

Is there multiple definitions for responsibility of class?

In the book UML 2 and the Unified Process from Arlow and Neustadt has been told: Analysis classes should have 3 to 5 responsibilities But as you know we have the SRP that tells us something else!! ...
1
vote
2answers
70 views

design problem handling a dynamic object

I am writing an application for different geometrical types of fuel tanks. I have a design problem that only at runtime I will receive the exact type of tank from the end user; and I don't know how ...
-1
votes
2answers
99 views

Do I name classes based on the object type they represent or the responsibility they have?

The more I read about the Single Responsibility Principle the less I see a class as an object type, but rather as a servant that does something. For example, let us suppose we have a new requirement ...
0
votes
0answers
106 views

In what cases is Polymorphism useful?

I know how Polymorphism works, but I am trying to understand in what cases is Polymorphism useful. Now All the examples that I have found about Polymorphism are one of the following (the below code ...
1
vote
3answers
77 views

In a layered architecture, is a domain object sent 'up' to the ui layer so that the ui layer can display the fields that are in the domain object?

I'm learning about the Layered Architecture Pattern for Software Development but I'm confused on how objects are sent 'up' the layers. In general, I know that there are about 4 main layers: ui layer, ...
-4
votes
1answer
32 views

Is there a design pattern for transferring “partial” or related data objects?

I am writing a program in Kotlin which parses some input data and writes it to a MySQL database (through JDBC). The database includes tables such as users and each table has a corresponding data ...
0
votes
0answers
34 views

How to design a nodejs API as typical OOP way using typescript?

I need to design a nodejs typescript API using typical OOP way with controllers and modals, here I am adding a code base for invoice API of the system. can anyone suggest best approach to design in ...
4
votes
2answers
118 views

Utility method with several parameters, that have same values, that does not belong in any class. Where to put?

I have a problem placing and shaping the flowing method in my program: private void PrintWarning(params string[] messages) { if (!_suppressWarnings) { if (_warningsAsErrors) { ...
0
votes
1answer
75 views

Inheritance but with two different shared traits?

I am facing a dilemma with designing an api gateway. Currently, I am using the pipeline pattern, with different stages being the requests made to various services, (http, sockets, amqp, ...). I have ...

1
2 3 4 5
60