Lets say we have a program which contains such classes:
public interface AbstractItem {
}
public SharpItem implements AbstractItem {
}
public BluntItem implements AbstractItem {
}
public interface AbstractToolbox {
//well the problem starts here...
public List<AbstractItem> getItems();
}
public ExpensiveToolbox implements Abstr...
I recall a design pattern for handling locking issues in C++ (where some locks are not re-entrant) by separating methods into 'external' and 'internal' ones. External ones acquire locks and can call internal ones which in turn assert that locks are held. External ones cannot call other external ones (because that would deadlock) and for ...
1) To my understanding, in a three-tier Asp.Net application we should implement exception handling in the following way:
a - we should put try-catch block around block of code ( located in any of the three layers ) from which we expect the page to gracefully recover from ( when this code generates an exception )?
b - we shouldn’t put t...
For a design patterns class, the instructor asked my team to develop an application that supports drawing and persisting glyphs, very similar to the WYSIWYG editor from GoF.
My team decided to use a Layered architecture, with descending layers: Presentation, Controller, Logic, Persistence.
The Logic maintains a collection of glyph repr...
Hello everyone.
I try to never delete the actual records from the important tables in my database, instead mark them as Deleted by setting corresponding field to True. But in case of a membership this approach will prevent any future user of reusing the username of the "deleted" user. Username won't be a problem, but what if the "delete...
It seems that there are similarities between Proxy and Adapter pattern?
Can any one please explain what are the differences? Why we require both of them? In which problems we should use only proxy and NOT another by an .net example?
Thank you
...
Given:
private void UpdataFieldItems(List<FieldItemBase> existingFieldItems, List<FieldItemBase> selectedFieldItems)
{
List<FieldItemBase> newFieldItemsSelected;
var fieldSelectionChanges = GetFieldSelectionChanges(out newFieldItemsSelected);//retuns a Flagged enum
if (Coding.EnumHas(fieldSelectionChanges, F...
Hi,
i have to create a program for a kind of complex proces.
Well, the process is not complex, but there are a lot of variables which control the process.
I can't in detail tell about the process, so i've made up one, which has the same load of IF's:
the process is: should we stop the iron melt oven or not.
We've got these parameters:
...
This is an example of a type of problem I have been having.
When a user comes to the home page of my app there are two possibilities, he/she is:
logged in
not logged in
If the user is logged in I want to display the username in the top right and a link which says "logout". If the user is not logged in I want to display a link which...
I have an app. that displays objects and tags related to these objects (not a very original app). One difference is that tags have "types". Most have the simple type=object, but others have type=file. Depending on the tag, they will have different renderings. For example clicking an object tag shows other objects that match, but on the f...
I'm looking for an example of where the State design pattern has been used to solve or simplify interesting or complicated state transitions. There are plenty of examples with three or four simple states. But what about code from real life projects that have sub-states and more than a handful of transitions? The kind of code that actuall...
Hello.
I have to model classes and database tables for a "User" entity.
This "User" entity have this properties:
User
Name
Age
Gender
Email
But I have 2 user's type: "Paid users" and "Free users". Each one have his own properties:
Paid User
Fee
Rate
Free User
Expiration Date
Level
"Paid User" and "Free User" ar...
I’m trying to decide which of the two factory patterns I should use in my Asp.Net applications:
1 : All DAL providers derive from same abstract base class DepartmentsProvider, which defines public interface of the class ( all the necessary CRUD methods for which derived classes (providers ) provide a concrete implementation ). BLL lay...
I have a webapp written in PHP using a MySQL database backend. This question could just as easily apply to any language and application trying to use an SQL database and MVC OOP design.
How do you keep your SQL code restricted to the Model?
There's a rather longer story specific to my case behind the question. As previously mentioned ...
hi:
Sample of roles:
building:service:land:water:access-granted
building:service:land:water:access-granted (deny)
building:namen:bio:water:science: access-granted
I have to parse a bunch of growing list of roles whereby I need to obtain details based on some of the attributes. The roles are not defined in a database and my applicati...
string s = new string("Hello World").Replace(" ","_").ToLower().ToUpper();
So you basically return from each method the modified object so can you call new methods on it.
...
iostream objects cin, cout, cerr, and clog are objects declared in the iostream header.
I'm aware that it's possible in some compilers to attempt to use these iostream objects before they are constructed, so under some circumstances they must be subject to the "static initialisation order fiasco". In those compilers where it's always s...
I'm looking for help identifying this design pattern and learning the "typical" vocabulary it uses:
I'm working on a project in PHP, and I've created a thin ORM layer that saves generic objects to and from the database. There are two classes that do the work:
"my_object" is basically a container for various kinds of data. After being ...
I feel like I hit a wall trying to structure what I thought would be a simple database schema for modeling basic financial transactions. I'm hoping some of you with more experience can weigh in and point me in the right direction.
My application has four distinctly different types of leases that customers can purchase. As such, each typ...
Let's say I have the following class:
class Foo
{
public:
Foo()
{
Bar();
}
private:
Bar(bool aSendPacket = true)
{
if (aSendPacket)
{
// Send packet...
}
}
};
I am writing a test harness which needs to create a Foo object via the factory pattern (i.e. I am not instan...