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
votes
2answers
115 views

Mermaid problem (OOP) [on hold]

A Mermaid is half fish and half human. It has upper human body and lower fish body. When under water its upper part swims like a human while its lower part swims like a fish. Please explain how can it ...
1
vote
1answer
33 views

Keeping lists of Objects, some with, some without inheritance

Let's say I have two classes, Foo and ExtendedFoo where ExtendedFoo inherits from Foo. Foo has a method .getValue() which returns a number, ExtendedFoo also has .increaseValue() which adds to the ...
-3
votes
0answers
36 views

Where to create objects and how to make them communicate with each other

I'm pretty new to OOP and need some help. I read quite a lot tutorials and watched some youtube videos but most stuff is about a small problem and quite out of the context. My problem is the ...
2
votes
1answer
153 views

Advantages of having numeric data types as classes rather than primitives [on hold]

I was wondering about why some languages choose to implement numeric types (boolean, integers, floats, characters etc.) as classes/objects (eg. Kotlin) and some as primitive types (eg. Java). I am ...
-3
votes
0answers
89 views

Interface Segregation Principle and casting

We all know what ISP is. The violation of the ISP leads to degenerative implementations of methods, implementations which just throw NotSupportedException and so on. So it is recommended to separate ...
0
votes
1answer
95 views

Access fields of super class from derived classes [duplicate]

There is an abstract BaseGame class that will be inherited by specific game classes. This class has an attribute requestHandler that will be used in all subclasses and should be initialized in the ...
0
votes
0answers
43 views

Should URL params and request params be stored in the Request object

Is it acceptable if GET parameters don't reside in the Request object, but in the URL? I am writing a small library in PHP, which is to represent the Request/Response as different entities and ...
4
votes
2answers
150 views

Why is it bad to have one mechanism for inheritance and subtyping?

It is quite well-known that (class) inheritance and subtyping (sometimes called interface inheritance) are different things: inheritance is a mechanism for sharing code, while subtyping is a ...
1
vote
6answers
162 views

Why do I need to map arguments to instance variables?

Class BankAccount: def __init__(self, accID, name, balance): self.accID = accID self.name = name self.balance = balance In the code above, why is it that I'm required to ...
-3
votes
1answer
76 views

Class refactoring [closed]

I have many rows in databases that are in fact classes, eg: 1-2 3-4 .. 10+ Something Now there are 2 options. One is to create class per table row (Something.class etc.), or to create single class ...
1
vote
2answers
216 views

Are any side effects not concrete side effects?

In Chapter 23 of "Object Oriented Software Construction" (1988), Betrand Meyer makes a distinction between side effects, concrete side effects, and abstract side effects. Meyer defines a side effect ...
0
votes
1answer
77 views

DI container with multiple instances of same object

I'm looking for idea to make a DI container that can store multiple instances of the same object. Usually, a DI container should store either a single instance of the object, or create new object each ...
6
votes
1answer
319 views

Mutable with logic inside or immutable with logic outside?

I know immutable objects are preferred to mutable objects for reasoning and maintenance. But in occasions making a class immutable have some costs, let me explain it with a simple example: class ...
0
votes
1answer
86 views

Upgrade object in PHP

I cannot find information on this anywhere so I assume it doesn't exist. It makes much sense for me for such functionality to exist and I want to ask whether it actually does and I am wrong in my ...
29
votes
6answers
8k views

Is it okay to have code smells if it admits an easier solution to another problem? [closed]

A group of friends and I have been working on a project for the past little while, and we wanted to invent a nice OOP way of representing a scenario specific to our product. Basically, we're working ...
-1
votes
1answer
113 views

override resolution behavior in c#

I tried the following piece of code public abstract class Entry3 { public abstract void Method1(); public virtual void Method2() { Console.WriteLine("Entry3.Method2"); } } public abstract ...
0
votes
0answers
23 views

Is this code Clean, Effective and SOLID? [migrated]

I've recently read the books Clean Code and Effective Java. I am a huge fan of Object-Oriented Java. I am trying to write as professionally as possible. I have been an Android Developer for 20 months ...
-2
votes
1answer
54 views

pass a variable as parameter to constructor c# [closed]

pass a variable as parameter to constructor as i want to change the variable value with changeable value i'm new to c# so that i tries to implement one thing in many way i did what i want to do with ...
2
votes
1answer
93 views

Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?

I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
0
votes
1answer
125 views

Best OOP practice for object vs dataservice [duplicate]

I am working on a new project and am curious as to how I should go about doing something properly. Lets say I have a table called "leads" in my database. This clearly means that a single "lead" would ...
3
votes
1answer
75 views

Is the 'application code' supposed to go in the Class or somewhere else?

I am trying to teach myself programming, but I have always been very confused by the object oriented approach. Recently, I have been reading about SOLID development principles. When I create ...
1
vote
1answer
179 views

Inheritance or Composition?

Let's say I have a main class A and another class B. In the B class the user can change some settings and variables of the program that belongs to A, I want to be able to apply these changes to the A ...
0
votes
4answers
200 views

Fixing class Hierarchy design mistakes due to incorrect inheritance

