pattern

Enable or disable the PatternLock screen from code

Hi. I try to find a way to disable the PatternLock screen temporary. I don't want the lock to be disabled completely, but the user should not need to re-enter his pattern all the time. My idea is to write a service which disables the pattern after some user activity and re-enables it after a while. (and even more) There are apps on th...

Looking for patterns/best practices for calculating complex discounts

Hi there, I'm developing a price calculation engine. I've looked all over and there's nothing that really fits what we need. However, I'm now looking how to implement specific prices and/or discounts. I don't want to introduce a rule based engine to my end-users, because they won't get it. For example, when you order an ItemX the price ...

Which of these is a repository pattern?

My domain entities are lined up like a tree: Root - Child 1 -- Child 1.1 -- Child 1.2 - Child 2 -- Child 2.1 -- Child 2.2 We ended up with 2 (rather strong) opinions on how a repository should be designed around these domain objects: Opinion 1: I need 2 repositories Child1Repository & Child2Repository which gets managed by a RootFac...

Keeping track of static method calls in a class using java.util.Observer

Hi, I'm a beginner programmer, and am wondering how to work around this issue. The problem I am trying to solve is keeping a tally of static method calls in my program using a java.util.Observer. Clearly, my original post must have just confused people so I'll leave it more open-ended: can anyone suggest a way to keep a static method ...

How do I get ShortDateFormat in classic asp

In asp.net I'm using this one: System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern Is that possible to get it in classic asp? ...

How can I use a variable's value as a glob pattern in Perl?

In Perl, you can get a list of files that match a pattern: my @list = <*.txt>; print "@list"; Now, I'd like to pass the pattern as a variable (because it's passed into a function). But that doesn't work: sub ProcessFiles { my ($pattern) = @_; my @list = <$pattern>; print "@list"; } readline() on unopened filehandle at ... ...

query check if its latitude or just text on map

on search i want to check if query is latitude and longitude or just text search with php. $query = '-122.0307642, 37.3316930'; latitude and longitude can have '-' in them also. what preg_match pattern it will be for this? ...

Can a custom guard mechanism be defined in Haskell?

If you look at the example for catches: f = expr `catches` [Handler (\ (ex :: ArithException) -> handleArith ex), Handler (\ (ex :: IOException) -> handleIO ex)] It looks like catches has defined a custom mechanism to match on patterns (the two exception types). Am I mistaken, or can this be generalized to ...

Regular expression with an = and a ;

I'm trying to use a regular expression to find all substrings that start with an equals sign (=) and ends with a semicolon (;) with any number of characters in between. It should be something like this =*; For some reason, the equals is not registering. Is there some sort of escape character that will make the regex notice my equals sig...

Shape recognition algorithms/code for Java

I'm looking for a shape recognition tool for Java. In particular, I'd like to find a Java library that given an image file (in jpeg, bmp, gif or any common image file format) gives me information about the regular shapes (rectangles, lines, ...) found in the picture and their coordinates. In previous questions on this topic I've seen r...

When using LINQ shall we use 3 layers?

When using LINQ to SQL or Entity framework,shall we need to separate application in 3 layers?BLL,DAL,Interface? ...

CodeIgniter: Decision making for creating of library & helper in CodeIgniter

Hi Guys, After developing in CodeIgniter for awhile, I find it difficult to make decision as to when do i create a custom library and when do i create a custom helper. I do understand that both allows you to have business logic in it and is reusable across the framework(calling from different controller etc.) But I strongly believe th...

jQuery: create regex pattern from variable

hi all, i'm trying to create a regex pattern out of a variable like: var tag = "style"; var pattern = "/<"+tag+"[^>]*>((\\n|.)*)<\\/"+tag+">/gi"; but it won't work - anyone can tell me what's wrong? thx ...

JAXB together with Builder Pattern. Is that possible?

Hi. I was wondering if anybody knows how I can use JAXB together with the Builder Pattern? The builder pattern wants you to set the constructor as private, and JAXB says "1 counts of IllegalAnnotationExceptions myClass does not have a no-arg default constructor" Is there somehow I can tell JAXB that I don't want no-arg default constru...

Does the Factory Method pattern violate the Open/Closed principle?

Does the Factory Method pattern (not to be confused with the Factory or Abstract Factory patterns) violate the Open/Closed principle? Update: To clarify, I'm referring to the scenario where a concrete class has static factory methods on it. For example (this is from the Wikipedia page on FMP): class Complex { public static Complex...

iPhone visualizing math pattern

Hi, I'm toying with an app idea for the iPhone but I don't know where to start or even what to look for in google :) I'd like to visualize math patterns on the iPhone, similar to this http://itunes.apple.com/us/app/patterns-lite/id304565312?mt=8 ... If someone could point me into the right direction then that would be fantastic. Original...

Java CLI UI-design, frameworks, libraries and principles?

I'm currently working on a small utility program that only requires a command line interface, and I started wondering if Java provided any standard way of creating the CLI, in a similar way that Swing and the likes exist for GUIs. I'm not really interested in command line parameters and parsing of them, but rather the command based inter...

Is a "factory" method the right pattern?

Hey all - So I'm working to improve an existing implementation. I have a number of polymorphic classes that are all composed into a higher level container class. The problem I'm dealing with at the moment is that the higher level container class, well, sucks. It looks something like this, which I really don't have a problem with (as th...

what is the pattern for modifying a collection in C#

What is the pattern (best practice) for such problem -- modifying elements (values) in collection? Conditions: size of the collection is not changed (no element is deleted or added) modification is in-place In C++ it was easy and nice, I just iterated trough a collection and changed the elements. But in C# iterating (using enumerato...

MVVM- View Model-View Model Communications

How do I go about having two view models communicate with one another using MVVM Light. I know how to use the messenger class and register etc.. Here is my Scenario A Settings View ---> a Settings View Model . . . A MainPage View ---...