Closed as exact duplicate of this question. But reopened, as the other Singleton questions are for general use and not use for DB access
I was thinking of making an internal data access class a Singleton but couldn't convince myself on the choice mainly because the class has no state except for local variables in its methods.
What is ...
We all know that programming patterns are excellent ways to provide a repeatable design amongst each other. While most people only use a few, choosing the right pattern for the right scenario is of utmost importance.
What are the three most vital patterns you believe any programmer should know and understand in their journey, and why do...
I teach a one semester University course in systems analysis and design. Topics include design patterns, UML, OOP, software development lifecycles, and the history, benefits and drawbacks of various methodologies (such as Agile/SCRUM/BDUF/Waterfall.)
Students who enter the course should have some exposure to programming, but in reality ...
There's a lot of security advice out there to tell programmers what not to do. What in your opinion are the best practices that should be followed when coding for good security?
Please add your suggested security control / design pattern below. Suggested format is a bold headline summarising the idea, followed by a description and examp...
As an exercise, I'm translating parts of our large and battle-hardened Delphi-framework to C#.
Included in this framework is a generic singleton parent class. Of course, implementing a singleton in C# is fairly easy (there is even a Jon Skeet article, so what more could I wish for), but our Delphi singleton has a slightly different tak...
Im writing a .net webforms app. It has a number of classes, for example users, bookings etc.
At the moment I have a number of manager classes, say bookingManager, that manage these classes. For example when creating a new booking, you call the add method in the bookingManager, and pass a booking. It then checks the booking is valid, chec...
Has anyone read 'Head First Design Patterns' by O'Reilly?
If so what do you think?
...
Hi,
I am in the process of refactoring our BI layers to make our code more "loosely coupled" and I was interested to hear what you guys thought might be interesting improvements to make?
At present, our API is something like the following:-
// Fetch a collection of objects
ProductCollection prods = Product.GetProducts();
// Load an i...
EDIT: minor fixes (virtual Print; return mpInstance) following remarks in the answers.
I am trying to create a system in which I can derive a Child class from any Base class, and its implementation should replace the implementation of the base class.
All the objects that create and use the base class objects shouldn't change the way th...
Can anyone explain exactly how the Strategy Pattern relates to Inversion of Control?
...
Hi guys,
What are the basic differences between classic .cs-aspx.cs-aspx (code behind/beside) model and new MVC model?
regards,
2 Steps Solutions guy.
...
I am building an Asp.net MVC site where I have a fast dedicated server for the web app but the database is stored in a very busy Ms Sql Server used by many other applications.
Also if the web server is very fast, the application response time is slow mainly for the slow response from the db server.
I cannot change the db server as all ...
I am trying to use the repository pattern in an instance of storing pictures.
What I do is save the actual pics in a directory on disk but save data about the pics and what pics go with what object in a database. I was wondering if I should use 2 interfaces for the storage, like IStorePicRepo and IStorePicDataRepo or have 1 interface ...
Hi,
I'm porting our old Active-Record based API over to a new structure to make unit testing easier etc. We are using the repository pattern for our data access and StructureMap for dependency injection.
I'm struggling a little now with how to structure everything. Using our 'Product' class as an example, we previously had our model, r...
In my web app I use several asmx (Web Services) from the same provider, they have one for this, other for that, but all require a SOAP Header with Authentication.
It is simple to add the Authentication:
public static SoCredentialsHeader AttachCredentialHeader()
{
SoCredentialsHeader ch = new SoCredentialsHeader();
ch.Authentica...
I have wondered what type of data structures and design patterns are used when implementing something like CSS where you can specify formatting or some other property at different levels of granularity.
One specific example that I am working on at the moment relates to internationalization of an application.
First of all English is the...
I am trying to build a board game ... And looks like it has to be implemented using a state machine..
I know of the State pattern from GoF, but I am sure there must be other ways to implement state machine. Please let me know.. if you know of any articles or books that contains details about different implementation (trade off of each ...
Assume a requirement of implementing a class "CAR".
Now, this class contains various states like "un-ignited", "ignited", "broken-down", "punctured", etc.,
The way I look at to implement this requirement is to have boolean flags aka "properties" in the class and 'check the state' using these boolean flags inside each member function. F...
I have a factory that builds the objects with longest lifetime in my application. These have types, lets say, ClientA and ClientB, which depend on Provider (an abstract class with many possible implementations), so both clients have a reference to Provider as member.
According to the command-line arguments, the factory chooses one imple...
After some years of experience in the field, it seems to me that the Factory pattern is one of the less interesting and useful patterns around when not writing frameworks or libraries.
I'm not saying that Factory pattern is unnecessary. For example, the W3C Document interface serves as a factory for various XML nodes (elements, attribut...