All Questions
15 questions
65
votes
10
answers
36k
views
Do you generally send objects or their member variables into functions?
Which is generally accepted practice between these two cases:
function insertIntoDatabase(Account account, Otherthing thing) {
database.insertMethod(account.getId(), thing.getId(), thing....
0
votes
1
answer
370
views
How best to share common steps between services while allowing them to provide their own behaviour
I've started working on a C# codebase. There are three services which run the same set of steps of three kinds of objects, each returning IResult:
public IResult FooService(Foo foo) { ... }
public ...
1
vote
1
answer
907
views
Can a class factory also save the object to a database?
How can a factory also save the object in the database?
I want to create an object that consists of other objects.
Pseudocode:
firstObject = db.get....;
secondObject = db.get....;
expectedObject = ...
1
vote
2
answers
1k
views
Calling methods on objects VS. passing objects as parameters
Which is considered a generally accepted practice?
class Image {
public void decode();
};
//main
Image image;
image.decode();
vs
class ImageDecoder {
public Image run(Image image);
};
//main
Image ...
5
votes
2
answers
8k
views
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 ...
4
votes
4
answers
539
views
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 ...
21
votes
5
answers
2k
views
How to avoid giant glue methods?
In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, neat,...
2
votes
1
answer
274
views
Is it OK to deprecate methods that need to be public due to the packaging model but are not to be used outside the codebase in Java?
I am currently working on a semi-large project that has several packages. There are 3 main packages, a "client" package, a "server" package and a "common" package. There are two jars, one for the ...
3
votes
2
answers
3k
views
Using MVC style, where is the best place to put SQL functionality?
I am wondering about best practices here.
MVC (Model - View - Controller) patterns involve separating components of your program that model the data, manipulate those models, and display those ...
9
votes
5
answers
1k
views
When to stop inheritance?
Once upon time ago I asked a question on Stack Overflow about inheritance.
I have said I design chess engine in OOP fashion. So I inherit all my pieces from Piece abstract class but inheritance still ...
1
vote
6
answers
5k
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++. ...
2
votes
1
answer
639
views
Should all functions be fully self-contained (is it bad practice to share a variable between functions)?
There are two ways to do the same thing (pseudo code)
Define databaseHandle in the parent function, and use it as a global in this scope:
function API() {
function openDatabase() {
return ...
3
votes
3
answers
287
views
Development Time: sql in UI code vs domain model with datamapper
First, sorry for my English guys.
Currently this is my first programming job. I am labeled as the most incompetent programmer in my company that's because they measure the performance and ...
3
votes
3
answers
2k
views
Parallel Class/Interface Hierarchy with the Facade Design Pattern?
About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
1
vote
1
answer
191
views
How to deal with interactions between many objects
I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement ...