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)

29
votes
9answers
4k views

Are abstract classes / methods obsolete?

I used to create a lot of abstract classes / methods. Then I started using interfaces. Now I am not sure if interfaces aren't making abstract classes obsolete. You need a fully abstract class? ...
46
votes
17answers
4k views

Is OO-programming really as important as hiring companies place it?

I am just finishing my masters degree (in computing) and applying for jobs. I've noticed many companies specifically ask for an understanding of object orientation. Popular interview questions are ...
2
votes
1answer
75 views

Design Question - System Integration

Guidance on good application architecture / design is not in short supply however most of the examples focus on some business object, like Customer and its behaviour and persistence. There is little ...
1
vote
1answer
221 views

Designing classes the right way [closed]

I am trying to design my classes in the optimal way for the following scenario. A city has metro lines covering a number of stations.There are 4 lines represented by 4 colors.The user has to enter ...
0
votes
1answer
189 views

Is not being able to resolve a function call to its declaration a drawback of Polymorphism?

Consider a class that prints an "outline" table for a particular product line. Say you have several, A, B, C, D. The mechanism of the table generation is the same, but the data is different. I ...
4
votes
8answers
324 views

Do objects with validation logic in their domain really represent their real world counterparts?

I asked a question about whether validation behavior should be treated the same as other types of behavior in regard to the concept of OOP being "data + behavior". I got some good answers back that ...
0
votes
1answer
84 views

when would you wrap a service object with an interface? [duplicate]

I'm new to UT and some of the best practices and anti-patterns when writing testable code, made me think. I used to wrap any service object with interface. but I see many mocking frameworks can ...
0
votes
0answers
54 views

when would you write static method as it avoid a “seam” for testing [duplicate]

when would you write static method. I used to write it in utils classes where all the methods are static and work state-lessly on arguments only. But now I know it blocks from creating a seam in ...
2
votes
4answers
491 views

When should something be a class? And are my chosen classes good OO design?

My background: I am new to programming. Python is my only programming knowledge. I program as a hobby, and I'm teaching myself by reading copious amounts of books. I understand enough about OOP to ...
2
votes
3answers
319 views

OOD: Java inheritance and access to child methods via casting

I have several classes Parent and Child1 ... Child9 implemented in Java. Parent is an abstract class, containing all the common variables of the child classes (a lot, which is the main reason why I ...
1
vote
1answer
157 views

Should I declare the most specific type as return type of method?

Sorry for my English In Android I can put only ArrayList of Parcelable objects in Intent: Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value); I can't put ...
2
votes
3answers
257 views

OOP: Behavior + Data, but what about 'validation' behaviors?

EDIT: Thanks for all the great answers! In reading these responses I realized that I'm approaching this from the wrong angle so I wrote a new question here. I had this discussion with my superior ...
1
vote
2answers
135 views

Deriving from a class only to provide a special constructor

In our codebase, I encountered the following construct: There is a base class B, and then there is a class D which derives from B, but does not override or add any members. In fact, D is completely ...
0
votes
1answer
120 views

Method Parameters Ordering [closed]

I was recently changing a method to add in an additional parameter, and I couldn't help but wonder if there were "best practices" or "generally accepted rules" in deciding what order parameters of a ...
26
votes
6answers
4k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
1
vote
1answer
489 views

Abstraction Layer over ORM Generated Entities

I am learning LINQ to SQL (and planning to learn Entity Framework). Initially I used a abstraction layer to convert LINQ to SQL entities into a domain objects. Later I discovered the “Inheritance ...
3
votes
4answers
585 views

How to force “program to an interface” without using a java Interface in java 1.6

In java 1.8 they have wonderful new "default interface methods". In 1.6 how close can we come? The goal: keep clients (using code) from being able to tell that a class is not a java interface. If ...
3
votes
2answers
394 views

Are there any OO languages without inheritance?

During a code review today, a colleague of mine said something interesting: prototype is only useful when you need inheritance - and when's inheritance ever a good idea? I thought about this and ...
9
votes
12answers
6k views

Why must we learn Procedural programming before we learn Object-oriented programming [closed]

I'm in the 4th year at an IT university now, and when I talk with my professor about this topic he rejects my opinion and gives me a very heavy criticism (in my university, we were being taught C ...
1
vote
2answers
193 views

Why is object-level privacy difficult to use as a paradigm, and why is it desirable?

I have heard a prominent language designer remark that no language today enforces real object privacy, and we are still unsure whether it is possible in practice to design a language that does. ...
1
vote
4answers
387 views

When to not use dynamic in C# [closed]

I'm making a class similar to the following: public class KeyValue { public readonly string key; public readonly object value; } Value could be of any object type as a result of this ...
9
votes
3answers
785 views

What is the object-oriented thought process? [closed]

I've been studying OOP in conjunction with Zend's MVC implementation for the past few months. I'm pretty new to programming, generally, but I feel strongly that I should learn things the 'right' way, ...
1
vote
3answers
664 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
4answers
824 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 ...
108
votes
12answers
24k views

Should we avoid object creation in Java?

I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat ...
2
votes
2answers
166 views

Should fields still be private when you need to restructure the data?

I was taught that an object should know how to do everything with itself. So I've built an application trying to keep fields private and have a lot of methods like these: DisplayGraphically() ...
1
vote
1answer
170 views

Static controllers

