Tagged Questions
0
votes
0answers
55 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
0answers
75 views
Real world Programming [on hold]
When starting a new project are design patterns useful way of coding for rapid prototyping (small scale projects) or are they for production (full blown projects) or for all cases?
0
votes
0answers
7 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
68 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
65 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
226 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 ...
2
votes
1answer
146 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
220 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
45 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
169 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 ...
5
votes
3answers
197 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 ...
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:
...
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
91 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 ...
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
138 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
175 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
236 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() {}
...
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
228 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
1answer
182 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
2answers
139 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 ...
0
votes
1answer
129 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 ...
2
votes
2answers
265 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 ...
3
votes
3answers
347 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
304 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
211 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
272 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 {
...
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 ...
5
votes
2answers
824 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 ...
0
votes
2answers
215 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 ...
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 ...
2
votes
3answers
453 views
Layering Design Pattern in Java clean code style
As a Java developer, I am developing trying to use the clean code rules. But in my team we are facing a concrete problem:
We have a business layer offering a service called "createObject", this ...
1
vote
1answer
192 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 ...
2
votes
7answers
490 views
Is there a pattern to restrict which classes can update another class?
Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really ...
0
votes
1answer
83 views
How are the forwarding of requests normally managed in the Chain of Responsibilty pattern? [closed]
I was just experimenting with the Chain of responsibility pattern, implementing my own version.
I'm currently reading Design Patterns, but I'm not really sure whether DP tells to stop your ...
1
vote
2answers
297 views
Loadbalancing and failover in code
I have HTTPS based webservices (not REST, rather old code). I am generating Java client stubs using Axis & using that to call the webservices. There are around 20 different APIs on the webservice. ...
2
votes
1answer
287 views
Optimized Special Character Escaper vs Matcher/Pattern
I need to escape special characters which are sent to apache lucent.
Since the code will run on a production server I want the code to be the fastest possible.
I've seen multiple ways to do it:
...
0
votes
0answers
81 views
Recaching calculations
I'm working on a webapp which has an existing framework to cache values from the database. I have a requirement which needs multiple values from the database and the values have to be ...
1
vote
1answer
128 views
how to model a connection to a resource, with rudimentary event processing
For my simple MUD client I'm using Apache Telnet (no, not ssh). A mud client is a strange beast:
Generally, a MUD client is a very basic telnet client that lacks VT100 terminal emulation and the ...
3
votes
1answer
216 views
Mutual observer pattern in Java
I want to improve my multi-threading and design pattern skills. As such I'm designing an Instant Messaging server.
I'm writing the Server first.
My plan so far is to have Client "Proxy" Classes to ...
4
votes
2answers
731 views
How does MVC work with the principle “Tell, Don't ask”?
Procedural code gets information then makes decisions. Object-oriented
code tells objects to do things.
— Alec Sharp
So, when a view wants to display some information that is suppose to be ...
13
votes
9answers
4k views
Are too many if-else statements for validation bad? [duplicate]
From the book Professional Enterprise .Net, which has 5 star rating on Amazon that I am doubting after having a read through. Here is a Borrower class (In C# but it's pretty basic; anyone can ...
1
vote
1answer
170 views
Law of Demeter issues with complex class design
I've posted questions pertaining to this issue before, but they've all tackled different aspects of the problem (Just so you know that I'm not reposting the same question to get more answers).
So, in ...
2
votes
3answers
435 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 ...
-3
votes
1answer
199 views
Best Object Oriented way of parsing a model with several fields(>50) and with null checks
I have a JSON-based data which contains many fields from a particular model. Any value
from the list of fields can be null. I am trying to find the best object oriented way
of parsing it and also it ...
3
votes
2answers
282 views
Can classes violate Single Responsibility if they delegate internal tasks?
I have two classes Output and Timeline, neither of which violate SR, but the two of them are linked together. So what I'd like to do is have a class called Elco (there's a reason behind the name) that ...
1
vote
4answers
518 views
Explanation of the definition of interface inheritance as described in GoF book
I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance:
Class versus Interface Inheritance
It's important to understand the difference between ...