New to patterns

Hi,
I am completely new to design patterns and J2EE so any help would be useful.
I have a basic web page with an embedded flash movie which communicates with a single servlet.
The servlet is basically a big if...else statement on the request params from the flash. Each if...else calling an appropriate method, doing some work and returning something to the flash movie.
I have been asked by a customer if this the server side servlet would/could be extendable, I want to redesign the whole approach to use a design pattern (is this the right thing to do?), but I don't know really where to start or even if this is the right thing to do. Any help ideas?
I have started reading J2EE Design Patterns by William Crawford, Jonathan Kaplan (is this a good book?) and am thinking of something along the MVC lines with all the work done in a JavaBean, the customer will want to be able to add to the if...else in the controller servlet, preferably by some sort of extension without changing my code, how would something like this work? Is there a better pattern for what I'm trying to do?
Any help will be much appreciated.
Thanks in advance.
Phil Maskell

It is unclear how your customer would want to extend the servlet.
When you say redesign, do you also mean removing the Flash component? Flash conflicts a little with the J2EE model.
Checkout http://jakarta.apache.org/struts/ to learn how to build extensible Java web applications.
Some things to keep in mind:
Using a MVC pattern, the servlet would act as the Controller, which should delegate to helper classes that carry out actions. In Struts, the org.apache.struts.action.ActionServlet reads the request URL and delegates to the appropriate Action class. Highly extendable by adding and/or revising action classes.
The View layer would consist of your Flash application if you keep it in the new design. otherwise the View is implemented with JSP pages.
The Model layer is where your business logic resides. You would use a Business Delegate to interact with the Controller objects. If you keep using Flash, then it seems like your Model or business logic would be mixed in with the View Layer. It really depends on what type of business requirements the application is attempting to realize. Here is the area of conflict with J2EE model.
Christian

