pattern

What's the best database access pattern for testability?

I've read about and dabbled with some including active record, repository, data transfer objects. Which is best? ...

Search file in directory using complex pattern

I am looking for a C# library for getting files or directory from a directory using a complex pattern like the one used in Ant: dir1/dir2/**/SVN/* --> Matches all files in SVN directories that are located anywhere in the directory tree under dir1/dir2 **/test/** --> Matches all files that have a test element in their path, including t...

Is it advisable to build a web service over other web services?

I've inherited this really weird codebase where they've built an external web service over a bunch of internal web services just to add authentication/authorization using WS-Security, WS-Encryption, et al. Less than a month into this engagement, I'm already feeling the pain of coupling volatile components through rigid WSDL, esp consider...

How do I configure the TortoiseSVN 'Global ignore pattern' properly?

I would like TortoiseSVN (1.5.3) to ignore certain folders, their contents and certain other files wherever they might appear in my directory hierarchy but I cannot get the global ignore string right. Whatever I do, it either adds to much or ignores too much What is the correct 'Global ignore pattern' to ignore.... Folders : bin obj r...

RAII in Java... is resource disposal always so ugly ? (was: I had a dream ?)

Hi all, I just played with Java file system API, and came down with the following function, used to copy binary files. The original source came from the Web, but I added try/catch/finally clauses to be sure that, should something wrong happen, the Buffer Streams would be closed (and thus, my OS ressources freed) before quiting the funct...

Class design: Wrapping up a datafile into a class with respect to thread-safety and testability.

I'm writing an app in C# (.net 3.5) and I have a question about class design: I'd like to create a class which accesses a file (read, write) and provides its content to the users (instanciators) of the class. The most common operation on an instance will be to retrieve a certain value from the file. The actual read and write (io) opera...

Appling Unit Of Work pattern

I have read in Patterns of Enterprise Application Architecture that a Unit Of Work should only be used in a single Session. So each session should have its only Unit Of Work. Can anybody tell me why I could not use one Unit Of Work for the whole application (in my case ASP.NET). thx, Lieven Cardoen aka Johlero ...

Ocaml: Match expression inside another one?

Hello, I'm currently working on a small project with Ocaml; a simple mathematical expression simplifier. I'm supposed to find certain patterns inside an expression, and simplify them so the number of parenthesis inside the expression decreases. So far I've been able to implement most rules except two, for which I've decided to create a r...

Immutable object pattern in C# - what do you think?

I have over the course of a few projects developed a pattern for creating immutable (readonly) objects and immutable object graphs. Immutable objects carry the benefit of being 100% thread safe and can therefore be reused across threads. In my work I very often use this pattern in Web applications for configuration settings and other obj...

Memento implementation on .NET

I've seen two different implementation of memento on .NET. One is pretty straightforward - The object creates another instance of itself. The other is serializing the object using BinaryFormatter and MemoryStream. Which is the preferred method? Can anyone point out advantages/disadvantages of each approach? ...

Is there a known pattern for scheduling events programatically?

Does anyone have a known, solid solution for the scheduling of events (i.e. appointments, meetings, etc) within a system. I'm speaking here of "events" as tasks that need to be done on a one-time or recurring basis and executed based on a schedule. I've found a schedule UI component by DevExpress and it has some reference to using custom...

RIA Server Pattern

Which kind of sever side pattern would be best suitable for a middle-weight RIA application? Now I have a Data Access Layer generated by SubSonic. Most of the times a service is called from Flex (with WebORB). This service then calls the Business layer. The business layer will get some data (SubSonic Collections or SP's), the data is co...

Regex to find an integer within a string

I'm new to using regex and I'd like to use it with Java. What I want to do is find the first integer in a string. Example: String = "the 14 dogs ate 12 bones" Would return 14. String = "djakld;asjl14ajdka;sdj" Would also return 14. This is what I have so far. Pattern intsOnly = Pattern.compile("\\d*"); Matcher makeMatch = intsOnly....

Pattern suggestions needed (Hibernate + Guice)

Hi, all, I'm looking for suggestions on how to inject runtime dependencies into JPA entities retrieved from Hibernate. My problem is essentially this: I have a number of different subclasses of a Transaction object. Each Transaction subclass has different behavior when it is executed, and requires a different set of dependencies from t...

MVC pattern in .NET: Can View call Exceptions in Model?

I'm using the MVC pattern in a .NET winform app. There are places in the Controller that can cause an exception. Rather than catching the exception and dislpaying a messagebox, which is a View responsibility, I do nothing in the Controller and let the View wrap that area in a try/catch. So far, there isn't anything that needs to be do...

Factory Pattern Advice Needed Please

I'm working on wrapping my head around the factory pattern by using it in a simple data storage project in my free time. The idea is to take simple data and save it to a database using a simple factory pattern in VB.NET. I think I have a basic understanding of the pattern itself, however, what I'm struggling with is how to fit the fact...

Use Linq to Query for terminal/Leaf nodes in Hierarchical Table/Composite pattern

I have a self-referencing table with an Id, CategoryName, and ParentId. It's a typical scenario of a hierarchy table of categories that can themselves be divided into categories that DB experts tell me is called the adjacency model. What I want is to use Linq to SQL to query for subcategories that themselves are related to no other sub...

C# multiple string match

I need C# string search algorithm which can match multiple occurance of pattern. For example, if pattern is 'AA' and string is 'BAAABBB' Regex produce match result Index = 1, but I need result Index = 1,2. Can I force Regex to give such result? ...

Regex Pattern - Allow alpha numeric, a bunch of special chars, but not a certain sequence of chars

I have the following regex: (?!^[&#]$)^([A-Za-z0-9-'.,&@:?!()$#/\])$ So allow A-Z, a-Z, 0-9, and these special chars '.,&@:?!()$#/\ I want to NOT match if the following set of chars is encountered anywhere in the string in this order: &# When I run this regex with just "&#" as input, it does not match my pattern, I get an error...

Regex to block all < in a String

I'm trying to create a Regex to block all < and > in a String except when used with <select>. Can anyone suggest a Regex for that? I'll be using it with javax.util.Pattern. I'm trying to write a solution to block the injection attack and XSS attempts through request and URL. For that, I'll be blocking the special characters and charact...