The NullObjectPattern is intended to be a "safe" ( neutral ) behavior.
The idea is create an object that don't do anything ( but doesn't throw NullPointerException either )
For instance the class defined as:
class Employee {
private String name;
private int age;
public String getName(){ return name; }
public int get...
This time I have a more philosopical question.
Most MVC tutorials/books seem to suggest to restrict the scope of one repository to one aspect of the model and set up multiple repositories to cover all model classes. (E.g.: ProjectRep, UserRep, ImageRep, all mapping onto the same db eventually.)
I can see how that would make unittesti...
I find this design pattern comes up a lot:
try: year = int(request.GET['year'])
except: year = 0
The try block can either fail because the key doesn't exist, or because it's not an int, but I don't really care. I just need a sane value in the end.
Shouldn't there be a nicer way to do this? Or at least a way to do it on one line? Some...
In the following example, the class Derived implements the abstract method method from class Main. But I can't think of a reason to fill in the method body in the abstract Derived class' implementation. Surely I should only implement abstract methods within real classes.
So how can I avoid doing it? What else can I do?
abstract class ...
This project is in PHP, but is fairly language agnostic. I'm building a project that has the following MVC format
Main_Class
Main_Class_Common
--> Class_A
--> Class_B
--> Class_C
--> Class_...
--> Class_K
Original requests go to the Main_Class which then includes the appropriate main sub class. The majority of a request will...
Hi I have a problem where i have to perform similar steps / actions (which differ slightly) on different sets of data (the data can be slightly different also with regards to its strucure). There are a few steps that i need to perform: connect, validate, build error messages if required, change the strcture of the data in to a set forma...
Hello, say you are implementing an api that usually takes data in the form of associative arrays, processes them for validation etc and converts them into a different format (still an array, although the keys and overall structure is different), and then sends them off to get processed further. What would be the best way to handle this....
Hi, I have been reading a bit lately about the singleton pattern. When readin the technical aspects of it, it appears to be ideally suited to managing a database handler or the likes. But after reading wider resources it appears that the developer community really does not favour the pattern.
I am struggling to find a better solution ...
Hi,
I'm revisiting a communications protocol parser design for a stream of bytes (serial data, received 1 byte at a time).
The packet structure (can't be changed) is:
|| Start Delimiter (1 byte) | Message ID (1 byte) | Length (1 byte) | Payload (n bytes) | Checksum (1 byte) ||
In the past I have implemented such systems in a procedu...
Hi all
I'm writing an ASP.NET app. I need to include a page where the user can add an item which has several sets of subitems, each of which sets is unlimited in number. The subitems themselves contain between 10 and 15 fields, so need a fair bit of UI space.
As an example of what I mean, the user needs to be able to add a Business rec...
Hi,
Any one please explain the modelLocator design pattern with simple example and where and when we are going to use this.?
Thanks,
Ravi
...
I'm currently having to integrate a lot of web service calls inside Silverlight that make calls similar to the code below. No user interaction should be possible until the loading of all 3 is complete.
// In my view, having standard delegate methods (non-anonymous) makes the
// code below even messier.
// I've left out the EventArgs t...
Hi,
These 2-3 last years, many projects I see, like Cuyahoga open source C# CMS, tends to define persistent and non persistent classes as Interface. Why? Is there a good reason? TDD? Mocking? A design pattern? ...
...
Given that Mixins generally introduce new behaviour into a class, this generally implies that a class would have more than one behaviour.
If a class has a single responsibility this is defined as the class having only one reason for change.
So, I can see this from two different perspectives
The class only has one reason for change....
What I have is a LineItem object and a collection called LineItems that holds LineItem objects. My LineItem objects have a property called ItemDate (DateTime data type) and another property called ItemAmount (decimal data type) and another property called ItemCategory (integer data type).
What I am trying to do is write a function in my...
Hi all
As part of my endless NHibernate-inspired DAL refactoring purgatory, I have started to use the Repository pattern to keep NHibernate at arms length from my UI layer. Here's an example of a Load method from a repository.
public StoredWill Load(int id)
{
StoredWill storedWill;
using (ISession session = NHibernateSessionFactory...
Ok im going to keep this really simple. Which method is the best for the likes of db handlers in an application: Singleton, Registry pattern, static configs class or config files.
Ive been reading about this and there seems to be a lot of contradictory ideas on this.
I understand that there wont be a one fits all solution but gener...
Hi this is a question to all experienced developers who create their web applications using ASP.NET(C#) with MySQL. I am currently using the Microsoft Enterprise Library to implement a database factory design pattern.
I have a DAL which returns a DataTable. I have a BLL that executes that DAL which returns a List<> of my DataObjects. T...
I often find myself designing simple little web projects that are serving up aggregate content or doing a 'mashup'. Typically this involves running a script to scrape/parse/manipulate some data periodically, then serving that as 'static' content.
I run the 'refresh' script as a cron job that generates HTML that is served up to the end-...
Possible Duplicates:
list of c++ tricks with names
What C++ idioms should C++ programmers use?
After reading books like C++ Primer, Effective C++ and TC++PL I want to learn some important design patterns.
So, what are the famous design patterns that every C++ programmer should know?
...