Search Results

Search found 5544 results on 222 pages for 'pattern'.

Page 29/222 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • creational pattern for instances depending on multiple subclass instances

    - by markusw
    I have a problem, for that I was not able to identify a suitable design pattern. I want to create instances depending on a given type that has been passed to a factory method. What I am doing until now is the following: T create(SuperType x) { if (x instanceof SubType1) { // do some stuff and return a new SubType extends T } else if (x instanceof SubType2) { // do some stuff and return a new SubType extends T } else if ... } else { throw new UnSupportedOperationException("nothing defined for " + x); } } It seems not to be best pratice for me. Has anybody an idea how to solve this in a better way?

    Read the article

  • regex pattern to match only strings that don't contain spaces PHP

    - by Jamex
    Hi, I want to match the word/pattern that is contained in the variable, but only match against the words that don't have white spaces. Please give suggestions. $var = 'look'; $array = ('look', 'greatlook', 'lookgreat', 'look great', 'badlook', 'look bad', 'look ', ' look'); matches words: look, greatlook, lookgreat, badlook non matches: look great, bad look, look (trailing space(s)), (space(s)) look. The syntax of the below functions are OK, but it matches everything $match = preg_grep ("/$var/", $array); $match = preg_grep ("/^$var/", $array); (match words with 'look' at the start) but when I include the [^\s], it gives an error $match = preg_grep ("/$var[^\s]/", $array); Parse error: syntax error, unexpected '^', expecting T_STRING or T_VARIABLE TIA

    Read the article

  • Xcode iphone sdk - Searching in UITableView, different pattern matching

    - by Lorenzo
    Hi everyone, I'm coding a UITableView with a UISearchBar to search between a list of cities (loaded in the uitableview) Here is my code for searhing: - (void) searchTableView { NSString *searchText = searchBar.text; NSMutableArray *searchArray = [[NSMutableArray alloc] init]; for (NSDictionary *dictionary in listOfItems) { NSArray *array = [dictionary objectForKey:@"Cities"]; [searchArray addObjectsFromArray:array]; } for (NSString *sTemp in searchArray) { NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch]; if (titleResultsRange.length > 0) [copyListOfItems addObject:sTemp]; } [searchArray release]; searchArray = nil;} And with this everything works fine, but i need to do something a bit different. I need to search only between items that match pattern Word* and not * Word *. For example if I search "roma", this need to match just with "Roma" or "Romania" and not with "Castelli di Roma". Is that possible with this searchbar? How can i modify this? Thanks

    Read the article

  • ClearCase UCM Mainline Configuration Management Pattern Question

    - by cogmios
    A configuration management pattern question (using Rational ClearCase UCM) When I use the mainline approach I create new releases by: - create release 1 from mainline - on a certain moment baseline release 1, deliver release 1 to mainline - create release 2 from mainline - on a certain moment baseline release 2, deliver release 2 to mainline - create release 3 from mainline - etc... Works very nice because the pathname is /main/release 3/latest instead of /main/release 1/release 2/release 3/latest etc... However... when in release 1 are new elements that have to be propagated to later releases I can not use the mainline since the mainline is already on e.g. release 4. The only thing I can do is deliver/merge from release 1 directly to release 2. The bad thing is that the pathname then becomes /main/release 1/release 2/latest for that files (and possibly later releases). That is I think not in line with the mainline approach. What am I doing wrong?

    Read the article

  • Design pattern for mouse interaction

    - by mike
    I need some opinions on what is the "ideal" design pattern for a general mouse interaction. Here the simplified problem. I have a small 3d program (QT and openGL) and I use the mouse for interaction. Every interaction is normally not only a single function call, it is mostly performed by up to 3 function calls (initiate, perform, finalize). For example, camera rotation: here the initial function call will deliver the current first mouse position, whereas the performing function calls will update the camera etc. However, for only a couple of interactions, hardcoding these (inside MousePressEvent, MouseReleaseEvent MouseMoveEvent or MouseWheelEvent etc) is not a big deal, but if I think about a more advanced program (e.g 20 or more interactions) then a proper design is needed. Therefore, how would you design such a interactions inside QT. I hope I made my problem clear enough, otherwise don't bother complain :-) Thanks

    Read the article

  • Design pattern to encapsulate common funtionality among UI controls

    - by Dan
    I'm brainstorming some ideas around a pattern to use for the following scenario. I have some 3rd party controls that I want to add common functionality to. Functionality is added by handling several of the the events and doing certain things when the events fire along with adding some private variables to hold some state info between events. I want to reuse the code and functionality so this is what I'd typically do. Create a class for this functionality and pass in the instance of the control that I want to add the functionality to in the constructor. Then I can add event handlers to the control in the instance of the class. Can anyone think of alternative patterns to use in order to create this kind of reusable functionality.

    Read the article

  • Pattern matching for lambda expressions

    - by alphomega
    21 --Primitive recursion constructor 22 pr :: ([Int] -> Int) -> ([Int] -> Int) -> ([Int] -> Int) 23 pr f g = \xs 0 -> f xs 24 pr f g = \xs (y+1) -> g xs y ((pr f g) xs y) I want the function this function creates to act differently on different inputs, so that it can create a recursive function. As expected, the above code doesn't work. How do I do something like pattern matching, but for the function it creates? Thanks

    Read the article

  • Store database, good pattern for simultaneous access

    - by dygi
    I am kinda new to database designing so i ask for some advices or some kind of a good pattern. The situation is that, there is one database, few tables and many users. How should i design the database, or / and which types of queries should i use, to make it work, if users can interact with the database simultaneously? I mean, they have access to and can change the same set of data. I was thinking about transactions, but I am not sure, if that is the right / good / the only solution. I will appreciate some google keywords too.

    Read the article

  • MVC design pattern - who loads view initially

    - by enableDeepak
    This query is about MVC design pattern in general and not ASP.net MVC framework I understand in MVC (desktop application): 1. User clicks something in view 2. this is passed on to controller to manage 3. controller makes some changes in Model 4. Model calls method on view which has the logic to refresh UI Questions around these: Q1) Can controller also modify View or Model only updates View? Q2) When screen loads for the first time, there is no Model change. Then, who fetches data from model and populates view? View directly calls Model and populates itself OR controller gets data and passes to view method OR some dummy event is raised at Model which updates View?

    Read the article

  • C++ Singleton design pattern.

    - by Artem Barger
    Recently I've bumped into realization/implementation of Singleton design pattern for C++. It has looked in the following way (I have adopted it from real life example): // a lot of methods is omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); static Singleton* instance; }; From this declaration I can deduce that instance field is initiated on the heap, that means there is a memory allocation. That is completely unclear for me is when does exactly memory is going to be deallocated? Or there is a bug and memory leak? It seems like there is a problem in implementation. PS. And main question how to implement it in the right way?

    Read the article

  • Regular Expression: Changes HTML Attributes Value to some pattern

    - by brain90
    Dear Engineers, I'm a newbie in RegEx I have thousands html tags, have wrote like this: <input type="text" name="CustomerName" /> <input type="text" name="SalesOrder"/> I need to match every name attribute values and convert them all to be like this: CustomerName -> cust[customer_name] SalesOrder -> cust[sales_order] So the results will be : <input type="text" name="cust[customer_name]" /> <input type="text" name="cust[sales_order]" /> My best try have stuck in this pattern: name=\"[a-zA-Z0-9]*\" - just found name="CustomerName" Please guide me wrote some Regular Expression magics to done this, I'm using Netbeans PDT. Thanks in advance for any pointers!.

    Read the article

  • Searching for the right pattern to handle login data

    - by stevebot
    Hi all, I'm working on a controller that handles logins for a Web app. These logins will come from multiple clients but will all contain the same data. However, depending on the client, this data will be interpreted into common entities for our webapp differently. For instance, we have a user code that gets sent in, and in one case we may use the first four digits of the code, and in another case 12 digits of the code to map to a field on a User entity. Instead of handling this all in the controller and having big nasty if blocks of logic, I would like to use a pattern to handle how this information gets ingested into our application. What are your opinions?

    Read the article

  • command design pattern usage

    - by sagie
    Hi. I've read 3 descriptions of the command design pattern: wikipedia, dofactory and source making. In all of them, the UML shows a relation between the client to the receiver & the concrete command, but no relation to the invoker. But in all 3 examples the client is the one that initiates the invoker and call its Execute method. I think that should be a relation to the invoker as well. Am I missing somthing in here? Maybe even a basic UML knowladge?

    Read the article

  • commad design pattern usage

    - by sagie
    Hi. I've read 3 descriptions of the command design pattern: wikipedia, dofactory and source making. In all of them, the UML shows a relation between the client to the receiver & the concrete command, but no relation to the invoker. But in all 3 examples the client is the one that initiates the invoker and call its Execute method. I think that should be a relation to the invoker as well. Am I missing somthing in here? Maybe even a basic UML knowladge?

    Read the article

  • Delete the first line that matches a pattern

    - by gioele
    How can I use sed to delete only the first line that contains a certain pattern? For example, I want to remove the first line matching FAA from this document: 1. foo bar quuz 2. foo FAA bar (this should go) 3. quuz quuz FAA (this should remain) 4. quuz FAA bar (this should also remain) The result should be 1. foo bar quuz 3. quuz quuz FAA (this should remain) 4. quuz FAA bar (this should also remain) A solution for POSIX sed would be greatly appreciated, GNU sed is OK.

    Read the article

  • What's this UI pattern called?

    - by Bears will eat you
    I'm trying to figure out what this sort of thing is called, and eventually how I can create one in a web browser. It looks like this (screenshot of the first app that came to mind): The specific component/pattern I'm looking for is the two list boxes ("Included Gear" and "Excluded Gear") that represent inclusion/exclusion of items from a set. I'm not really looking for the WPF name (if there is one) but it might be helpful. I am looking for the name of this thingy, if there is one, and if you really want to make my day, you can point me toward a jQuery or YUI way of making one of these dealies in a browser. In case you were wondering, the screenshot is a World of Warcraft gear optimization program. Go figure why it was the first program that came to mind when I was trying to think of an example.

    Read the article

  • Pattern for unidirectional has_many join?

    - by Kris
    It occurred to me that if I have a has_many join, where the foreign model does not have a belongs_to, and so the join is one way, then I don't actually need a foreign key. We could have a column, category_ids, which stores a marshaled Array of IDs which we can pass to find. So here is an untested example: class page < AR def categories Category.find(self.category_ids) end def categories<<(category) # get id and append to category_ids save! end def category_ids @cat_ids ||= Marshal.load(read_attribute(:category_ids)) rescue [] end def category_ids=(ids) @cat_ids = ids write_attribute(:category_ids, ids) end end page.category_ids = [1,4,12,3] page.categories = Array of Category Is there accepted pattern for this already? Is it common or just not worth the effort?

    Read the article

  • Using TweenMax to fade in div with background pattern and z-index not working

    - by shibbydoo
    I'm trying to do this really simple fade using TweenMax for this div I have. Here's the css for the div .aboutBg { background:url(../images/pattern.jpg); top:0; right:0; left:0; bottom:0, position:fixed; border:10px solid red; z-index:10; } TweenMax.to('.aboutPage', 0.5, {autoAlpha:1}); What's happening is the border would fade in nicely but the patterned bg is not, it just pops up at the end of the tween. If I remove the z-index everything works, but I have to have set the z-index so it's on top of my other content. Also I'm not tweening the z-index, it's set before the tween, so I'm not sure why it's not fading correctly. Anyone has any idea? Thanks.

    Read the article

  • C++ Singleton design pattern

    - by Artem Barger
    Recently I've bumped into a realization/implementation of the Singleton design pattern for C++. It has looked like this (I have adopted it from the real life example): // a lot of methods are omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); static Singleton* instance; }; From this declaration I can deduce that the instance field is initiated on the heap. That means there is a memory allocation. What is completely unclear for me is when exactly the memory is going to be deallocated? Or is there a bug and memory leak? It seems like there is a problem in the implementation. My main question is, how do I implement it in the right way?

    Read the article

  • What pattern is this? php

    - by user151841
    I have several classes that are basically interfaces to database rows. Since the class assumes that a row already exists ( __construct expects a field value ), there is a public static function that allows creation of the row and returns an instance of the class. Here's an example ( without the actual database inserts ): class selfStarter { public $type; public function __construct( $type ) { $this->type = $type; } public static function create( $type ) { if ( ! empty($type) ) { $starter = & new selfStarter($type); return $starter; } } } $obj1 = selfStarter::create( "apple" ); $obj2 = & new selfStarter( "banana" ); What is this pattern called?

    Read the article

  • [Bash] Save part of matching pattern to variable

    - by Ben
    I want to extract a substring matching a pattern and save it to a file. An example string: Apr 12 19:24:17 PC_NMG kernel: sd 11:0:0:0: [sdf] Attached SCSI removable disk I want to extract the part between the brackets, in this case []. I tried to do something like grep -e '[$subtext]' to save the text in the brackets to a variable. Of course it doesn't work, but I am looking for a way similar to this. It would be very elegant to include a variable in a regex like this. What can I do best? Thanks!

    Read the article

  • singleton pattern in java- lazy Intialization

    - by flash
    public static MySingleton getInstance() { if (_instance==null) { synchronized (MySingleton.class) { _instance = new MySingleton(); } } return _instance; } 1.is there a flaw with the above implementation of the getInstance method? 2.What is the difference between the two implementations.? public static synchronized MySingleton getInstance() { if (_instance==null) { _instance = new MySingleton(); } return _instance; } I have seen a lot of answers on the singleton pattern in stackoverflow but the question I have posted is to know mainly difference of 'synchronize' at method and block level in this particular case.

    Read the article

  • find a specific string pattern in an array jquery

    - by Bwyss
    Apologies if this is a duplicate, but I can't seem to find the solution. I am trying to find a specific string pattern in an array. I want to find all values in data that contain 'underscore r underscore'. I then want to create a new array that contains only those keys and values. var data = ["something", "bar_r_something"]; var resultArray = new Array(); for (var i = 0; i < data.length; i++) { var bar = /_r_/; if ($.inArray(bar, data[i].length) > 0) { console.log("found _r_"); resultArray.push(data[i]); } }; I just can't seem to get that $.inArray to work, it seems to always kick out -1.

    Read the article

  • Doubt about a particular pattern of Javascript class definition

    - by fenderplayer
    Recently i saw the following code that creates a class in javascript: var Model.Foo = function(){ // private stuff var a, b; // public properties this.attr1 = ''; this.attr2 = ''; if(Model.Foo._init === 'undefined'){ Model.Foo.prototype = { func1 : function(){ //...}, func2 : function(){ //... }, //other prototype functions } } Model.Foo._init = true; } // Instantiate and use the class as follows: var foo = new Model.Foo(); foo.func1(); I guess the _init variable is used to make sure we don't define the prototypes again. Also, i feel the code is more readable since i am placing everything in a function block (so in oop-speak, all attributes and methods are in one place). Do you see any issues with the code above? Any pitfalls of using this pattern if i need to create lots of classes in a big project?

    Read the article

  • What Design Pattern To Replace 'CurrentStep' Variable

    - by Rob P.
    Tried to search but didn't know how to phrase it. I've got some code that is essentially... Private CurMajorStep as Integer = 0 Private CurMinorStep as Integer = 0 Public Sub PerformNextStep() Select Case iMajorStep Case 0 ThingOne() Case 1 ThingTwo() Case 2 ThingThree() Case 3 ThingFour() Case 4 AnythingElse() Case 5 Finish() End Select End Sub And then, in some of those, the CurMinorStep keeps track of the current state of that particular 'step'. I hope that all makes sense. The code is messy and I know it's going to be problematic to maintain. Can someone point me to a clean OO pattern to handle this?

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >