Search Results

Search found 5705 results on 229 pages for 'observer pattern'.

Page 2/229 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Observer pattern used with decorator pattern

    - by icelated
    I want to make a program that does an order entry system for beverages. ( i will probably do description, cost) I want to use the Decorator pattern and the observer pattern. I made a UML drawing and saved it as a pic for easy viewing. This site wont let me upload as a word doc so i have to upload a pic - i hope its easily viewable.... I need to know if i am doing the UML / design patterns correctly before moving on to the coding part. Beverage is my abstract component class. Espresso, houseblend, darkroast are my concrete subject classes.. I also have a condiment decorator class milk,mocha,soy,whip. would be my observer? because they would be interested in data changes to cost? Now, would the espresso,houseblend etc, be my SUBJECT and the condiments be my observer? My theory is that Cost is a changes and that the condiments need to know the changes? So, subject = esspresso,houseblend,darkroast,etc.. // they hold cost() Observer = milk,mocha,soy,whip? // they hold cost() would be the concrete components and the milk,mocha,soy,whip? would be the decorator! So, following good software engineering practices "design to an interface and not implementation" or "identify things that change from those that dont" would i need a costbehavior interface? If you look at the UML you will see where i am going with this and see if i am implementing observer + Decorator pattern correctly? I think the decorator is correct. since, the pic is not very viewable i will detail the classes here: Beverage class(register observer, remove observer, notify observer, description) these classes are the concrete beverage classes espresso, houseblend,darkroast, decaf(cost,getdescription,setcost,costchanged) interface observer class(update) // cost? interface costbehavior class(cost) // since this changes? condiment decorator class( getdescription) concrete classes that are linked to the 2 interface s and decorator are: milk,mocha,soy,whip(cost,getdescription,update) these are my decorator/ wrapper classes. Thank you.. Is there a way to make this picture bigger?

    Read the article

  • Ocaml Pattern Matching

    - by Atticus
    Hey guys, I'm pretty new to OCaml and pattern matching, so I was having a hard time trying to figure this out. Say that I have a list of tuples. What I want to do is match a parameter with one of the tuples based on the first element in the tuple, and upon doing so, I want to return the second element of the tuple. So for example, I want to do something like this: let list = [ "a", 1; "b", 2"; "c", 3; "d", 4 ] ;; let map_left_to_right e rules = match e with | first -> second | first -> second | first -> second If I use map_left_to_right "b" list, I want to get 2 in return. I therefore want to list out all first elements in the list of rules and match the parameter with one of these elements, but I am not sure how to do so. I was thinking that I need to use either List.iter or List.for_all to do something like this. Any help would be appreciated. Thanks!

    Read the article

  • Identity Map Pattern and the Entity Framework

    - by nikolaosk
    This is going to be the seventh post of a series of posts regarding ASP.Net and the Entity Framework and how we can use Entity Framework to access our datastore. You can find the first one here , the second one here and the third one here , the fourth one here , the fifth one here and the sixth one here . I have a post regarding ASP.Net and EntityDataSource. You can read it here .I have 3 more posts on Profiling Entity Framework applications. You can have a look at them here , here and here . In...(read more)

    Read the article

  • Are Promises/A a good event design pattern to implement even in synchronous languages like PHP?

    - by Xeoncross
    I have always kept an eye out for event systems when writing code in scripting languages. Web applications have a history of allowing the user to add plugins and modules whenever needed. In most PHP systems you have a global/singleton event object which all interested parties tie into and wait to be alerted to changes. Event::on('event_name', $callback); Recently more patterns like the observer have been used for things like jQuery. $(el).on('event', callback); Even PHP now has built in classes for it. class Blog extends SplSubject { public function save() { $this->notify(); } } Anyway, the Promises/A proposal has caught my eye. It is designed for asynchronous systems, but I'm wondering if it is also a good design to implement now that even synchronous languages like PHP are changing. Combining Dependency Injection with Promises/A seems it might be the best combination for handling events currently.

    Read the article

  • 'click' observer in Prototype

    - by Tom
    I have a page which contains several divs (each with a unique ID and the same class, 'parent'). Underneath each "parent" div, is a div with class "child" and unique ID name -child. This DIV is upon page load empty. Whenever you click on a parent DIV, the following code is executed. $$('div.parent').each(function(s){ $(s).observe('click', function(event){ event.stop(); var filer = $(s).readAttribute('filer'); var currentElement = $(s).id; var childElement = currentElement + '-children'; new Ajax.Updater ({success: childElement}, root + '/filers/interfacechildren', { parameters: {parentId: currentElement, filer: filer} }); }); }); Of course, it's possible that a child node is again a parent ont its own. The response looks like this (Smarty with Zend Framework): {foreach from=$ifaces item=interface} <div id="{$interface->name}" filer="{$interface->system_id}" class="parent">{$interface->name}</div> <div id="{$interface->name}-children" class="child"></div> {/foreach} Whenever I click on a "parent" div that is loaded inside a child, nothing happens :( Any suggestions / fixes how to fix this?

    Read the article

  • XMLHttpRequest fails in observer method

    - by Michael
    I'm developing a Firefox extension and this code belongs to javascript module. var ajax = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); ajax.open('GET', "http://www.google.com", true); ajax.onload = function () { Reader.log("Got News"); }; ajax.onerror = function () { Reader.log("Got Error"); }; ajax.send(null); This small code always fails (onerror) if calling from observe method invoked by preference "@mozilla.org/preferences-service;1" Anyone knows how to make this work in observe method?

    Read the article

  • Cocoa document-based app: Notification not always received by observer

    - by roysolay
    Hi, I hope somebody can help with my notification problem. I have a notification which looks to be set up correctly but it isn’t delivered as expected. I am developing a document based app. The delegate/ document class posts the notification when it reads from a saved file: [[NSNotificationCenter defaultCenter] postNotificationName:notifyBsplinePolyOpened object:self]; Logging tells me that this line is reached whenever I open a saved document. In the DrawView class, I have observers for the windowOpen notification and the bsplinePoly file open notification: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainWindowOpen:) name:NSWindowDidBecomeMainNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(savedBspline:) name:notifyBsplinePolyOpened object:nil]; - (void) mainWindowOpen:(NSNotification*) note { NSLog(@"Window opened"); _mainWindow = [note object]; } - (void) savedBspline:(NSNotification*) note { NSLog(@"savedBspline called"); NSLog(@"note is %@", [note name]); } The behavior is odd. When I save and close the main window and reopen it, I get the “Window opened” message but not the “savedBspline called” message. If I leave a main window open and open a previously saved session, I get the “Window opened” message and the “savedBspline called” message. I have searched online discussion and Apple DevCenter documentation but I have not seen this problem.

    Read the article

  • Is MVC a Design Pattern or Architectural pattern

    - by JCasso
    According to Sun and Msdn it is a design pattern. According to Wikipedia it is an architectural pattern In comparison to design patterns, architectural patterns are larger in scale. (Wikipedia - Architectural pattern) Or it is an architectural pattern that also has a design pattern ? Which one is true ?

    Read the article

  • Query Object Pattern (Design Pattern)

    - by The Elite Gentleman
    Hi Guys, I need to implement a Query Object Pattern in Java for my customizable search interface (of a webapp I'm writing). Does anybody know where I can get an example/tutorial of Query Object Pattern (Martin Fowler's QoP)? Thanks in Advance ADDITION How to add a Query Pattern to an existing DAO pattern?

    Read the article

  • Java RegEx Pattern not matching (works in .NET)

    - by CDSO1
    Below is an example that is producing an exception in Java (and not matching the input). Perhaps I misunderstood the JavaDoc, but it looks like it should work. Using the same pattern and input in C# will produce a match. import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) { String pattern = "aspx\\?uid=([^']*)"; Pattern p = Pattern.compile(pattern); Matcher m = p.matcher("id='page.aspx?uid=123'"); System.out.println(m.groupCount() > 0 ? m.group(1) : "No Matches"); } }

    Read the article

  • Using the Specification Pattern

    - by Kane
    Like any design pattern the Specification Pattern is a great concept but susceptible to overuse by an eager architect/developer. I am about to commence development on a new application (.NET & C#) and really like the concept of the Specification Pattern and am keen to make full use of it. However before I go in all guns blazing I would be really interested in knowing if anyone could share the pain points that experienced when use the Specification Pattern in developing an application. Ideally I'm looking to see if others have had issues in Writing unit tests against the specification pattern Deciding which layer the specifications should live in (Repository, Service, Domain, etc) Using it everywhere when a simple if statement would have done the job etc? Thanks in advance

    Read the article

  • Is component-based design an architectural pattern or design pattern?

    - by xEnOn
    When using the component-based paradigm in game development with engines like Unity, is component-based design an architectural pattern, or a design pattern? Can I even say that component-based design is my "main" architectural pattern for my game? I see architectural patterns as being more high-level than design pattern. The component-based design in game development's context (like with Unity engine) seems to fit as an architectural pattern to me. However, on some sites, I read that component-based design is a behavioural pattern, much like other behavioural design patterns, and not so much like an architectural pattern like MVC.

    Read the article

  • F# Active Pattern List.filter or equivalent

    - by akaphenom
    I have a records of types type tradeLeg = { id : int ; tradeId : int ; legActivity : LegActivityType ; actedOn : DateTime ; estimates : legComponents ; entryType : ShareOrDollarBased ; confirmedPrice: DollarsPerShare option; actuals : legComponents option ; type trade = { id : int ; securityId : int ; ricCode : string ; tradeActivity : TradeType ; enteredOn : DateTime ; closedOn : DateTime ; tradeLegs : tradeLeg list ; } Obviously the tradeLegs are a type off of a trade. A leg may be settled or unsettled (or unsettled but price confirmed) - thus I have defined the active pattern: let (|LegIsSettled|LegIsConfirmed|LegIsUnsettled|) (l: tradeLeg) = if Helper.exists l.actuals then LegIsSettled elif Helper.exists l.confirmedPrice then LegIsConfirmed else LegIsUnsettled and then to determine if a trade is settled (based on all legs matching LegIsSettled pattern: let (|TradeIsSettled|TradeIsUnsettled|) (t: trade) = if List.exists ( fun l -> match l with | LegIsSettled -> false | _ -> true) t.tradeLegs then TradeIsSettled else TradeIsUnsettled I can see some advantages of this use of active patterns, however i would think there is a more efficient way to see if any item of a list either matches (or doesn't) an actie pattern without having to write a lambda expression specifically for it, and using List.exist. Question is two fold: is there a more concise way to express this? is there a way to abstract the functionality / expression (fun l - match l with | LegIsSettled - false | _ - true) Such that let itemMatchesPattern pattern item = match item with | pattern -> true | _ -> false such I could write (as I am reusing this design-pattern): let curriedItemMatchesPattern = itemMatchesPattern LegIsSettled if List.exists curriedItemMatchesPattern t.tradeLegs then TradeIsSettled else TradeIsUnsettled Thoughts?

    Read the article

  • Print a string that contains a certain pattern in Java

    - by jjpotter
    I am trying to find a regular expression within a line of a .csv file, so I can eventually save all the matches to another file, and lose all the other junk. So a line in my file might look like: MachineName,User,IP,VariableData,Location The VariableData is what I want to match, and if there's a match, print the line. I am using a pattern for this because I only want 3 out of 10 of variations of VariableData, and out of those 3, they are numbered differently(example, "pc104, pccrt102, pccart65"). I am trying to do this using the Scanner Class and keeping it simple as possible so I can understand it. Here is where I was heading with this...(the pattern isn't complete, just have it like this for testing). import java.io.File; import java.util.Scanner; import java.util.regex.Pattern; public class pcv { public static void main(String[] args) { File myFile = new File("c:\\temp\\report.csv"); Pattern myPat = Pattern.compile("pc"); try{ Scanner myScan = new Scanner(myFile); while(myScan.hasNext()){ if(myScan.hasNext(myPat)){ System.out.println("Test"); } } }catch(Exception e){ } } } This code loops, im guessing the .hasNext() methods are resetting themselves. I've played around with the Matcher class a little bit, but only found a way to match the expression but not get the whole line. My other throught was maybe somehow count the line that contains the pattern, then go back and print the line that corresponds to the counts.

    Read the article

  • How you would you describe the Observer pattern in beginner language?

    - by Sheldon
    Currently, my level of understanding is below all the coding examples on the web about the Observer Pattern. I understand it simply as being almost a subscription that updates all other events when a change is made that the delegate registers. However, I'm very unstable in my true comprehension of the benefits and uses. I've done some googling, but most are above my level of understanding. I'm trying to implement this pattern with my current homework assignment, and to truly make sense on my project need a better understanding of the pattern itself and perhaps an example to see what its use. I don't want to force this pattern into something just to submit, I need to understand the purpose and develop my methods accordingly so that it actually serves a good purpose. My text doesn't really go into it, just mentions it in one sentence. MSDN was hard for me to understand, as I'm a beginner on this, and it seems more of an advanced topic. How would you describe this Observer pattern and its uses in C# to a beginner? For an example, please keep code very simple so I can understand the purpose more than complex code snippets. I'm trying to use it effectively with some simple textbox string manipulations and using delegates for my assignment, so a pointer would help!

    Read the article

  • OLL Live webcast - Using SQL for Pattern Matching in Oracle Database

    - by KLaker
    If you are interested in learning about our exciting new 12c SQL pattern matching feature then mark your diaries. On Wednesday, October 30th at 8:00 am (US/Pacific time zone) Supriya Ananth, who is one of our top curriculum developers at Oracle, will be hosting an OLL webcast on our new SQL pattern matching feature. The ability to recognize patterns in a sequence of rows has been a capability that was widely desired, but not possible with SQL until now. Row pattern matching in native SQL improves application and development productivity and query efficiency for row-sequence analysis. With Oracle Database 12c you can use the new MATCH_RECOGNIZE clause to perform pattern matching in SQL to do the following: Logically partition and order the data using the PARTITION BY and ORDER BY clauses Use regular expressions syntax to define patterns of rows to seek using the PATTERN clause. These patterns a powerful and expressive feature, applied to the pattern variables you define. Specify the logical conditions required to map a row to a row pattern variable in the DEFINE clause. Define measures, which are expressions usable in the MEASURES clause of the SQL query. For more information and to register for this exciting webcast please visit the OLL Live website, see here: https://apex.oracle.com/pls/apex/f?p=44785:145:116820049307135::::P145_EVENT_ID,P145_PREV_PAGE:461,143.  Please note - if the above link does not work then go to OLL (https://apex.oracle.com/pls/apex/f?p=44785:1:) and click the OLL Live icon (upper right, beneath the Login link or logout link if you are already logged in). The pattern matching webcast is listed on the calendar of events on 30 October.

    Read the article

  • pattern matching in .Net consistent with IsolatedStorageFile.GetFileNames() pattern matching

    - by Mick N
    Is the pattern matching logic used by this API exposed for reuse somewhere in the .Net Framework? Something of the form FilePatternMatch( string searchPattern, stringfileNameToTest ) is what I'm looking for. I'm implementing a temporary workaround for WP7 not filtering the results for this overload and I'd like the solution to both provide a consistent experience and avoid reinventing this functionality if it is exposed. If the behaviour is not exposed for reuse, a regular expression solution (like glob pattern matching in .NET) will suffice and would save me spending the time to test the fine details of what the behaviour should be. Perhaps one of the answers posted in the thread linked above is correct. Since I haven't confirmed the exact behaviour as yet, I wasn't able to determine this at a glance. Feel free to point me to one of those answers if you know it is behaviouraly an exact match to the API referenced in the question title. I could assume the pattern matching is consistent with how DOS handled * and ? in 8.3 file names (I'm familiar with behavioural nuances of that implementation), but it's reasonable to assume Microsoft has evolved pattern matching behaviour for file names in the decade+ since so I thought I would check before proceeding on that assumption.

    Read the article

  • Lua pattern matching vs. regular expressions

    - by harald
    hello, i'm currently learning lua. regarding pattern-matching in lua i found the following sentence in the lua documentation on lua.org: Nevertheless, pattern matching in Lua is a powerful tool and includes some features that are difficult to match with standard POSIX implementations. as i'm familiar with posix regular expressions i would like to know if there are any common samples where lua pattern matching is "better" compared to regular expression -- or did i misinterpret the sentence? and if there are any common examples: why is any of pattern-matching vs. regular expressions better suited? thanks very much, harald

    Read the article

  • Numerical Pattern Matching

    - by Timothy Strimple
    A project I'm researching requires some numerical pattern matching. My searches haven't turned up many relevant hits since most results tend to be around text pattern matching. The idea is we'll have certain wave patterns we'll need to be watching for and trying to match incoming data vs the wave database we will be building. Here is and example of one of the wave patterns we'll need to be matching against. There is clearly a pattern there, but the peaks will not have the exact same values, but the overall shape of the wave iterations will be very similar. Does anyone have any advice on how to go about storing and later matching these patterns, and / or other search terms I can use to find more information on the subject of pattern matching? Thanks, Tim.

    Read the article

  • Pattern/Matcher in Java?

    - by user1007059
    I have a certain text in Java, and I want to use pattern and matcher to extract something from it. This is my program: public String getItemsByType(String text, String start, String end) { String patternHolder; StringBuffer itemLines = new StringBuffer(); patternHolder = start + ".*" + end; Pattern pattern = Pattern.compile(patternHolder); Matcher matcher = pattern.matcher(text); while (matcher.find()) { itemLines.append(text.substring(matcher.start(), matcher.end()) + "\n"); } return itemLines.toString(); } This code works fully WHEN the searched text is on the same line, for instance: String text = "My name is John and I am 18 years Old"; getItemsByType(text, "My", "John"); immediately grabs the text "My name is John" out of the text. However, when my text looks like this: String text = "My name\nis John\nand I'm\n18 years\nold"; getItemsByType(text, "My", "John"); It doesn't grab anything, since "My" and "John" are on different lines. How do I solve this?

    Read the article

  • Design Pattern for "Context Sensitive" Right Click Menu

    - by MadSeb
    Hi, What is a design pattern I can use for generating "context-sensitive" right click menus ? I have in mind a "Windows Explorer"-like application where a user can right click on a folder and get a list of menu items but right click on a drive and get a totally different list. What design pattern should I use ? Would the factory design pattern be appropiate for handling such a menu ? Regards, Seb

    Read the article

  • RewriteRule Works With "Match Everything" Pattern But Not Directory Pattern

    - by kgrote
    I'm trying to redirect newsletter URLs from my local server to an Amazon S3 bucket. So I want to redirect from: https://mysite.com/assets/img/newsletter/Jan12_Newsletter.html to: https://s3.amazonaws.com/mybucket/newsletters/legacy/Jan12_Newsletter.html Here's the first part of my rule: RewriteEngine On RewriteBase / # Is it in the newsletters directory RewriteCond %{REQUEST_URI} ^(/assets/img/newsletter/)(.+) [NC] # Is not a 2008-2011 newsletter RewriteCond %{REQUEST_URI} !(.+)(11|10|09|08)_Newsletter.html$ [NC] ## -> RewriteRule to S3 Here <- ## If I use this RewriteRule to point to the new subdirectory on S3 it will NOT redirect: RewriteRule ^(/assets/img/newsletter/)(.+) https://s3.amazonaws.com/mybucket/newsletters/legacy/$2 [R=301,L] However if I use a blanket expression to capture the entire file path it WILL redirect: RewriteRule ^(.*)$ https://s3.amazonaws.com/mybucket/newsletters/legacy/$1 [R=301,L] Why does it only work with a "match everything" expression but not a more specific expression?

    Read the article

  • Observer Pattern Implementation

    - by user17028
    To teach myself basic game programming, I am going to program a clone of Pong. I will use the Observer design pattern, with an interface between the input and the game engine. However, I'm not sure what the interface should do. One idea I had was for the input interface to tell the game engine that (e.g.) the screen was clicked, then to let the game engine decide what to do with that information (shoot a bullet, for example). Another idea I had was for the input interface, having caught the mouse click, to tell the game engine to shoot a bullet. Which method would be better for me to use?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >