All Questions
Tagged with programming-practicesobject-oriented-design
38 questions
36votes
8answers
3kviews
Is OOP becoming easier or harder? [closed]
When the concepts of Object Oriented Programming were introduced to programmers years back it looks interesting and programming was cleaner. OOP was like this Stock stock = new Stock(); stock.addItem(...
13votes
3answers
27kviews
Is it a better practice pre-initialize attributes in a class, or to add them along the way?
I'm sorry if this is a ABSOLUTELY sophomoric question, but I'm curious what the best practices are out there, and I can't seem to find a good answer on Google. In Python, I usually use an empty class ...
8votes
10answers
3kviews
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 ...
7votes
4answers
864views
Do some best practices depend on skill?
Is there evidence that some software development best practices depend on programming skill level? I mean, these methods are good, but maybe the way the are used or the extent might vary? This ...
6votes
3answers
38kviews
Best OOP Practice in C#: Passing the Object as Parameter VS Creating a New Instance of the Object
First of all, I would like to know if passing an object as parameter is much better than creating another object again in a class that will use it again and second what are the pros and cons of each ...
6votes
4answers
35kviews
A DTO class having an ArrayList of its own type - is this considered a good design?
I came across a DTO class like the below one. class PersonDTO { private String firstName; private String middleName; private String lastName; private String dob; // some 50 fields ...
6votes
3answers
12kviews
Trying to come up with a mapping convention for C# objects
so this is C# but it could apply to any OO language where different sets of objects exist across different layers of an application. We have been trying to come up with a convention within the team ...
5votes
2answers
8kviews
Design pattern for processing a huge CSV file -- Java
I am learning design patterns in Java and also working on a problem where I need to handle huge number of requests streaming into my program from a huge CSV file on the disk. Each CSV line is one ...
4votes
3answers
1kviews
Passing object or using the field
I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
4votes
4answers
539views
Is it better to generate a large list during the constructor or when it's accessed?
I've got a class member function that generates a large list and puts it into a private member variable so it can be accessed through a getter. The generation of this list is a rather intensive ...
4votes
3answers
1kviews
Turning structural code into object oriented code
This is a bit experimentation from my part because I had written a lot of procedural code back in my school days hence I have trouble in thinking in OOP way i.e. to find proper classes and ...
4votes
1answer
1kviews
How to implement a facade correctly
I have read multiple websites on this topic but none of them gave me a 'good' solution for the problem I am having. The problem is described in the following (related) questions: How do I couple the ...
4votes
2answers
3kviews
Separating Read / Write Responsibilities of a DB
We're working on a reporting system which has a clear write and a read path. For example writes will only happen after consuming events from a queue and reads will only happen when serving requests ...
3votes
4answers
780views
Is it a bad practice to have an interface method to tell whether it can handle an object?
interface Resolver { boolean canResolve(SomeInput input); SomeOutput resolve(SomeInput input); } public static void main(String[] args) { List<Resolver> resolvers = ...; ...
2votes
3answers
235views
Correctness of an implementation beyond the methods signature contract of an interface
Is there a programming principle/guideline that tackles the correctness of a implementation beyond the methods signature contract of an interface? Let's say we have a repository interface with two ...