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
3answers
797 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 ...
4
votes
4answers
405 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= ...
13
votes
5answers
8k 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 ...
22
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
873 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
323 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
529 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
401 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
657 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
363 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 ...
6
votes
2answers
639 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, ...
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 ...
5
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
547 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
452 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
698 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 ...
5
votes
3answers
532 views

What is a good design model for my new class?

I am a beginning programmer who, after trying to manage over 2000 lines of procedural php code, now has discovered the value of OOP. I have read a few books to get me up to speed on the beginning ...
11
votes
2answers
625 views

FP for simulation and modelling

I'm about to start a simulation/modelling project. I already know that OOP is used for this kind of projects. However, studying Haskell made me consider using the FP paradigm for modelling a system of ...
21
votes
6answers
970 views

Should an object know its own ID?

obj.id seems fairly common and also seems to fall within the range of something an object could know about itself. I find myself asking why should my object know its own id? It doesn't seem to have a ...
0
votes
2answers
239 views

Why to say, my function is of IFly type rather than saying it's Airplane type

Say, I have two classes: Airplane and Bird, both of them fly. Both implement the interface IFly. IFly declares a function StartFlying(). Thus both Airplane and Bird have to define the function, and ...
1
vote
3answers
456 views

Figuring out the Call chain [closed]

Let's say I have an assemblyA that has a method which creates an instance of assemblyB and calls its MethodFoo(). Now assemblyB also creates an instance of assemblyC and calls MethodFoo(). So no ...
5
votes
4answers
4k views

Should I create an Enum mapping to my database table

I have a database table containing a list of systems relevant to the tool I am building, mostly in-house applications, or third-party systems we receive data from. This table is added to infrequently, ...
0
votes
1answer
399 views

In PHP, what are the different design patterns to implement OO controllers as opposed to procedural controllers?

For example, it's very straightforward to have an index.php controller be a procedural script like so: <?php //include classes and functions //get some data from the database //and/or process a ...
1
vote
2answers
134 views

Is there a better way to handle data abstraction in this example?

I'm building an application that retrieves Sharepoint list data via a web service SPlists.Lists. To create an instance of the web service, I have the following class: class ...
3
votes
1answer
1k views

Why setter method when getter method enough in PHP OOP

I am practicing OOP with PHP, and I am struck at setter and getter methods. I can directly access the class properties and methods with getter method then what's the use of setter method? See my ...
39
votes
7answers
2k views

How can I get my progress reviewed as a solo junior developer [closed]

I am currently working for a 2 person company, as the solo primary developer. My boss gets the clients, mocks up some png design templates and hands them over to me. This system has been working fine ...
15
votes
5answers
10k views

Are UML class diagrams adequate to design javascript systems?

Given that UML is oriented towards a more classic approach to object orientation, is it still usable in a reliable way to design javascript systems? One specific problem that I can see is that class ...
3
votes
3answers
3k views

Is the singleton pattern prone to thread safety problems?

Is the singleton pattern prone to thread safety problems? If so, what are the best methods to work around them?
12
votes
5answers
3k views

Formal definition for term “pure OO language”?

I can't think of a better place among SO siblings to pose such a question. Originally I wanted to ask "Is python a pure OO language?" but considering troubles and some sort of discomfort people ...
3
votes
1answer
941 views

Domain Models (PHP)

I have been programming in PHP for several years and have, in the past, adopted methods of my own to handle data within my applications. I have built my own MVC, in the past, and have a reasonable ...
5
votes
1answer
95 views

Object construction design

I recently started to use c# to interface with a database, and there was one part of the process that appeared odd to me. When creating a SqlCommand, the method I was lead to took the form: ...
2
votes
7answers
1k views

OO Software Architecture - base class that everything inherits from. Bad/good idea?

I am reviewing a proposed OO software architecture that looks like this: Base Foo Something Bar SomethingElse Where Base is a static class. My immediate thought was that every object in any ...
6
votes
2answers
686 views

Have I mistakenly assumed that my routines are loosely coupled?

My Selenium test structures goes as - Data Object class - public class RegistrationData { String firstName = "test first name"; String lastName = "test last name"; // Getter Setter Here } ...
0
votes
1answer
130 views

If I define a property to prototype appears in the constructor of object, why?

I took the example from this question modified a bit: What is the point of the prototype method? function employee(name,jobtitle,born) { this.name=name; this.jobtitle=jobtitle; this.born=born; ...
9
votes
4answers
52k views

What's the difference between overloading a method and overriding it in Java?

What's the difference between overloading a method and overriding it in Java? Is there a difference in method signature, access specifier, return type, etc.?
3
votes
5answers
1k views

What's the equivalent name of “procedure” in OOP?

In several of my programming courses in the University, my teachers always told me the following: A function and a procedure are basically the same thing: the only difference is that a function ...
5
votes
8answers
933 views

Learning OO for a C Programmer [closed]

I've been programming professionally in C, and only C, for around 10 years in a variety of roles. As would be normal to expect, I understand the idioms of the language fairly well and beyond that ...
7
votes
3answers
5k views

Data classes: getters and setters or different method design

I've been trying to design an interface for a data class I'm writing. This class stores styles for characters, for example whether the character is bold, italic or underlined. But also the font-size ...
3
votes
1answer
555 views

Can I assume interface oriented programming as a good object oriented programming?

I have been programming for decades but I have not been used to object oriented programming. But for recenet years, I had a great opportunity to learn OOP, its principles, and a lot of patterns that ...
0
votes
2answers
507 views

Breaking up a large PHP object used to abstract the database. Best practices?

Two years ago it was thought a single object with functions such as $database->get_user_from_id($ID) would be a good idea. The functions return objects (not arrays), and the front-end code never ...
2
votes
3answers
1k views

Are CK Metrics still considered useful? Is there an open source tool to help?

Chidamber & Kemerer proposed several metrics for object oriented code. Among them, depth of inheritance tree, weighted number of methods, number of member functions, number of children, and ...