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
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
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
2answers
2k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
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 ...
126
votes
23answers
33k views

If immutable objects are good, why do people keep creating mutable objects?

If immutable objects¹ are good, simple and offer benefits in concurrent programming why do programmers keep creating mutable objects²? I have four years of experience in Java programming and as I see ...
1
vote
3answers
211 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 ...
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 ...
18
votes
9answers
1k views

Does OO, TDD, and Refactoring to Smaller Functions affect Speed of Code?

In Computer Science field, I have noticed a notable shift in thinking when it comes to programming. The advice as it stands now is write smaller, more testable code refactor existing code into ...
1
vote
1answer
152 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
620 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 ...
18
votes
3answers
11k views

Which is a better practice - helper methods as instance or static?

This question is subjective but I was just curious how most programmers approach this. The sample below is in pseudo-C# but this should apply to Java, C++, and other OOP languages as well. Anyway, ...
2
votes
2answers
593 views

Where should instantiated classes be stored?

I'm having a bit of a design dilemma here. I'm writing a library that consists of a bunch of template classes that are designed to be used as a base for creating content. For example: public class ...
32
votes
6answers
2k views

How do I prove or disprove “god” objects are wrong?

Problem Summary: Long story short, I inherited a code base and a development team I am not allowed to replace and the use of God Objects is a big issue. Going forward, I want to have us re-factor ...
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, ...
10
votes
5answers
2k views

Can an object oriented program be seen as a Finite State Machine?

This might be a philosophical/fundamental question, but I just want to clarify it. In my understanding a Finite State Machine is a way of modeling a system in which the system's output will not only ...
4
votes
1answer
783 views

How can we protect the namespace of an object in Javascript?

Continuing from my previous question: Javascript simple code to understand prototype-based OOP basics Let's say we run into console this two separate objects(even if they are called child and parent ...
4
votes
1answer
534 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
125 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 ...
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 ...
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: ...
4
votes
3answers
327 views

Inheritance vs containment while extending a large legacy project

I have got a legacy Java project with a lot of code. The code uses MVC pattern and is well structured and well written. It also has a lot of unit tests and it is still actively maintained (bug fixing, ...
5
votes
5answers
576 views

Should I always encapsulate an internal data structure entirely?

Please consider this class: class ClassA{ private Thing[] things; // stores data // stuff omitted public Thing[] getThings(){ return things; } } This class exposes the ...
17
votes
15answers
3k views

Is Object Oriented Programming a solution to complexity? [closed]

Do you think Object Oriented Programming is a solution to complexity. Why? This topic may be a bit controversial but my intentions to know the answer of Why from the experts here !
2
votes
1answer
185 views

Best practice to collect information from child objects

I'm regularly facing following pattern: public abstract class BaseItem { BaseItem[] children; // ... public void DoSomethingWithStuff() { StuffCollection collection = new ...
2
votes
6answers
496 views

What is the best design decision approach?

I have two classes (named MyFoo1 and MyFoo2) that share some common functionality. So far, it does not seem like I need any polymorphic inheritance but, at this point, I am considering the following ...
0
votes
2answers
213 views

Can an object call a method on it's immediate descendant? [closed]

I have an inheritance hierarchy three deep : an abstract base class, from which I derive another abstract class, call it the intermediate class, from which will derive possibly a large variety of ...
2
votes
0answers
115 views

How does a search functionality fit in DDD with CQRS?

In Vaughn Vernon's book Implementing domain driven design and the accompanying sample application I found that he implemented a CQRS approach to the iddd_collaboration bounded context. He presents ...
1
vote
1answer
89 views

How to properly handle conditional dependencies in a factory?

Let's say you have a string $action run-time, that specifies which type of $object needs to be created: $dbobject, $memcacheobject, $fileobject, $xmlobject, etc. Assume also, that creation of an ...
0
votes
0answers
74 views

Is this considered an implementation of the Template Method design pattern?

Please consider a StringBank class. This class holds a list of Strings and can return them to the client. It's code (irrelevant stuff omitted): abstract class StringBank{ List<String> ...
3
votes
1answer
156 views

Does this Decorator implementation violate the Liskov Substitution Principle?

Please consider the following implementation of the Decorator design pattern: WordBank objects store strings and return them to the client through the method getWords(). The decorator class, ...
7
votes
2answers
544 views

How exactly to use the MVC design pattern

I have read the documentation on the apple's developer website which refer following guidelines A view class shouldn't depend on a model class (although this may be unavoidable with some custom ...
4
votes
4answers
715 views

Which methods should be put in an interface and which in abstract classes?

I have seen many frameworks and modules and their standard they follow is like this UserInterface which have some predefined methods AbstractUserClass which implements userInterface Then ...
1
vote
2answers
150 views

Three variants of circular references between objects: how to choose?

I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least ...
6
votes
3answers
274 views

How to adhere to the open-closed principle in practice

I understand the intent of the open-closed principle. It's meant to reduce the risk of breaking something that already works while modifying it, by telling you to try to extend without modifying. ...
8
votes
10answers
713 views

What should be first - functionality or design? [duplicate]

I've started reading a book from Head First series about OOP and Design. In a first chapter it is stated I have to worry about design of my application just after basic functionality is ready. Basic ...
2
votes
3answers
525 views

Is procedural programming the root of all object oriented evil? [closed]

If you read Working Effectively with Legacy Code, Clean Code, Refactoring: Improving the Design of Existing Code and Design Patterns you will get what I mean. Many of the examples and topics ...
5
votes
1answer
583 views

Is this actually good OO design?

Context I have Specification class with several properties including: StartDate, EndDate, DaysToComplete, DateToComplete. A specification contains a list of required courses (i.e. a company requires ...
0
votes
2answers
2k views

What is a Package Diagram? and What is a Sequence Diagram? [closed]

In many interviews I've been asked this question. What is a Package Diagram? and What is a Sequence Diagram? and difference between Package Diagram and Sequence Diagram. Thanks in Advance. Edit ...
0
votes
4answers
185 views

Why encapsulate container variables? [duplicate]

I wasn't sure how to formulate the title, but there's something that's made little sense to me in OOP I understand the idea of encapsulation, which is to create a layer of protection, and ...
-1
votes
4answers
1k views

Is there really Object-relational impedance mismatch?

It is always stated that it is hard to store applications objects in relational databases - the object-relational impedance mismatch - and that is why Document databases are better. However, is there ...
0
votes
7answers
345 views

Using a Simple/Static Factory vs. instantiating directly: new Thing() vs. factory.createThing() - what's the benefit?

Here are two ways to instantiate an object: Option 1: Thing thing = new Thing(); Option 2: (the factory is a Static Factory, but it could also be a Simple Factory). Thing thing = ...
-1
votes
4answers
248 views

Why is Java not 'pure' OOP? [duplicate]

Java is designed in a very OO approach, and somewhat even 'forces' programmers to program within the OO paradigm (which can be considered good or bad, a matter of opinion). However while almost ...
23
votes
4answers
1k views

Why Java doesn't make use of encapsulation with some classes?

My question is related with System.in and System.out classes (there might be others like those in the Standard library). Why is that? Isn't that a bad practice in OOP? Shouldn't it be used like: ...