patterns

SQL Server TSQL conventions/patterns on SET, WITH and ENABLE

After years of using TSQL, I still cannot figure out when to use SET, WITH or ENABLE. When you read TSQL statement like, ALTER TABLE Person.Person ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON); It looks more intuitive and readable if it was written like (invalid query below), ALTER TABLE Person.Person SET CHANGE_TRACKI...

In Presenter First, why is SubscribeSomeEvent method on an interface preferred to plain old events?

I recently found out about Presenter First and read their whitepapers and blogs, etc. In most of the examples I found, the events are not declared directly on the interface but rather as a method for it. For example, public interface IPuzzleView { void SubscribeMoveRequest(PointDelegate listener); // vs event PointDelegate...

Formula/pattern to provide a unique 32 bit int that represents a 512 character file path?

Is there a common formula that could provide a unique value for a 512 character file path, assuming one 32 bit byte per character, and possibly limiting the characters used in the names? I know that if you just used uppercase letters alone the combination would be grossly more than a 32-bit int, but what about using an identity field wi...

In Mathematica, how can I find patterns that include rules and lists?

Example: test = {"a" -> {{1}, 12}, "b" -> {13}} I'd like to find all expressions in the list with this pattern: _ -> {_,_} The first element, "a" -> {{1}, 12}, is represented by this pattern. However, none of these expressions work: Cases[test,_->{_,_}], Cases[test,_->_], Cases[test,Rule[_,_]], etc. Any advice would be apprecia...

Another preg_replace question!

Ive got a string that are words bunched together and I need to seperate them, and every word that ends in 'A' should probably be on a new line, item onea second itema third I also need to check if the word ending in 'A' should actually end in 'A' like extra or sultana. item oneasecond itemand an extra item I have an array full of ...

What are some good use cases for the CALLBACK pattern/idiom?

I don't use this pattern, maybe there are some places where it would have been appropriate and I used something else. Have you used it in your daily coding? Feel free to give samples, in your language of choice, along with your explanation. ...

Best method to remove session handled by Session Proxy pattern

Hi all, I would like to use Proxy pattern for Session handling. In my session proxy class I have something like that: public static class SessionProxy { private const string ThemeNameSessionName = "ThemeName"; private const string PasswordExpirationDaysSessionNam = "PasswordExpirationDays"; /// /// Gets or sets ...

AJAX - PHP Communication patterns

I'm building a webapp in MySQL/PHP/Javascript. In PHP, I've got all the classes from the domain od the problem which persist in the database. In Javascript, there is a cache with objects from the last queries. When an object in Javascript is updated by the user, it has to update itself in server-side. Which would be the best way to do ...

Python: is using "..%(var)s.." % locals() a good practice ?

I discovered this pattern (or anti-pattern) and I am very happy with it. I feel it is very agile: def example(): age = ... name = ... print "hello %(name)s you are %(age)s years old" % locals() Sometimes I use its cousin: def example2(obj): print "The file at %(path)s has %(length)s bytes" % obj.__dict__ I don't ne...

What are UI Patterns?

What is the difference between User Interaction Design Patterns and User Interface Design Patterns. I have heard that one is the subset of the other, but how do thy correlate? What is the correct term for ui patterns e.g., from http://uipatternfactory.com/? ...

What's the difference between the Dependency Injection and Service Locator patterns?

Both patterns seem like an implementation of the principle of inversion of control. That is, that an object should not know how to construct its dependencies. Dependency Injection (DI) seems to use a constructor or setter to "inject" it's dependencies. Example of using Constructor Injection: //Foo Needs an IBar public class Foo { ...

Is the Prototype Design Pattern Really Just Clone?

I am doing an in depth study on design patterns, and I came across prototype, which I didn't really study before. I have searched the web and several books, and there isn't a really good example of prototype that could find that isn't just clone. Is the design pattern of prototype basically a language feature of java and C# as clone? ...

jQuery (anti-)pattern: building selectors with string manipulation

Too often I find myself building selectors with string manipulation (split, search, replace, concat, +, join). Good or bad? ...

Java Web Application Configuration Patterns

Are there any patterns or best practices that can be used to simplify changing configuration profiles for java web applications across multiple environments. e.g. JDBC URLs, SOAP end-points, etc. As a bit of background to help clarify my question, I work with several large java web applications that during any given release cycle move...

Factory Creation Methods Always Static?

It's common place for factory classes to be static, and factory methods to be static also. Did the GOF in the Design Patterns book ever stipulate that factories and their methods MUST be static in order to meet the strict definition of the pattern? Is having factories+/methods static just a consequence of the pattern? state data is not...

How to set ID in Object Oriented Code.

I'm a bit confused when it comes to Object oriented programming for say a 3 tier application. Here is just a small example of what I am trying to do (I will shorten the database design to make it simple). Assume I am making a ticket help desk system. A ticket has a description, a responsible person, a due date, and of course an ID (un...

What is the name of the pattern?

Hi. I often design system where I have a class in my system that has a bunch of protected methods. The protected methods are that because they should be accessible to specializations, and as such, I consider the protected methods to be a contract between my general class and any specialized classes. Therefore I want to test that these...

Simple method for accepting command-line input for a standard Windows service written in C#?

Hey stackoverflow, I have written a pretty simple Windows service in C# that starts up automatically and runs A-okay. I was wondering the best method to have the service accept command-line input -- it will always be from the same user (admin), and the service itself is fully trusted (LocalSystem). I know a little (very little) about d...

What is a DataVO pattern?

While looking at some open source code to learn more about J2EE, I came across classes (or packages) named DataVO. In the code I looked at, this was simply serialized XML used by other classes. What is the DataVO pattern exactly? and how does it differ from Data access object or Data transfer object? Thanks! ...

What's the name of this UI pattern?

Sometimes when some feature requires many different settings, they are written in a cloze-like text, where the gaps (=variables) are displayed as comboboxes or hyperlinks which open some kind of lookup list. Example: If the available space is less than [10%/5%/1MB/...] then [send e-mail to admin/play a sound/...] The Outlook rules...