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

How to structure classes in the filesystem?

I have a few (view) classes. Table, Tree, PagingColumn, SelectionColumn, SparkLineColumn, TimeColumn. currently they're flat under app/view like this: app/view/Table app/view/Tree app/view/...
1
vote
3answers
840 views

should I extend or create instance of the class

I have two classes Class A and Class B in Class A, i have three methods that perform the save, delete and select operation based upon the object I pass them. in Class B I perform the logic operations, ...
40
votes
8answers
9k views

What should be allowed inside getters and setters?

I got into an interesting internet argument about getter and setter methods and encapsulation. Someone said that all they should do is an assignment (setters) or a variable access (getters) to keep ...
1
vote
1answer
2k views

Use decorator and factory together to extend objects?

I'm new to OOP and design pattern. I've a simple app that handles the generation of Tables, Columns (that belong to Table), Rows (that belong to Table and have Columns) and Values (that belong to ...
28
votes
12answers
3k views

Why should a class be anything other than “abstract” or “final/sealed”?

After 10+ years of java/c# programming, I find myself creating either: abstract classes: contract not meant to be instantiated as-is. final/sealed classes: implementation not meant to serve as base ...
9
votes
3answers
2k views

Mocking concrete class - Not recommended

I've just read an excerpt of "Growing Object-Oriented Software" book which explains some reasons why mocking concrete class is not recommended. Here some sample code of a unit-test for the ...
15
votes
4answers
64k views

What is the use of Association, Aggregation and Composition?

I have gone through lots of theories about what is encapsulation and the three techniques of implementing it, which are Association, Aggregation and Composition. What I found is: Encapsulation ...
1
vote
1answer
601 views

Central Exception Handler

Recently I've been thinking about a general ExceptionHandler, that I could initialize once in my app context and inject it everywhere. The idea that it will have quite simple interface with just ...
6
votes
6answers
1k views

OOP Design: relationship between entity classes

I have at first sight a simple issue but can't wrap my head around on how to solve. I have an abstract class Compound. A Compound is made up of Structures. Then there is also a Container which holds 1 ...
0
votes
1answer
579 views

would a composite design pattern be useful for group membership?

I'm trying to think about the best way to handle group memberships on a website. People sign up and select checkboxes in a list of interests. Every week we send out interest-themed emails to those ...
8
votes
5answers
3k views

Is having 'Util' classes a cause for concern? [closed]

I sometimes create 'Util' classes which primarily serve to hold methods and values that don't really seem to belong elsewhere. But every time I create one of these classes, I think "uh-oh, I'm gonna ...
3
votes
4answers
2k views

DDD: Service or Repository

I am developing an app in DDD manner. And I have a little problem with it. I have a Fare (airline fare) and FareRepository objects. And at some point I should load additional fare information (from a ...
22
votes
7answers
2k views

Pattern for a class that does only one thing

Let's say I have a procedure that does stuff: void doStuff(initalParams) { ... } Now I discover that "doing stuff" is quite a compex operation. The procedure becomes large, I split it up into ...
6
votes
1answer
447 views

DDD: service contains two repository

Does it correct way to have two repository inside one service and will it be an application or domain service? Suppose I have a Passenger object that should contains Passport (government id) object. ...
15
votes
5answers
4k views

What is considered third party code?

Inspired by this question Using third-party libraries - always use a wrapper? I wanted to know what people actually consider as third-party libraries. Example from PHP: If I'm building an application ...
9
votes
1answer
2k views

Is wrapping a third party code the only solution to unit test its consumers?

I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework. Now ...
23
votes
7answers
25k views

What is the difference between “data hiding” and “encapsulation”?

I'm reading "Java concurrency in practice" and there is said: "Fortunately, the same object-oriented techniques that help you write well-organized, maintainable classes - such as encapsulation and ...
11
votes
1answer
1k views

Why did object-oriented paradigms take so long to go mainstream?

I read this question and it got me thinking about another fairly recent thing. Object oriented languages. I'm not sure when the first one was created, but why did it take so long before they became ...
0
votes
2answers
215 views

When modeling a virtual circuit board, what is the best design pattern to check for cycles?

To make it simple assume you have only AND and OR gates. Each has two inputs and one output. The output of two inputs can be used as an input for the next gate For example: A AND B -> E C AND D -> F ...
5
votes
3answers
6k views

Manager/Container class vs static class methods

Suppose I have a Widget class that is part of a framework used independently by many applications. I create Widget instances in many situations and their lifetimes vary. In addition to Widget's ...
3
votes
6answers
1k views

Can interface be not abstract?

Friend of mine said that not every interface is abstract. I haven't chance to discuss that with him but it get me thinking of not abstract interface in any type of language. Is there a non abstract ...
0
votes
4answers
385 views

Is comparing an OO compiler to a SQL compiler/optimizer valid?

I'm now doing a lot of SQL development at my new job where as before I was doing Object Oriented desktop app stuff. I keep running across very large scripts (thousands of lines) and wanting to ...
-1
votes
1answer
585 views

Using dot to Access Object Attribute and Proper abstraction

I have been programming in python and Java for quite a number of years and one thing I find myself doing is using the setters and getters from Java in Python but a number of blogs seem to think using ...
1
vote
6answers
2k views

Learning good OOP design and unlearning some bad habits [duplicate]

Possible Duplicate: What books or resources would you recommend to learn practical OO design and development concepts? I have been mostly a C programmer so far in my career with knowledge of C+...
3
votes
6answers
8k views

How get and set accessors work

The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable. Am I right in saying that ...
2
votes
3answers
799 views

What kind of programs/solutions can only be written with OOP or are too hard to achieve without it? [closed]

Paraphrasing a recent question: What is Object Oriented Programming ill-suited for? I would like to ask the opposite question: What kind of programs cannot be written unless you use OOP? What kind ...
1
vote
3answers
241 views

“Best fit” to avoid reuse of object instances in a collection

Imagine I have a collection of object instances which represent activities for a user to undertake. Dependent on user attributes, I have to randomly select instances to present activities to the user....
4
votes
4answers
408 views

Are injectable classes allowed to have constructor parameters in DI?

Given the following code: class ClientClass{ public function print(){ //some code to calculate $inputString $parser= new Parser($inputString); $result= $parser->parse()...
13
votes
5answers
9k views

Ways to ensure unique instances of a class?

I'm looking for different ways to ensure that each instance of a given class is a uniquely identifiable instance. For example, I have a Name class with the field name. Once I have a Name object with ...
10
votes
12answers
2k views

How can I explain object-oriented programming to someone who's only coded in Fortran 77?

My mother did her college thesis in Fortran, and now (over a decade later) needs to learn c++ for fluids simulations. She is able to understand all of the procedural programming, but no matter how ...
23
votes
5answers
3k views

Do unit tests sometimes break encapsulation? [duplicate]

I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept inside our ...
5
votes
2answers
2k views

What is the difference of delegator and dispatcher?

What is the difference of delegator and dispatcher? I am not quite sure of either concept.
22
votes
9answers
4k views

What can go wrong if the Liskov substitution principle is violated?

I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what ...
13
votes
1answer
1k views

How to verify the Liskov substitution principle in an inheritance hierarchy?

Inspired by this answer: Liskov Substitution Principle requires that Preconditions cannot be strengthened in a subtype. Postconditions cannot be weakened in a subtype. Invariants ...
3
votes
2answers
881 views

Something similar to Objective-C categories in other languages?

I understand Objective-C categories and how they become useful, but I always have a hard time explaining the concept to other programmers that are not familiar with Objective C. Maybe I'm just bad ...
1
vote
1answer
330 views

Object behaviour or separate class?

When it comes to OO database access you see two common approaches - the first is to provide a class (say "Customer") with methods such as Retrieve(), Update(), Delete(), etc. The other is to keep the ...
4
votes
4answers
532 views

How much is modern programming still tied to underyling digital logic? [closed]

First of all: I've got no academic background. I'm working primarily with Java and Spring and I'm also fond of web programming and relational databases. I hope I'm using the right terms and I hope ...
12
votes
2answers
402 views

Looking for some OO design advice

I'm developing an app that will be used to open and close valves in an industrial environment, and was thinking of something simple like this:- public static void ValveController { public static ...
6
votes
2answers
659 views

Help to understand the abstract factory pattern

I'm learning the 23 design patterns of the GoF. I think I've found a way to understand and simplify how the Abstract Factory works but I would like to know if this is a correct assumption or if I am ...
2
votes
1answer
367 views

Validation and Error Generation when using the Data Mapper Pattern

I am working on saving state of an object to a database using the data mapper pattern, but I am looking for suggestions/guidance on the validation and error message generation step (step 4 below). ...
16
votes
5answers
2k views

Why am I seeing so many instantiable classes without state?

I'm seeing a lot of instantiable classes in the C++ and Java world that don't have any state. I really can't figure out why people do that, they could just use a namespace with free functions in C++, ...
5
votes
4answers
195 views

How to implement isValid correctly?

I'm trying to provide a mechanism for validating my object like this: class SomeObject { private $_inputString; private $_errors=array(); public function __construct($inputString) { ...
45
votes
14answers
19k views

Isn't MVC anti OOP?

The main idea behind OOP is to unify data and behavior in a single entity - the object. In procedural programming there is data and separately algorithms modifying the data. In the Model-View-...
6
votes
2answers
644 views

How far should an entity take care of its properties values by itself?

Let's consider the following example of a class, which is an entity that I'm using through Entity Framework. - InvoiceHeader - BilledAmount (property, decimal) - PaidAmount (property, decimal)...
2
votes
1answer
4k views

About anonymous objects

In Java particularly Android development, is there any difference between declaring an object like SomeObject object = new SomeObject(); someField.setObject(object); compared to an anonymous ...
6
votes
6answers
5k views

Which order to define getters and setters in? [closed]

Is there a best practice for the order to define getters and setters in? There seems to be two practices: getter/setter pairs first getters, then setters (or the other way around) To illuminate ...
14
votes
6answers
549 views

Tips about how to spread Object Oriented practices [closed]

I work for a medium company that has around 250 developers. Unfortunately, lots of them are stuck in a procedural way of thinking and some teams constantly deliver big Transactional Script ...
1
vote
4answers
2k views

When to use identity comparison instead of equals?

I wonder why would anybody want to use identity comparison for fields in equals, like here (Java syntax): class C { private A a; public boolean equals(Object other) { // standard ...
6
votes
4answers
460 views

Should Equality be commutative within a Class Hierachy?

It is easy to define the Equals operation in ways that are not commutative. When providing equality against other types, there are obviously situations (in most languages) were equality not being ...
3
votes
1answer
708 views

The Meaning of Unified in UML

UML and other related modelling languages are exists in most of the system engineering fields to represent the system, flow, relations in a structured way. UML also is one of the modelling language ...