Search Results

Search found 6569 results on 263 pages for 'specification pattern'.

Page 32/263 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • What software design pattern is best for the following scenario (C#)

    - by askjdh
    I have a gps device that records data e.g. datetime, latitude, longitude I have an sdk that reads the data from the device. The way the data is read: A command packet (basically a combination of int values in a struct) is sent to the device. The device responds with the data in fixed size chunks e.g. 64bytes Depending on the command issued I will get back differect data structs e.g. sending command 1 to the device returns a struct like struct x { id int, name char[20] } command 2 returns a collection of the following structs (basically it boils down to an array of the structs - y[12]) struct y { date datetime, lat decimal, lon decimal } I would then want to convert the struct to a class and save the data to a database. What would be the best way to encapsulate the entire process, preferably using some established design pattern? Many thanks M

    Read the article

  • 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

  • Dashboard pattern: HorizontalScrollView with pagination or ScrollView?

    - by Macarse
    I am starting a new application and I am willing to use the Dashboard pattern. For example: The Google IO app uses it: My issue is that the amount of buttons will be more than six. I'm not sure if I should use vertical or horizontal scrolling. Vertical scrolling could be done with a ScrollView or a GridView but I am not sure which would be the easier way to implement the horizontal version. I was thinking of using an HorizontalScrollView but it doesn't have pagination. It should feel similar to the tweetdeck app. How would you implement it?

    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

  • Design pattern for extending Android's activities?

    - by Carl
    While programming on Android, I end up writing a parent activity which is extended by several others. A bit like ListActivity. My parent activity extends Activity. if I intend to use a Map or a List, I can't use my parent activity as superclass - the child activity can only extend one activity obviously. As such I end up writing my parent activities with the same logic for Activity, ListActivity, MapActivity and so forth. What am I looking for is some sort of trait functionality/design pattern which would help in this case. Any suggestions?

    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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >