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)

2
votes
2answers
922 views

Factory Pattern and/or Dependency Injection?

I understand the concept and can use both the Factory Pattern and Dependency Injection, however they seem a little at odds with each other conceptually. Is it a case of using one over the other? Or ...
5
votes
2answers
405 views

Is this a correct implementation of an Immutable class in Java?

public final class ImmutableClass { private StringBuffer name; public ImmutableClass(StringBuffer name) { this.name=name; } public StringBuffer getName() { return ...
0
votes
1answer
332 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 ...
25
votes
8answers
2k views

What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP. I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit ...
33
votes
3answers
1k views

Does Java development typically involve more subclassing than C#/.NET?

I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly ...
1
vote
4answers
366 views

Data duplication vs Encapsulating. Which design to use?

The problem that I face is how to combine encapsulating and optimal memory use. I can't show you my code and therefore explain it on extensive (I hope) example. Let's say we need to have a database ...
13
votes
6answers
2k views

Should a class know about its subclasses?

Should a class know about its subclasses? Should a class do something that is specific for a given subclass for instance? My instincts tells me that is a bad design, it seems like an anti-pattern of ...
1
vote
3answers
300 views

Problems with Facades and then evolution in software

I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void ...
0
votes
0answers
65 views

using internal or external iterators over graph edges

I've written some code to manipulate sparse graphs for school work I'm doing, and I have an operation which requires me to loop over all the edges of a graph. The interface I need to implement is some ...
0
votes
4answers
125 views

Understanding parameters

I have read this statement: "A parameter is used as a sort of temporary messenger, carrying data originating from outside the constructor or method and making it available inside it." So, does that ...
0
votes
4answers
395 views

Problem regarding DRY principle and Polymorphism

I have a class that is 99% identical to its counter part. Sample code goes below: public abstract class BaseClass { void Method1() { } void Method2() { } void Method3() { } public ...
4
votes
1answer
189 views

OOP, domain models, and the user

When developing domain models, I can see two major ways of thinking about the user: The first one assumes that a program is a kind of "simulation" of what happens in the real world, and the user is ...
5
votes
1answer
555 views

Dictionary of objects

I have a dictionary of Objects of a class Columns Dictionary<double, Columns> Columns is a class of columns, i.e. name, post code, etc, mobile phone. I would like to make Columns class as ...
0
votes
3answers
379 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 ...
2
votes
5answers
589 views

Good design for a recreation of pokemon

I'm currently working on a group project to recreate the original Pokemon Yellow version in Java. We've only just started planning it out but they way we've drawn out the design right now is to have ...
3
votes
1answer
165 views

Understanding abstraction

I am trying to understand object oriented code better and I decided to start at abstraction. If I am not incorrect, abstraction means that you hide information that isn't relevant to what task you ...
0
votes
0answers
91 views

When You Have Both Options, When Functional and When OOP? [duplicate]

Like (I suspect) a lot of JS devs, I tend to start with intuition first and then come to sound principles/practice with experience informing study of the comp. sci stuff I never really had any form ...
9
votes
6answers
994 views

What Functional features are worth a little OOP confusion for the benefits they bring?

After learning functional programming in Haskell and F#, the OOP paradigm seems ass-backwards with classes, interfaces, objects. Which aspects of FP can I bring to work that my co-workers can ...
10
votes
12answers
2k views

Is “If a method is re-used without changes, put the method in a base class, else create an interface” a good rule-of-thumb?

A colleague of mine came up with a rule-of-thumb for choosing between creating a base class or an interface. He says: Imagine every new method that you are about to implement. For each of them, ...
3
votes
1answer
764 views

What are the disadvantages of self-encapsulation?

Background Tony Hoare's billion dollar mistake was the invention of null. Subsequently, a lot of code has become riddled with null pointer exceptions (segfaults) when software developers try to use ...
7
votes
4answers
464 views

Do $_POST, $_GET, etc violate the encapsulation principle?

Using globals makes your code hard to test thus more prone to bugs, not secure and unpredictable. That's why we pass the variables we want inside a function/object. So my question is simple: Do ...
1
vote
1answer
622 views

Liskov principle: violation by type-hinting

According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like ...
0
votes
2answers
330 views

OOP PHP make separate classes or one

I'm studying OOP PHP and working on a small personal project but I have hard time grasping some concepts. Let's say I have a list of items, each item belongs to subcategory, and each subcategory ...
2
votes
6answers
733 views

Confusion about inheritance

I know I might get downvoted for this, but I'm really curious. I was taught that inheritance is a very powerful polymorphism tool, but I can't seem to use it well in real cases. So far, I can only ...
4
votes
5answers
627 views

How to model an address type in DDD?

I have an User entity that has a Set of Address where Address is a value object: class User{ ... private Set<Address> addresses; ... public setAddresses(Set<Address> ...
1
vote
3answers
492 views

C# vector class - Interpolation design decision

Currently I'm working on a vector class in C# and now I'm coming to the point, where I've to figure out, how i want to implement the functions for interpolation between two vectors. At first I came up ...
1
vote
3answers
670 views

MVC is a GUI Architecture or a Architecture to GUI and Domain?

Fowler refers to the MVC, as a GUI architecture: There have been many different ways to organize the code for a rich client system. Here I discuss a selection of those that I feel have been the ...
1
vote
1answer
99 views

How to depict Import a file action in the Sequence diagram

Everyone says sequence diagrams are so easy but I just cannot figure this out. Basically user clicks on an 'Import from temp folder' button, the program opens a window with a list populated with ...
3
votes
2answers
549 views

Design pattern to handle queries using multiple models

I am presented with a dilemma while trying to re-designing the class structure for my PHP/MySQL application to make it more elegant and conform it to the SOLID principle. The problem goes like this: ...
6
votes
2answers
583 views

Why “OOP” and not simply “Object Programming”?

Why do we say "Object-oriented programming" and not simply "Object programming"? Why do we speak of orientation in just this case, and not "Functionally-oriented programming" and so?
12
votes
6answers
3k views

How to practice object oriented programming? [closed]

I've always programmed in procedural languages and currently I'm moving towards object orientation. The main problem I've faced is that I can't see a way to practice object orientation in an effective ...
0
votes
2answers
223 views

How can a collection class instantiate many objects with one database call?

I have a baseClass where I do not want public setters. I have a load($id) method that will retrieve the data for that object from the db. I have been using static class methods like ...
0
votes
1answer
104 views

Class diagrams - do aggregated/composed classes automatically see each other?

Let's say that in the game, a player has a pet: Player<>------Pet Obviously player can access Pet's fields and methods, but I assume Pet does not know about the player? I need that Pet can access ...
4
votes
4answers
291 views

Should single purpose utility app use a class

When writing a small utility app, that does just one thing, should that one thing be encapsulated in a seperate class, or just let it be part of whatever class/module is used to start the application? ...
4
votes
3answers
224 views

Help with design structure choice: Using classes or library of functions

So I have GUI Class that will call another class called ImageProcessor that contains a bunch functions that will perform image processing algorithms like edgeDetection, gaussianblur, contourfinding, ...
3
votes
2answers
261 views

Semantic coupling vs. large class

I have hardware I communicate with via TCP. This hardware accepts ~40 different commands/requests with about 20 different responses. I've created a HardwareProxy class which has a TcpClient to send ...
4
votes
2answers
260 views

If an entity is composed, is it still a god object?

I am working on a system to configure hardware. Unfortunately, there is tons of variety in the hardware, which means there's a wide variety of capabilities and configurations depending on what ...
7
votes
4answers
1k views

Make methods that do not depend on instance fields, static?

Recently I started programming in Groovy for a integration testing framework, for a Java project. I use Intellij IDEA with Groovy plug-in and I am surprised to see as a warning for all the methods ...
3
votes
7answers
553 views

Is there a pattern to restrict which classes can update another class?

Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really ...
1
vote
3answers
185 views

Law of Demeter in MVC regarding Controller-View communication

The scenario: Having a Controller that controls a view composed of complex subviews. Each one of those subviews is a separated class in a separate file. For example, one of those subviews is called ...
0
votes
2answers
460 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 ...
13
votes
4answers
691 views

Switch vs Polymorphism when dealing with model and view

I can't figure out a better solution to my problem. I have a view controller that presents a list of elements. Those elements are models that can be an instance of B, C, D, etc and inherit from A. So ...
2
votes
2answers
357 views

Class design for calling “the same method” on different classes from one place

Let me introduce my situation: I have Java EE application and in one package, I want to have classes which will act primarily as cache for some data from database, for example: class that will hold ...
2
votes
5answers
165 views

Designing a single look up entity

In almost every application you have this look up entity that provides a dynamic references. This are things like type, category, etc. These entities will always have id, name, desc So at first I ...
2
votes
4answers
153 views

How to handle status columns in designing tables

How to handle multiple statuses for a table entry, for example an item table may have an active, inactive, fast moving, and/or batch statuses. And I wanted to handle them in single column with VARCHAR ...
2
votes
2answers
103 views

How to deal with data on the model specific to the technology being used?

There are some cases where some of the data on a class of the domain model of an application seems to be dependent on the technology being used. One example of this is the following: suppose we are ...
5
votes
4answers
578 views

How do I decide to which class a method should belong

I have TopicBusiness.class and PostBusiness.class. I have no problem with deciding into which class methods such as addPostToDatabase() or getAllPostsFromDatabase() should go. But what about ...
2
votes
2answers
2k views

Ruby - when to use instance variables vs parameters between methods?

I'm writing several methods that call other methods. To pass the information I have a couple of choices: Pass the information as parameters Set instance variables so that other methods can access ...
0
votes
0answers
46 views

Law of Demeter confusion [duplicate]

I am reading a book called Rails AntiPatterns and they talk about using delegation to to avoid breaking the Law of Demeter. Here is their prime example: They believe that calling something like this ...
9
votes
4answers
808 views

Rails: Law of Demeter Confusion

I am reading a book called Rails AntiPatterns and they talk about using delegation to to avoid breaking the Law of Demeter. Here is their prime example: They believe that calling something like this ...