Tagged Questions
0
votes
1answer
59 views
software design for client/server, over sockets, with JDBC
What's a reasonable architecture and design for a client/server application, over sockets, using JDBC?
Right now I have the server query the database and instantiate a Queue of records. Clients may ...
1
vote
1answer
128 views
Builder pattern inside interface. Bad design decision?
I am having trouble evaluating an implementation of the builder pattern I just came up with.
The context is an API library, so I am trying not to expose any implementations in order to have a stable ...
0
votes
0answers
79 views
How to design extension mechanism for java app
I have an application where I have a set of core features.
The application itself HAS to work in core only mode.
I would also want to make the application extensible such that, when certain ...
4
votes
3answers
79 views
Returning results of method on batch list?
The title is a bit vague so I'll try to elaborate.
I have a function
makeFoo(int bar) -> returns Foo or throws Exception.
I also have a batch version of this
makeFoos(int[] bars) -> ...
0
votes
0answers
77 views
Result Object vs. Exceptions [closed]
Related to this question I posted earlier:
Returning results of method on batch list?
I stumbled across an interesting idea at: https://www.braintreepayments.com/docs/java/general/result_objects
...
0
votes
1answer
213 views
Email Content creation | Proper design
Working on an E commerce application where we need to send so many email to customer like
Registration email
Forget Password
Order placed
There are many other emails that can be sent, I already ...
0
votes
0answers
8 views
Select design pattern - user stage [duplicate]
I'm struggling to point a finger into the right design pattern.
I have a web site which user can register and interact with the system.
I want to add the following abilities to a user:
Each user ...
0
votes
1answer
77 views
DTO - service layer - statelessness best practices interfering with each other
I am designing a REST API coupled with a service layer that takes DTOs as input and produces them as output. This works fine for most service calls where the DTO is used to access an underlying ...
0
votes
1answer
67 views
Implement RPC via SIP
Look at the following use case.
I have a client (Java) application, which wants to get/set the state of another, remote application (C). The communication between them is done via SIP, which is run ...
3
votes
2answers
232 views
Is the Java Integer cache a realization of the object pool pattern?
One of the best-known examples of a full-fledged object pool is the JDBC connection pool. Main reasons:
objects in the pool are expensive to create and relate with external resources
each object in ...
6
votes
6answers
953 views
Should I extract specific functionality into a function and why?
I have a large method which does 3 tasks, each of them can be extracted into a separate function. If I'll make an additional functions for each of that tasks, will it make my code better or worse and ...
6
votes
8answers
1k views
How to split large, tightly coupled classes?
I have some huge classes of more than 2k lines of code (and growing) that I would like to refactor if possible, to have some more light and clean design.
The reason it is so big is mainly because ...
2
votes
1answer
148 views
Working with a large, messy object [duplicate]
I have been handed a very cluttered, "One Ring" object (one object to rule them all). The OR class has 40 fields. These fields map to 16 different objects (the OR has all the fields from the 16 ...
-2
votes
4answers
227 views
What is the name of this design pattern? [closed]
I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it).
Example in PHP ...
0
votes
0answers
59 views
Android From Local DB (DAO) to Server sync (JSON) - Design issue
I sync data between my local DB and a Server.
I'm looking for the cleanest way to modelise all of this.
I have a com.something.db package
That contains a Data Helper and couple of DAO classes that ...
-1
votes
2answers
171 views
Help with MVC design pattern? [closed]
I am trying to build a java program for user login but I am not sure if my MVC design is accurate. I have the following classes:
LoginControl - servlet
LoginBean - data holder java class with ...
19
votes
4answers
2k views
Builder Pattern: When to fail?
When implementing the Builder Pattern, I often find myself confused with when to let building fail and I even manage to take different stands on the matter every few days.
First some explanation:
...
5
votes
3answers
199 views
How to refactor my design, if it seems to require multiple inheritance?
Recently I made a question about Java classes implementing methods from two sources (kinda like multiple inheritance). However, it was pointed out that this sort of need may be a sign of a design ...
4
votes
2answers
396 views
How to delete an object when other things reference it (and not making the code full of inter-dependencies)
The situation:
In my program, there are a list of cues. To call a cue at a certain time, there are objects called Triggers. Cues have many public methods that allow them, among other things, to be ...
0
votes
2answers
134 views
Is using interfaces on internal code a good idea? [duplicate]
I'm working on a set of automated tests that we use internally at work. Lately, we've been designing classes that implement interfaces in addition to inheritance.
As I understand it, interfaces in ...
2
votes
1answer
92 views
What's the right OO way to create a counter/inventory class that works for both differentiated and undifferentiated countables?
You are writing a videogame about trading beans. Red beans, black beans, pinto beans, you name it. As everybody knows all beans are the same. You write the "Inventory" class for a trader in that ...
5
votes
4answers
801 views
What is a good pattern for combined caching and reinitialization?
I have a situation where I have three requirements:
Lazy initialization - don't create the collection until asked for it
Caching - keep the collection in memory on the object
Reinitialization - be ...
18
votes
5answers
3k views
How would another popular language avoid having to use the factory pattern while managing similar complexity as in Java/Java EE?
Factory pattern (or at least the use of FactoryFactory..) is the butt of many jokes, like here.
Apart from having verbose and "creative" names like ...
1
vote
2answers
141 views
Java Method Returns Unbounded Type
I was reading this article, https://weblogs.java.net/blog/emcmanus/archive/2010/10/25/using-builder-pattern-subclasses, about subclassing a builder class. I understood the article but there was one ...
-1
votes
1answer
178 views
How to create a some kind of value for sentences? [closed]
I want to identify most matching sentence using some pattern. That means by using java algorithm I want to create identical value for each sentences.Each sentence when entering to that algorithm can ...
4
votes
2answers
238 views
How to decouple simple factory and default implementation?
I have a simple factory class (FileResources) with static factory methods providing a default implementation (DefaultFileResource).
public final class FileResources {
private FileResources() {}
...
2
votes
2answers
286 views
Best practice with respect to anonymous classes in UI applications
When working with user interface based Java programs, one way of attaching behaviour to a certain actions (e.g. to a button click) is through the use of anonymous classes. In the example below, the ...
0
votes
1answer
130 views
Using a variable in a Global context in webapps
In a webapp, I have a scenario where I need some kind of global context (Static like) for few variables, for the current thread only.
If there are 3 different concurrent users, then I expect three ...
20
votes
2answers
3k views
How to improve upon Bloch's Builder Pattern, to make it more appropriate for use in classes that may be extended and sub-extended many times over?
I have been greatly influenced by Joshua Bloch's Effective Java book (2nd edition), probably more so than with any programming book I've read. In particular, his Builder Pattern (item 2) has had the ...
1
vote
1answer
232 views
Android Data persistence question
I have an android app in which users have sets of items, and each item has about 10 properties.
What I do at the moment:
items are stored in the server database
when the user logs in, I get all the ...
0
votes
2answers
140 views
Best way to display domain object summary information efficiently and in an OO way from a large inheritance tree?
I've provided only simplified code as it's more of an abstract design question.
So I have many, many nested business/domain event objects, e.g.
public class Event
{
//bunch of properties and ...
3
votes
1answer
1k views
Opensource showcase for MVC in Java Swing [closed]
I've allready created small desktop CRUD applications using Java/Swing. In hindsight I'm not quite sure if the overall design of these applications is good. I've also done some reading on MVC and ...
3
votes
3answers
358 views
Why should a builder be an inner class instead in it's own class file?
Many Builder Pattern examples make the Builder an inner class of the object it builds.
This makes some sense since it indicates what the Builder builds. However, in static a static type language we ...
3
votes
1answer
310 views
State pattern vs Inheritance
In the following image for the State Pattern from Applying Domain-Driven Design and Patterns: With Examples in C# and .NET
I'm trying to persist the SalesOrder entity into the database. Normally I ...
1
vote
1answer
250 views
Creating a System Sequence Diagram from an [extended] use case
As I have been taught - one controller = one use case.
But I have:
OutsiderController
SupplierController (which extends OutsiderController)
SubContractorController (which also extentds ...
-4
votes
1answer
2k views
Singleton: Is Singleton an Anti-Pattern [duplicate]
Was reading an interesting blog post on Singleton design pattern which is so widely used.
If it's stupid or as in some quora posts, its an anti-pattern why is it so widely used even in frameworks.
...
0
votes
2answers
677 views
Designing application flow
I am creating a web application in java where I need to mock the following flow.
When user trigger a certain process (add product to cart), I need to pass through following steps
Need to see in ...
1
vote
1answer
217 views
Decorator Pattern in Head First Design Patterns
I'm trying to teach myself some design patterns using a book that I was recommended, Head First Design Patterns. I came to the chapter on the Decorator Pattern, and although I understand the purpose ...
1
vote
2answers
274 views
If every instance of a type is to be random, how should the Random generator object be stored?
It seems to me that this is often encountered in practice and I was wondering if there is a design pattern for the following:
Suppose I have a class that represents a card:
public class Hand {
...
5
votes
2answers
888 views
Open Close Principle (OCP) vs Dependency Inversion Principle (DIP)
I was trying to understand the difference between Open Closed Principle (OCP) and Dependency Inversion Princible (DIP).
Based on research I've made on the internet so far, I came to the conclusion ...
4
votes
1answer
451 views
Designing status management for a file processing module
The background
One of the functionality of a product that I am currently working on is to process a set of compressed files ( containing XML files ) that will be made available at a fixed location ...
3
votes
3answers
1k views
Which design pattern is more suitable for logging?
I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
2
votes
3answers
443 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 ...
0
votes
2answers
216 views
Best place for a factory interface
What's the best place for a factory interface to create an instance of another interface?
OptionA: a separate class
public interface InterAFactory {
InterA createInterA();
}
public interface ...
0
votes
1answer
237 views
Flexible / Dynamic object creation or Alternative to list of lists [closed]
I have a xlsx file, that has some tabs with different data. I want to be able to save each row of a tab in a list. The first thing that comes to mind is a list of lists, but I was wondering if there ...
2
votes
3answers
290 views
Which one of these designs is preferred? [duplicate]
In the case of an application with a single simple responsibility (eg, a simple replacement for grep or wc), which of these designs is preferred and why? I find that they are all testable and they all ...
1
vote
1answer
198 views
Is there a name for the Builder Pattern where the Builder is implemented via interfaces so certain parameters are required?
So we implemented the builder pattern for most of our domain to help in understandability of what actually being passed to a constructor, and for the normal advantages that a builder gives. The one ...
12
votes
3answers
3k views
Static factory vs factory as a singleton
In some of my code, I have a static factory similar to this:
public class SomeFactory {
// Static class
private SomeFactory() {...}
public static Foo createFoo() {...}
public ...
11
votes
3answers
3k views
Improvements to Joshua Bloch's Builder Design Pattern?
Back in 2007, I read an article about Joshua Blochs take on the "builder pattern" and how it could be modified to improve the overuse of constructors and setters, especially when an object has a large ...
13
votes
5answers
6k views
What is the difference between all-static-methods and applying a singleton pattern?
I am making a database to store information about the users of my website (I am using stuts2 and hence Java EE technology). For the database I'll be making a DBManager. Should I apply singleton ...