I have a code like this. My derived class man, may not properly have a member function declared pure virtual higher up the hierarchy. eg. WagTail here class mammal{ public: virtual void WagTail() ...
1
vote
2answers
141 views

Using static classes to define methods for handling POCO class objects

I am pretty new to the OOP paradigm and for this current project of mine, I need to design and develop a web application backend in .NET MVC using C#. A friend of mine told me that the class objects ...
4
votes
4answers
172 views

Design question concerning proper and practical encapsulation

I have been working on refactoring old code and found a lot of instances of the following type of situation: There is a master object which we call "Application" and there is only one of these. The ...
2
votes
2answers
101 views

Too specific of namespacing/packaging

I'm about to start building a C# library for English and French morphology as a side project. The library will be later merged with other linguistic aspects (phonology, sentence parsing, etc). for ...
0
votes
1answer
28 views

How can I create a data model to efficiently answer the question of - where to place my db-interaction code I am about to write?

I am seeking the right model for storing and retrieving data, when working with any specific class, while keeping in mind the bigger picture. Details: I have some SQL code in (one) of my classes and ...
0
votes
2answers
292 views

Structuring project (refactoring) [closed]

I'm working on a project that requires from me to make modular and extendible code structure. This code should be able to support multiple clients. The good news is that code should not do anything ...
1
vote
1answer
140 views

How to decide if object should request or receive data?

Deciding whether an object should request data (by calling a function) or receive data (by having a function called from another object) is probably dependent on the exact situation. So how do I ...
0
votes
1answer
103 views

Should I initialize a member variable in declaration when it is initialized by a constructor parameter?

Which is recommended for initialization of class fields in C#: class Foo { public X x = new X(); // or any default value... public Foo(X _x) { x = _x; } } Or class Foo { ...
2
votes
1answer
187 views

Hidden dependencies - why not?

Hidden dependencies: function __construct($dep_registry){ $this->db = $dep_registry->get('db'); $this->request = $dep_registry->get('request'); ... } Not so hidden: function ...
3
votes
3answers
142 views

Development Time: sql in UI code vs domain model with datamapper

First, sorry for my English guys. Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
6
votes
3answers
256 views

Implementing common logic in base class

Background In the documentation of a project I'm working on I came across the following sentence which immediately triggered an alarm for me: when having several concrete classes that inherits ...
0
votes
1answer
84 views

Multiple method calls in the constructor and dependency injection

I was asked to refactor some almost ureadable spaghetti code into object-oriented architecture. I have some doubts regarding a class that I designed. Here is the class' skeleton: require_once ...
0
votes
1answer
73 views

Cleanly using PHP Iterator class in Loops - calling first element

I have implemented the Iterator class in PHP and built the follow mandatory methods as follows class I implements Iterator { private $a = []; function __construct(array $a) { ...
1
vote
2answers
100 views

OOP (possibly Java-specific): Comprehensive Set of Method Categories [closed]

I am working on a coding convention to follow for my Java projects. I find it easier to find my way through a class when I group its methods by category. For example, rather than having each ...
1
vote
1answer
63 views

Is it okay to expose implementation components in a library?

I'm writing a library for general consumption (It's free software and open source). Is it okay to have a visible namespace (e.g. Library.Implementation) for implementation-only components that remain ...
0
votes
1answer
119 views

How much to encapsulate when objects being dealt with are pretty similar

As I have been answering questions related to object-oriented design and how to go about reducing the amount of classes to make sure that there is not a lot of "class clutter" and code repetition I ...
2
votes
2answers
71 views

Optional Member Data

I am creating a strong binding of an XML specification and I am essentially trying to "flatten" the specification as much as possible, so that it won't feel like you are manipulating an XML tree. ...
1
vote
5answers
351 views

Are there too many parameters in this constructor? [duplicate]

Check this out: public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\View\DesignInterface $design, \Magento\Framework\Registry $registry, ...
0
votes
0answers
56 views

Ordering of methods in class [duplicate]

How do you order the methods in your classes? I am aware of the alphabetical approach and the telling a story approach and so far I prefer the story approach, but how do you handle private/helper ...
0
votes
1answer
110 views

PHP OOP: value property is guaranteed different?

Imagine this code: class Test { public $result; public function makeSum($a,$b) { $sum = $a+$b; $this->result = $sum; } } In a webserver. At same exact moment, ...
14
votes
3answers
2k views

What is the reason of using an interface versus a generically constrained type

In object-oriented languages that support generic type parameters (also known as class templates, and parametric polymorphism, though of course each name carries different connotations), it is often ...
5
votes
2answers
178 views

Sharing state with dependencies - Object-Oriented Design

Suppose that I define two interfaces below: public interface IReader { void Read(string bookName); } public interface IWriter { void Write(string bookName); } Now I want to implement ...
0
votes
0answers
14 views

Extracting client specific code. refactoring possibilities required [duplicate]

I am facing a Design problem. I have a set of classes which writes data in XML,JSON or HTML formates for different clients. I have a class which receives Data and a XML, JSON or HTML writer as it ...
1
vote
1answer
168 views

Is SICP still relevant? [closed]

Today, I came across this book entitled:The Structure and Interpretation of Computer Programs I read the Table Of Contents and it really interests, me. It seems to be exactly what I've been looking ...
0
votes
1answer
70 views

Are there any strong reasons to use DI for sub-classes that are known to be tightly coupled to their parent containers?

I have Product classes for Products A through Z. And each Product class has its own set of product-specific subclasses, which I'd say are tightly coupled to them, like so: //specific product class ...
0
votes
2answers
109 views

Distinguishing Classes: How to catch system behavior in classes (Library System Case)

Suppose a Library System. if I think about Data, I can just distinguish Book, Member classes or at most Author or Publisher... (Are they only classes?), but I have some use cases, scenarios (Borrow, ...
8
votes
7answers
1k views

what should be logger's position in the parameter list [closed]

In my code I inject a logger to many of my classes through their constructor's parameter list I noticed that I put it randomly: sometimes it's the first on the list, sometimes last, and sometimes in ...
0
votes
1answer
101 views

2 Classes that share similar behaviours but unrelated.

I'm working on something at the moment and am a little confused. I'm working on an enquiry system in PHP (it's Opencart Based, so MVC). An enquiry comes in and depending on what form it was ...