I have built myself a PHP MVC framework to meet my needs. As pretty much all of the core classes are static, I just stumbled upon the idea of having static controllers. I know that for some reason ...
10
votes
4answers
715 views

What's wrong in returning hashtable from public method and when does it make sense to do so?

What are the design problems in returning a hashtable from a public method when you want to return multiple items instead of creating a class and returning object of that? If it does have problems ...
0
votes
2answers
83 views

When should you create/destroy underlying object in a class that wraps it

(note: I used Java to make it easer to explain my question, but the actual language is irrelevant for this dilemma) TL; DR: I have a wrapper around some underlying class. At which point should I ...
0
votes
2answers
162 views

Is this instance of mixing FP and OOP a good design?

I had a strange-feeling pattern come up in some code I was writing. In a project with user accounts, there was a lot of code that needed to do common things such as creating accounts, deleting them, ...
0
votes
0answers
162 views

Evaluating local storage for data persistence for small, stand-alone applications

TL;DR - I have a standalone application that will remain relatively small. I'm trying to evaluate between using XML files or a lightweight database for local storage of data that needs to be ...
4
votes
3answers
2k views

Is the “Objects First” approach a good idea? [closed]

Do you think programming novices should learn objects from day 1, as seen in the book "Objects First With Java: A Practical Introduction Using BlueJ" by David Barnes? Or do you think this is a bad ...
0
votes
1answer
86 views

Are there any serialization schemes for OOP that include methods or operations in the contract in addition to data structure?

So typically we create schemas, mime-types, etc for our objects when we're communicating to another system about objects. The document usually defines data structure of the objects for serialization ...
0
votes
3answers
328 views

Is the KISS principle more important than utilizing OOP to solve a problem?

I'm a PHP developer coding in the Yii 1.x framework. I was looking for a way to encode unescaped JSON in Yii 1.x, and found the CJSON framework class for this purpose (so OOP). Since it does not ...
-1
votes
1answer
133 views

Is it common to have a constructor with 7 elements for example? [duplicate]

Is it common to have a constructor with 7 elements for example? or is it better to use many setters instead?
35
votes
5answers
3k views

IOC Containers break OOP Principles

What is the purpose of IOC Containers? The combined reasons for it can be simplified to the following: When using OOP/SOLID Development principles, Dependency Injection gets messy. Either you have ...
0
votes
0answers
56 views

Is it good to make singleton Log classes for Entity classes [duplicate]

I am little confused about the technique i use in almost all applications i wrote ,i think i am going wrong I make Entity class Forexample Person, Adress ,Class and then to save it i make AdressLog ...
1
vote
2answers
223 views

when using dependency injection, should I always pass an interface

When using depending injection, you generally pass everything around as an interface (perhaps with the exception of primitives and strings). That allows you to easily chance the behavior, without ...
0
votes
0answers
84 views

The finer points of HMVC

I'm new to HMVC and whilst tutorials are great about dealing with the overall details of keeping modules separate and only letting controllers communicate, they aren't so great at explaining the ...
11
votes
4answers
692 views

Is it an overkill to wrap a collection in a simple class only for the sake of better readability?

I have the following map: Map<Double, List<SoundEvent>> soundEventCells = new HashMap<Double, List<SoundEvent>>(); This HashMap maps double values (which are points in time) ...
1
vote
2answers
189 views

When I create an object, is fresh memory allocated to both instance fields and methods or only to instance fields

I have a following class class Student{ int rollNumber; int marks; public void setResult(int rollNumber, int marks){ this.rollNumber=rollNumber; this.marks=marks; } public void ...
44
votes
11answers
10k views

Why is it good to split a program into multiple classes? [closed]

I'm still a student in high school (entering 10th grade), and I have yet to take an actual computer course in school. Everything I've done so far is through books. Those books have taught me concepts ...
77
votes
16answers
29k views

When are Getters and Setters Justified

Getters and setters are often criticized as being not proper OO. On the other hand most OO code I've seen has extensive getters and setters. When are getters and setters justified? Do you try to ...
1
vote
1answer
189 views

Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email: private static class EmailHelper { public static void SendEmail(string from, string to, string subject, string message) { ...
0
votes
1answer
297 views

Single responsibility: how does this code cause problems?

Given the following interface interface Modem { public void Dial(string pno); public void Hangup(); public void Send(char c); public char Recv(); } Uncle Bob writes However, ...
1
vote
4answers
154 views

Domain model associations that do not required the behaviour of the associated object. How to model?

I've been struggling with this question for a while. I'm specifically thinking within the object orientated domain model. Let's say I have two entities. A supplier and a customer. There is a ...
0
votes
2answers
57 views

Should `setX(Object o)` methods perform deep or shallow copies of objects?

My particular situation is related to Java, but I believe this is a more general OOP question than just Java programming. The Question: Should "mutator" methods perform deep or shallow copies? An ...
2
votes
3answers
266 views

Could the creation of many methods in Java affect performance? [closed]

I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment. This seems to ...
1
vote
1answer
692 views

C++ : Association, Aggregation and Composition [closed]

I'm beginning to study OOAD and I'm having difficulty finding a C++ code example that'd illustrate how Association, Aggregation and Composition are implemented programmatically. (There are several ...
0
votes
5answers
370 views

Liskov Substitution and SRP Principle violation - how best to structure this scenario?

While learning SRP and LSP, I'm trying to improve the design of my code to comply best with both of these principles. I have an employee class that has a calculatePay method on it. Firstly, I believe ...