In virtually every project I've ever worked on, there will be one or two classes with the following properties:
Extremely large with many many members and methods.
Many other classes inheriting from this class.
Many other classes otherwise depending on this class.
Bad design, you might say. But in all cases, this wasn't the case at ...
If I have limited time, but I want to start learning a few design patterns, which ones should I learn first?
...
NOTE: Sorry for the long question!
I'm trying to understand some key areas behind object orientation and I couldn't decide one way or another about my particular question.
Let's say I have an object full of lovely data. Class bob.
Bob myBob = new Bob("This string is data");
Let's say I want to save the contents of myBob to an xml f...
I'm working on a project where I need to add some functionality to a service object and using a decorator to add it in seems like a good fit. However, I've only ever used decorators with simple beans, never on a singleton like a service object. Has anyone ever done this before and what are the pros and cons? In this case I don't think cr...
What I mean by this, is that sometimes architects look to simplify and improve testability, at the expense of other important forces.
For example, I'm reviewing a very complicated application, made so by extensive use of design patterns that overly favor testing, e.g. IoC, DI, AOP, etc...
Now, typically I like these things, but this ...
I have read multiple articles about why singletons are bad.
I know it has few uses like logging but what about initalizing and deinitializing.
Are there any problems doing that?
I have a scripting engine that I need to bind on startup to a library.
Libraries don't have main() so what should I use?
Regular functions or a Singleton.
Can th...
I'm struggling with implementing the Bridge design pattern (or an alternative such as Adapter) in Python
I want to be able to write code like this to dump database schemas based on a supplied URL:
urls = ['sqlite://c:\\temp\\test.db', 'oracle://user:password@tns_name'];
for url in urls:
db = Database(url);
schema = db.schema()
...
I'm looking for an elegant way to have AppContext configured right and here is it:
public class AppContext : IAppContext
{
public AppContext()
{
Application = new AppStorage(); // app scoped hashtable
Local = new LocalStorage(); // current thread scoped hashtable
Session = new SessionStorage(); ...
There's a lot of confusion over MVC but after flicking through a Head First patterns book (As a side note I hate that brand, though this example was quite good) it claims that MVC or Model View Controller is a hybrid of multiple patterns - mediator, observer etc...
In a recent prototype I did the following, it's C# but should be straigh...
Assume you have controls A, B, C, D and E all with a Visibility property. You also have states 1,2,3,4,5 and 6 in which various combinations of your controls would be displayed.
Currently this is being handled by switch statements for each state: i.e.
Select Case PageState
case "1"
a.visible = false
b.visible = true
...
I have a simple address object in my domain that has a ToString() method that returns the address like this:
123 Test Ave
Appt 1A
Spokane, WA 99201
We will be diplaying this in a webpage on several different occasions so it makes senses to add the functionality somewhere to display the address with Html formatting, but if I where to ad...
Hello there,
I am thinking to create a Custom Control button that would do a CRUD tasks for me. Let me elaborate:
I wanted something that save time to writeup code on every UI for CRUD tasks. I am here becuause I want to make sure the approach I am taking should be verified before I am putting hours and taking strain.
A Custom (could ...
Hi the wise folks at SO. This is an SOS.
I'm in a deep trouble. In my web application there is an object (Say it is a request for something). User submits his/her request. After this it comes to the people who can approve/disapprove that request. During the period from submission to approval/disapproval many actions can be taken on the ...
hi, I am building a web application and I want to manage cache for several objects, so I don't have to go to the DB each time. my problem is that this objects`s data can be modified by other application on the DB. Does anyone knows a good pattern to keep my cached objects in sync with the BD?.
I read this article (www.developer.com/java/...
In C++, I understand that it is possible to create a Singleton base class using templates. It is described in the book, Modern C++ Design, by Andrei Alexandrescu.
Can something like this be achieved in Java?
...
I am still learning MVP. I have a IView and a presenter. I have a custom List control that I have written for this application. I'd like to add some items to it, one at a time. Should I expose IView.AddItem(Item) or should I expose a IView.MyCustomList property?
Is this a matter of style, or is there a correct answer to this one?
...
What are your opinions on how disposable objects are implemented in .Net? And how do you solve the repetitiveness of implementing IDisposable classes?
I feel that IDisposable types are not the first-class citizens that they should've been. Too much is left to the mercy of the developer.
Specifically, I wonder if there should'nt have be...
Hi, this must be such a common scenario that there's been a lot written about it already, hopefully even a really good pattern. I have a domain model in which a custom container contains entities. For example (properties and interfaces excluded for brevity):
class Entity
{
public int Id;
public EntityContainer ParentContainer;...
It seems that while I strive to maintain OO principles, it all seems so contrived or unnatural.
...
I've seen a million examples of DAOs, and for the most part they all implement your basic CRUD operations for single entities, with maybe a few methods that return lists (e.g. List getCustomers()).
However, I've never seen an example in which there is a method that updates, deletes, or creates multiple entities, like: void update(List)....