Similar Messages

  • How can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it

    how can i view and apply new custom patterns without going to preset manager? i had this facility but have now lost it.  i design patterns but am fairly new to photoshop. i used to be able to click on the drop down menu in patterns in the 'fill' box but cannot now do this.  have i inadvertently clicked on something to turn this facility off?  i now have to go to 'preset manager' and manually move my new design to the first box and click 'done' so that i can use it.

    Which version of photoshop are you using?
    After you define a custom pattern it should be added to the bottom of whatever patterns are already loaded.
    For example, if you define a custom pattern and then go to Edit>Fill>Pattern, the newly defined pattern should have been added to the existing loaded patterns.

  • Cannot use new fill pattern scripts for Photoshop CC 2014.2

    I have installed Photoshop CC 2014.2 (2014.2.0 Release), but am unable to get the new Fill pattern scripts to work or even show up in the UI. Namely, I am referring to the Flame, Picture Frame, and Tree scripted patterns described here: https://www.adobe.com/technology/projects/DecoScriptedPatternsInPhotoshop.html
    This is what my Fill dialog looks like:
    I have confirmed that the corresponding presets exist in the Photoshop CC 2014 > Presets > Deco folder:
    I have tried resetting Photoshop's preferences; and while everything was reset, the missing presets still failed to appear.

    If you are talking about CC 2014 and not CC, have you updated to
    Adobe Photoshop Version: 2014.2.1 20141014.r.257 2014/10/14:23:59:59 CL 987299  x64?
    (First line of File > System Info)
    Gene

  • New(?) pattern looking for a good home

    Hi everyone, this is my second post to sun forums about this, I initially asked people for help with the decorator and strategy pattern on the general Java Programming forum not being aware that there was a specific section for design pattern related questions. Since then I refined my solution somewhat and was wondering if anyone here would take a look. Sorry about the length of my post, I know it's best to keep it brief but in this case it just seemed that a fully functional example was more important than keeping it short.
    So what I'd like to ask is whether any of you have seen this pattern before and if so, then what is it called. I'm also looking for some fresh eyes on this, this example I wrote seems to work but there are a lot of subtleties to the problem so any help figuring out if I went wrong anywhere is greatly appreciated. Please do tell me if you think this is an insane approach to the problem -- in short, might this pattern have a chance at finding a good home or should it be put down?
    The intent of the pattern I am giving below is to modify behavior of an object at runtime through composition. In effect, it is like strategy pattern, except that the effect is achieved by wrapping, and wrapping can be done multiple times so the effect is cumulative. Wrapper class is a subclass of the class whose instance is being wrapped, and the change of behavior is accomplished by overriding methods in the wrapper class. After wrapping, the object "mutates" and starts to behave as if it was an instance of the wrapper class.
    Here's the example:
    public class Test {
         public static void main(String[] args) {
              double[] data = { 1, 1, 1, 1 };
              ModifiableChannel ch1 = new ModifiableChannel();
              ch1.fill(data);
              // ch2 shifts ch1 down by 1
              ModifiableChannel ch2 = new DownShiftedChannel(ch1, 1);
              // ch3A shifts ch2 down by 1
              ModifiableChannel ch3A = new DownShiftedChannel(ch2, 1);
              // ch3B shifts ch2 up by 1, tests independence from ch3A
              ModifiableChannel ch3B = new UpShiftedChannel(ch2, 1);
              // ch4 shifts ch3A up by 1, data now looks same as ch2
              ModifiableChannel ch4 = new UpShiftedChannel(ch3A, 1);
              // print channels:
              System.out.println("ch1:");
              printChannel(ch1);
              System.out.println("ch2:");
              printChannel(ch2);
              System.out.println("ch3A:");
              printChannel(ch3A);
              System.out.println("ch3B:");
              printChannel(ch3B);
              System.out.println("ch4:");
              printChannel(ch4);
         public static void printChannel(Channel channel) {
              for(int i = 0; i < channel.size(); i++) {
                   System.out.println(channel.get(i) + "");
              // Note how channel's getAverage() method "sees"
              // the changes that each wrapper imposes on top
              // of the original object.
              System.out.println("avg=" + channel.getAverage());
    * A Channel is a simple container for data that can
    * find its average. Think audio channel or any other
    * kind of sampled data.
    public interface Channel {
         public void fill(double[] data);
         public double get(int i);
         public double getAverage();
         public int size();
    public class DefaultChannel implements Channel {
         private double[] data;
         public void fill(double[] data) {
              this.data = new double[data.length];
              for(int i = 0; i < data.length; i++)
                   this.data[i] = data;
         public double get(int i) {
              if(i < 0 || i >= data.length)
                   throw new IndexOutOfBoundsException("Incorrect index.");
              return data[i];
         public double getAverage() {
              if(data.length == 0) return 0;
              double average = this.get(0);
              for(int i = 1; i < data.length; i++) {
                   average = average * i / (i + 1) + this.get(i) / (i + 1);
              return average;
         public int size() {
              return data.length;
    public class ModifiableChannel extends DefaultChannel {
         protected ChannelModifier modifier;
         public void fill(double[] data) {
              if (modifier != null) {
                   modifier.fill(data);
              } else {
                   super.fill(data);
         public void _fill(double[] data) {
              super.fill(data);
         public double get(int i) {
              if(modifier != null)
                   return modifier.get(i);
              else
                   return super.get(i);
         public double _get(int i) {
              return super.get(i);
         public double getAverage() {
              if (modifier != null) {
                   return modifier.getAverage();
              } else {
                   return super.getAverage();
         public double _getAverage() {
              return super.getAverage();
    public class ChannelModifier extends ModifiableChannel {
         protected ModifiableChannel delegate;
         protected ModifiableChannel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         private void pre() {
              if(doSwap) { // we only want to swap out modifiers once when the
                   // top call in the chain is made, after that we want to
                   // proceed without it and finally restore doSwap to original
                   // state once ChannelModifier is reached.
                   tmpModifier = root.modifier;
                   root.modifier = this;
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   root.modifier = tmpModifier;
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public ChannelModifier(ModifiableChannel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         public void fill(double[] data) {
              pre();
              if(delegate instanceof ChannelModifier)
                   delegate.fill(data);
              else
                   delegate._fill(data);
              post();
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.get(i);
              else
                   result = delegate._get(i);
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ChannelModifier)
                   result = delegate.getAverage();
              else
                   result = delegate._getAverage();
              post();
              return result;
         public int size() {
              //for simplicity no support for modifying size()
              return delegate.size();
    public class DownShiftedChannel extends ChannelModifier {
         private double shift;
         public DownShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) - shift;
    public class UpShiftedChannel extends ChannelModifier {
         private double shift;
         public UpShiftedChannel(ModifiableChannel channel, final double shift) {
              super(channel);
              this.shift = shift;
         @Override
         public double get(int i) {
              return super.get(i) + shift;
    Output:ch1:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch2:
    0.0
    0.0
    0.0
    0.0
    avg=0.0
    ch3A:
    -1.0
    -1.0
    -1.0
    -1.0
    avg=-1.0
    ch3B:
    1.0
    1.0
    1.0
    1.0
    avg=1.0
    ch4:
    0.0
    0.0
    0.0
    0.0
    avg=0.0

    jduprez wrote:
    Hello,
    unless you sell your design better, I deem it is an inferior derivation of the Adapter pattern.
    In the Adapter pattern, the adaptee doesn't have to be designed to support adaptation, and the instance doesn't even know at runtime whether it is adapted.
    Your design makes the "modifiable" class aware of the modification, and it needs to be explicitly designed to be modifiable (in particular this constrains the implementation hierarchy). Overall DesignPattern are meant to provide flexibility, your version offers less flexibility than Adapter, as it poses more constraint on the modifiable class.
    Another sign of this inflexibility is your instanceof checks.
    On an unrelated note, I intensely dislike your naming choice of fill() vs _fill()+, I prefer more explicit names (I cannot provide you one as I didn't understand the purpose of this dual method, which a good name would have avoided, by the way).
    That being said, I haven't followed your original problem, so I am not aware of the constraints that led you to this design.
    Best regards,
    J.
    Edited by: jduprez on Mar 22, 2010 10:56 PMThank you for your input, I will try to explain my design better. First of all, as I understand it the Adapter pattern is meant to translate one interface into another. This is not at all what I am trying to do here, I am trying to keep the same interface but modify behavior of objects through composition. I started thinking about how to do this when I was trying to apply the Decorator pattern to filter some data. The way I would do that in my example here is to write an AbstractChannelDecorator that delegates all methods to the Channel it wraps:
    public abstract class AbstractChannelDecorator implements Channel {
            protected Channel delegate;
    ...// code ommitted
         public double getAverage() {
              return delegate.getAverage();
    ...// code ommitted
    }and then to filter the data I would extend it with concrete classes and override the appropriate methods like so:
    public class DownShiftedChannel extends AbstractChannelDecorator {
         ...// code ommitted
         public double get(int i) {
              return super.get(i) - shift;
           ...// code ommitted
    }(I am just shifting the data here to simplify the examples but a more realistic example would be something like a moving average filter to smooth the data).
    Unfortunately this doesn't get me what I want, because getAverage() method doesn't use the filtered data unless I override it in the concrete decorator, but that means I will have to re-implement the whole algorithm. So that's pretty much my motivation for this, how do I use what on the surface looks like a Decorator pattern, but in reality works more like inheritance?
    Now as to the other points of critique you mentioned:
    I understand your dislike for such method names, I'm sorry about that, I had to come up with some way for the ChannelModifier to call ModifiableChannel's super's method equivalents. I needed some way to have the innermost wrapped object to initiate a call to the topmost ChannelModifier, but only do it once -- that was one way to do it. I suppose I could have done it with a flag and another if/else statement in each of the methods, or if you prefer, the naming convention could have been fill() and super_fill(), get() and super_get(), I didn't really think that it was that important. Anyway, those methods are not meant to be used by any other class except ChannelModifier so I probably should have made them protected.
    The instanceof checks are necessary because at some point ChannelModifier instance runs into a delegate that isn't a ChannelModifier and I have to somehow detect that, because otherwise instead of calling get() I'd call get() which in ModifiableChannel would take me back up to the topmost wrapper and start the whole call chain again, so we'd be in infinite recursion. But calling get() allows me to prevent that and go straight to the original method of the innermost wrapped object.
    I completely agree with you that the example I presented has limited flexibility in supporting multiple implementations. If I had two different Channel implementations I would need two ModifiableChannel classes, two ChannelModifiers, and two sets of concrete implementations -- obviously that's not good. Not to worry though, I found a way around that. Here's what I came up with, it's a modification of my original example with DefaultChannel replaced by ChannelImplementation1,2:
    public class ChannelImplementation1 implements Channel { ... }
    public class ChannelImplementation2 implements Channel { ... }
    // this interface allows implementations to be interchangeable in ChannelModifier
    public interface ModifiableChannel {
         public double super_get(int i);
         public double super_getAverage();
         public void setModifier(ChannelModifier modifier);
         public ChannelModifier getModifier();
    public class ModifiableChannelImplementation1
              extends ChannelImplementation1
              implements ModifiableChannel {
         ... // see DefaultChannel in my original example
    public class ModifiableChannelImplementation2
              extends ChannelImplementation1
              implements ModifiableChannel { ...}
    // ChannelModifier is a Channel, but more importantly, it takes a Channel,
    // not any specific implementation of it, so in effect the user has complete
    // flexibility as to what implementation to use.
    public class ChannelModifier implements Channel {
         protected Channel delegate;
         protected Channel root;
         protected ChannelModifier tmpModifier;
         protected boolean doSwap = true;
         public ChannelModifier(Channel delegate) {
              if(delegate instanceof ChannelModifier)
                   this.root = ((ChannelModifier)delegate).root;
              else
                   this.root = delegate;
              this.delegate = delegate;
         private void pre() {
              if(doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        tmpModifier = root.getModifier();
                        root.setModifier(this);
                   if(delegate instanceof ChannelModifier)
                        ((ChannelModifier)delegate).doSwap = false;
         private void post() {
              if (doSwap) {
                   if(root instanceof ModifiableChannel) {
                        ModifiableChannel root = (ModifiableChannel)this.root;
                        root.setModifier(tmpModifier);
              } else {
                   if(delegate instanceof ChannelModifier)
                             ((ChannelModifier)delegate).doSwap = true;
         public void fill(double[] data) {
              delegate.fill(data);
         public double get(int i) {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
    // I've changed the naming convention from _get() to super_get(), I think that may help show the intent of the call
                   result = ((ModifiableChannel)delegate).super_get(i);
              else
                   result = delegate.get(i);               
              post();
              return result;
         public double getAverage() {
              pre();
              double result;
              if(delegate instanceof ModifiableChannel)
                   result = ((ModifiableChannel)delegate).super_getAverage();
              else
                   result = delegate.getAverage();
              post();
              return result;
         public int size() {
              return delegate.size();
    public class UpShiftedChannel extends ChannelModifier { ...}
    public class DownShiftedChannel extends ChannelModifier { ... }

  • New J2EE Pattern

    Introducing Shine Pattern
    A brief history of Shine
    When we started to do a project we encountered an important problem. Developing a project with amateur developers is very dangerous. Because new developers don't care about some important things, and if the project manager, technical architect or head developer don’t care about those points, the project will fail.
    In 2008 the university manager to assess the student progress situation wants them to develop an enterprise project. Because most of students haven’t enough experiences in implementing software project, we did primary analysis and during implementing project we try to don't help them. Unfortunately output of the project was re-programming the project. This problem kept our mind busy for a long time until we try to create a standard and comprehensive pattern for completing a project. After doing this job we do many enterprise projects with this pattern and the result was 50% saving time of developing and extending the project. So we decided to offer this pattern for developers in SourgeForge website.
    The problems which make the projects to are:
    •     Not to follow a standard architecture
    •     Not to care about naming rules in forms, classes, pages...
    •     Creating useless classes in frameworks such as Struts, Spring and also JSF
    •     Using complexity classes
    •     Implementing logic layer in the UI layer
    •     Plethora of dependency on UI
    •     Gaffes of web designer
    •     Creating meaningless pages
    •     Not to care about security points
    •     Creating complexity in distributed application on the network by using RMI, Corba, JMS
    •     Plethora engaging with frameworks XML adjustments
    Shine's parts
    Shine pattern has been developed for variety of application. This pattern has these parts:
    •     Maplet: a framework for doing web projects which are coincidence with MVC architecture. This framework helps developers to follow a standard pattern for developing a web application. Maplet helps developers to save time of developing and extending.
    •     JShooter: a framework that makes reflects oriented programming an easy job for developers. Meanwhile it helps distributing application on the network.
    •     JConnection: This package helps developers to work with JDBC and Hibernate easier than before.
    •     Util: This package helps developers in these subjects:
    1-     File System
    2-     Runtime
    3-     Compiler
    4-     System Information
    5-     Web Socket
    6-     MD5
    7-     Thread
    8-     Validation
    9-     XML Parsing
    10-     Web uploading
    Suggestion
    Our suggestion is that before producing any new part for your application search our Util package. There are lots of classes in this package that help you in different fields. This package will be developed by java open source developers in every version of Shine.

    thanks for share.i like it . http://www.usedconecrusher.com
    Edited by: 783365 on 2010-7-20 下午6:23

  • ANN: New Design Pattern (DAO)

    Hello,
    Thanks for your overwhelming response to our previous sample applications demonstrating various [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/index.html]design patterns.
    Continuing with the series, this month we have showcased the [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Data Access Object (DAO) Design Pattern which is considered as a best practice for applications accessesing the database or the underlying persistence layer from the business tier.
    The DAO implements the access mechanism required to work with the data source. The data source could be a persistent store like an RDBMS, an external service like a B2B exchange, a repository like an LDAP database, or an XML Repository. Using the scenario of web based News Application, this sample application demonstrates the effective use of this pattern.
    [url http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/dataaccesstier/index.html]Download the sample application to learn more about this pattern.
    More Sample Applications are available at [url http://www.oracle.com/technology/sample_code/index.html]
    http://www.oracle.com/technology/sample_code/index.html
    Thanks,
    Rajat
    OTN Team

    Hi
    This is because you are not using the latest jdbc driver version. Either use the latest ojdbc14.jar downloadable from the location given in the readme(Oracle Database 10g (10.1.0.2.0) drivers),
    Or simply comment this part in the code.
    Also you may just replace the close method call with ods=null;
    Hope this helps
    Shrinivas

  • New password pattern verification

    Need to develop a class that will verify new passwords against specific patterns. Such as requiring mixed case, at least one numeric character, not having the same character twice, etc. Think Oracle...
    Anyone done this sort of thing? Not sure where to start...

    Not sure where to start...Too much cold beer?
    public void check(String pass) {
            int idx = 0;
            boolean numeric = false;
            boolean upperCase = false;
            boolean lowerCase = false;
            char last = 0;
            while (idx < pass.length()) {
                char ch = pass.charAt(idx++);
                upperCase |= Character.isUpperCase(ch);
                lowerCase |= Character.isLowerCase(ch);
                numeric |= Character.isDigit(ch);
                if (last != 0) {
                    if (last == ch)
                        System.out.println("repeated " + last);
                last = ch;
            if (! upperCase)
                System.out.println("need at least one upper case character");
            if (! lowerCase)
                System.out.println("need at least one lower case character");
            if (! numeric)
                System.out.println("need at least one numeric character");
            if (pass.length() < 5)
                System.out.println("need at least 5 characters");
    }

  • New 6534 pattern generator causes computer not to boot

    We have a brand new 6534 pxi pattern generator. When we plug the card in the computer does not boot at all. As in nothing appears on the screen and only the fans in the chassis turn on. We have a PXI 1010 chassis with 2 other cards inside. I also tried it on another computer with an external pxi bus and the same thing happpened. Is the card blown or are we missing something?

    Sounds blown!
    Call NI and talk to tech support to get an RMA.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Using the new CS4 Pattern Swatches

    Does Adobe allow designers to use ai Pattern Swatches for their designs they plan to sell? Like a pattern fill background or a shape(s) that's filled w/ one of the pattern swatches? Or do you have to create your own swatches?
    When I asked Adobe, they sent me this:http://www.adobe.com/products/eulas/pdfs/Gen_WWCombined-combined-
    2008062
    3_1026.pdf
    A contract that I can't really find my answer in. 

    Thanks M.Num
    I did actually get ahold of cust. support and they said i could use them for profit on my own artwork as long as my version isn't for educational as I suppose educational is cheaper. The rep didn't mention that i would have to modify though.
    Dina

  • Purpose of new - dup pattern

    Hi
    I am interesting in java bytecode and also have read that 2nd version of its specification but still can not get the point, why when creating new class instance there is new instruction followed by dup.
    why do I need to have 2 same instances on top of the stack? does this have something to do with <init> internal mehod?
    thanks
    Marko_112
    Edited by: Marko_112 on Sep 14, 2008 11:43 PM

    Looking at the bytecode, you generally see a sequence like this: "new", "dup" and "invokespecial". So before invokespecial, there are 2 references to the new object on the stack. Invokespecial calls the <init> method (to initialize the object) and consumes one of those references. So after the object is initialized, you now have one reference to the initialized object left on the stack.
    Luc

  • NEW DESIGN PATTERN:TAGLIBS only.No servlets

    We followed the following architecture:
    request response
    | *
    | *
    servlet JSP
    ejb
    1.Request is given to servlet.
    2.servlet fetches data from the Ejb layer
    3.servlet forwards data to jsp
    4.jsp genreates view to the user
    Now we find the following Main TROUBLE with this architecture
    The jsp can present only those data that has been provided by the Servlet,i.e. jsp can not demand various differnt types of data from the business layer as it needs.
    Reason is Servlet forwards the JSP.
    solution we identified is use taglibs to interact with the ejb layer.
    jsp will use this tag lib to interact with the business tier.
    request/RESPONSE
    |
    |
    jsp ------->TAGLIBS
    |
    ----------------|------
    EJB LAYER
    Is there any one else who uses such architecture ?
    What are the other advantages and disadvantages of this architecture ?

    This is a rather standard architecture. The servlet is responsible for collecting all the data that needs to be presented from the business layer. The only responsibility of the JSP is to render this data on screen (generating HTML). The JSP itself must not be bothered with business logic.
    Take a look at Struts (http://jakarta.apache.org/struts/). This framework implements the described architecture (aka JSP Model 2).
    --Arnout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • New language feature: lazy local pattern matching

    <p>In the upcoming release of the Open Quark Framework, CAL gets a new language       feature: lazy local pattern matching.</p> <p>The new local pattern match syntax allows one to bind one or more variables to       the fields of a data constructor or a record in a single declaration inside a       let block.</p> <p>      For example:</p> <p>      // data constructor patterns:<br />      public foo1 = let Prelude.Cons a b = ["foo"]; in a;<br />      public foo2 = let Prelude.Cons {head=a, tail=b} = ["foo"]; in a;<br />      <br />      // list cons patterns:<br />      public foo3 = let a:b = [3]; in a;<br />      <br />      // tuple patterns:<br />      public foo4 = let (a, b, c) = (b, c, 1 :: Prelude.Int); in abc;<br />      <br />      // record patterns:<br />      public foo5 = let = {a = "foo"}; in a; // non-polymorphic record pattern<br />      public foo6 = let {_ | a} = {a = "foo", b = "bar"}; in a; // polymorhpic record       pattern<br />      <br />      Whereas a case expression such as (case expr of a:b -> ...) forces the       evaluation of expr to weak-head normal form (WHNF), a similar pattern match       declaration (let a:b = expr; in ...) does not force the evaluation of expr       until one of a or b is evaluated. In this sense, we can regard this as a form       of lazy pattern matching.<br /> </p> <p>Thus,</p> <p>      let a:b = []; in 3.0;</p> <p>is okay and would not cause a pattern match failure, but the case expression</p> <p>      case [] of a:b -> 3.0;</p> <p>would cause a pattern match failure.</p> <p>This laziness is useful in situations where unpacking via a case expression may       result in an infinite loop. For example, the original definition of List.unzip3       looks like this:</p> <p>// Original implementation of List.unzip3<br />      unzip3 :: [(a, b, c)] -> ([a], <b>, [c]);<br />      public unzip3 !list =<br />          case list of<br />          [] -> ([], [], []);<br />          x : xs -><br />              let<br />                  ys =       unzip3 xs;<br />              in<br />                  case x       of<br />                  (x1,       x2, x3) -><br />                      //do       not do a "case" on the ys, since this makes unzip3 strictly evaluate the list!<br />                      (x1       : field1 ys, x2 : field2 ys, x3 : field3 ys);<br />              ;<br />          ;<br /> </p> <p>The use of the accessor functions field1, field2 and field3 here is necessary,       as the alternate implementation shown below would result in "unzip3 xs" to be       evaluated to WHNF during the evaluation of "unzip3 (x:xs)". Thus if the input       list is infinite, the function would never terminate. </p> <p>// Alternate (defective) implementation of List.unzip3<br />      unzip3 :: [(a, b, c)] -> ([a], <b>, [c]);<br />      public unzip3 !list =<br />          case list of<br />          [] -> ([], [], []);<br />          x : xs -><br />              let<br />                  ys =       unzip3 xs;<br />              in<br />                  case x       of<br />                  (x1,       x2, x3) -><br />                      case       ys of // the use of "case" here is inappropriate, as it causes "unzip3 xs" to       be evaluated to WHNF<br />                      (y1,       y2, y3) -> (x1 : y1, x2 : y2, x3 : y3);<br />                  ;<br />              ;<br />          ;<br /> </p> <p>With the new syntax, the original implementation can be expressed more nicely       without changing its semantics:</p> <p>// New implementation of List.unzip3, revised to use the local pattern match       syntax<br />      unzip3 :: [(a, b, c)] -> ([a], <b>, [c]);<br />      public unzip3 !list =<br />          case list of<br />          [] -> ([], [], []);<br />          x : xs -><br />              let<br />                  (y1,       y2, y3) = unzip3 xs; // using a tuple pattern to perform a lazy local pattern       match<br />              in<br />                  case x       of<br />                  (x1,       x2, x3) -><br />                      (x1       : y1, x2 : y2, x3 : y3);<br />              ;<br />          ;<br /> </p> <p style="text-decoration: underline">It is important to note that in places where       a case expression can be used (without having an unwanted change in the       laziness of the expression being unpacked), it should be used instead of this       local pattern match syntax.</p> <p>Things to note about the new syntax:</p> <p>      - local type declarations on the pattern-bound variables are allowed, and these       type declarations can have associated CALDoc comments. On the other hand, the       actual local pattern match declaration itself cannot have a type declaration       nor a CALDoc comment.</p> <p>      - this syntax cannot be used for top-level definitions, only local definitions       in let blocks</p> <p>      - one cannot use patterns with multiple data constructors, e.g.</p> <p>      let (Left|Right) = ...;</p> <p>      is not allowed</p> <p>      - one cannot specify a variable for the base record pattern, e.g.</p> <p>      let {r | a, b} = ...;</p> <p>      is not allowed, but this is okay:</p> <p>      let {_ | a, b} = ...;</p> <p>      - patterns without no variables are disallowed, e.g.</p> <p>      let _ = ...;<br />      let [] = ...;<br />      let () = ...;<br />      let : = ...;<br />      let {_|#1} = ...;      <br /> </p>

    If you use just / it misinterprets it and it ruins
    your " " tags for a string. I don't think so. '/' is not a special character for Java regex, nor for Java String.
    The reason i used
    literal is to try to force it to directly match,
    originally i thought that was the reason it wasn't
    working.That will be no problem because it enforces '.' to be treated as a dot, not as a regex 'any character'.
    Message was edited by:
    hiwa

  • Does the route list gets reset when adding route pattern in version 9 of CUCM?

    Hi All,
    I created a new route pattern in call manager version 9 and then associated it to an existing route list. But when I was trying to save the route pattern. I was prompted with the message saying " Any updates to this Route Pattern automatically resets the associated gateway or Route List"
    I was not able to see this message on CUCM version 8.6 however on CUCM version 9 it is there.
    Does that mean that the route list/gateway will be reset and the existing calls will be dropped?
    Or is it a bug?
    A response will be greatly appreciated.
    Thanks

    Hi Farhad,
    It does pop up when we modify the Route Pattern in CUCM 8.6 too.
    If you asociate the GW/Trunk directly to Route Pattern, yes, it will reset them and calls will be interrupted. To avoid that, we need to associate the Route List to Route Patterns.
    //Suresh
    Please rate all the useful posts.

  • Pattern Swatch From Pattern Maker Filter

    Is there a way to copy a new custom Pattern Swatch that you create using the Pattern Maker filter? I have often created a pattern that worked perfect but could only apply it to a layer. I want to be able to save just the custom swatch that patterns correctly so that I can use it as a repeating background image on a website.
    I know I should know this, but it's something that I've never been able to figure out, or find in the Help Menu.
    Linda

    > Well, you could always open a new file the same size as the pattern you created originally and load it from the Layer Styles > Pattern dialog.
    For some reason it tiles right when I apply the pattern to a large background. But when I attempt to create a simple square tile, even the same size as I started with, and attempt to use it as a repeating background on a web page, you can see the tiling.
    > Or how about after you make a new pattern in Pattern Maker and OK it, you have it load into an open Photoshop window, yes? You know the size of the tile the pattern maker made. How about making a selection the same size and use the arrow keys to move it into place and then copy/paste a new doc.
    Sounds good on paper Welles. But I can't get it to work right. I still see the tiling when I save the file out this way and use it as a background.
    I don't need this for anything urgent. And I know I can make something work for when I need it. The pattern I'm working with has a lot of texture so when it repeats outside of applying it in Photoshop, it just doesn't match up right. I had hoped there would be an easy way to capture the custom Pattern Maker Tile as a single image that could be used to repeat itself without seeing the tiling.
    Maybe this would be a good feature request. Thanks for both of your input.

  • Create new swatch using Guassian Blur

    Hello
    I am trying to create a new swatch pattern that repeats consistently (see diagram below)
    I create a assemble four (6pt by 6pt squares) together and then colour them in approproiately. I guassian blur at 1.5pt each square. I add a base colour background in a square of 12pt by 12pt and then put a 12pt by 12pt invisible bounding box behind all this. I then drag to the swatch panel to create my new swatch.
    Problem is that when I try to colour in a larger square with this patter I get harsh lines ... see the example. Would love thoughts on how to get around this
    Thanks
    John

    Nah, don't create the seams at the edges of the squares but more in a flower shape with one of the squares in the middle and the others surrounding it as ahlf squares.
    Mylenium

Maybe you are looking for

  • Convert application error to system error

    Iam facing an issue in BPM, Iam triyng to access to a webservice using synchronous send step, and I ahve an exception branch to catch the syetm error and fault message. Eventhough I specified fault messages, application error was not properly recogni

  • Archiving object

    Hi all, How do i know, how many records archived in the archive object. Where can i check the archiving file path? i can able to see the individual table records

  • RELATED in Calculated Column or Calcualted Field?

    Dear Team, 1] If I use the REALTED function to lookup a price in a Calculated Column like: RetailPrice =RELATED(dProducts[RetailPrice]) and there are only 30 different prices (unique values) in a total of 39,000 rows, here are my questions: Because t

  • To open Report in Maximize form when calling it from FORM

    Dear All, I am facing a problem related to Report.When a report is called from the FORM, this report is not openned in MAXIMIZE form. How will it be openned in Maximize form. If there is any solution for it. Please write.... Regards, Akhilesh P. Verm

  • How can I make Adobe Reader X open e-mail links in Thunderbird?

    When I click an e-mail address in Adobe Reader X, an Outlook e-mail window opens, even though Thunderbird is my standard e-mail client and assigned to the mailto: protocol.