Search Results

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

Page 43/263 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • How to read line after finding a pattern?

    - by Jonathan Low
    i've got a "CHANNEL(SYSTEM.DEF.SVRCONN) CHLTYPE(SVRCONN)" "id=3" what i want to do is to retrieve the id after i do a search on the file and found the first line. open (CHECKFILE8, "$file"); while (<CHECKFILE8>) #while loop to loop through each line in the file { chomp; #take out each line by line $datavalue = $_; #store into var , $datavalue. $datavalue =~ s/^\s+//; #Remove multiple spaces and change to 1 space from the front $datavalue =~ s/\s+$//; #Remove multiple spaces and change to 1 space from the back $datavalue =~ s/[ \t]+/ /g; #remove multiple "tabs" and replace with 1 space if($datavalue eq "CHANNEL(SYSTEM.DEF.SVRCONN) CHLTYPE(SVRCONN)") { // HOW TO READ THE NEXT LINE? } } } close(CHECKFILE8); } Thanks

    Read the article

  • Design pattern for data entry forms with LINQ2SQL

    - by petebob796
    I am about to start a new winforms data entry application, it already has the database designed which I am comfortable with. I was going to use LINQ2SQL to access the tables to keep things type safe but am now wondering about design patterns, something I am just getting into. Since LINQ is giving me objects to use should I still create classes in between to hold the validation code and helper methods or should these just go in with the UI? It just seems I will end up with classes sat in between with little code which will cause the UI classes to have code just getting and setting values in the intermediate class and returning from validation to flag errors... Any good reading on this? Should I consider the entity framework (or similar) instead?

    Read the article

  • PHP Extract Values From One String Based on a Pattern Defined in Another

    - by ironkeith
    I have two strings: $first = '/this/is/a/string'; $second = '/this/:param1/a/:param2'; And I'm trying to get this: $params = array('param1' => 'is', 'param2' => 'string'); But getting from point a to b is proving more than my tired brain can handle at the moment. Anything starting with a ':' in the second string defines a variable name/position. There can be any number of variables in $second which need to be extracted from $first. Segments are separated by a '/'. Thanks.

    Read the article

  • Request/Response pattern in SOA implementation

    - by UserControl
    In some enterprise-like project (.NET, WCF) i saw that all service contracts accept a single Request parameter and always return Response: [DataContract] public class CustomerRequest : RequestBase { [DataMember] public long Id { get; set; } } [DataContract] public class CustomerResponse : ResponseBase { [DataMember] public CustomerInfo Customer { get; set; } } where RequestBase/ResponseBase contain common stuff like ErrorCode, Context, etc. Bodies of both service methods and proxies are wrapped in try/catch, so the only way to check for errors is looking at ResponseBase.ErrorCode (which is enumeration). I want to know how this technique is called and why it's better compared to passing what's needed as method parameters and using standard WCF context passing/faults mechanisms?

    Read the article

  • Design pattern suggestion

    - by Avinash
    Following is the problem statement. There are n numbers of match strings, If event A occurs and then in certain period of time event B occurs then I do not raise alarm. but if B do not occurs then i have to raise alarm. There can be multiple chain of events which defines whether to raise alarm or not.

    Read the article

  • What is a good "Error Checking" Pattern (Java)?

    - by Jack
    I'll explain what I mean by input error checking. Say you have a function doSomething(x). If the function completes successfully doSomething does something and returns nothing. However, if there are errors I'd like to be notified. That is what I mean by error checking. I'm looking for, in general, the best way to check for errors. I've thought of the following solutions, each with a potential problem. Flag error checking. If doSomething(x) completes successfully return null. Otherwise, it returns a boolean or an error string. Problem: Side effects. Throwing an exception. Throw an exception if doSomething(x) encounters an error. Problem: If you are performing error checking for parameters only, throwing an IllegalArgumentExceptionseems inappropriate. Validating input prior to function call. If the error checking is only meant for the parameters of the function, then you can call a validator function before calling the doSomething(x) function. Problem: What if a client of the class forgets to call the validator function before calling doSomething(x)? I often encounter this problem and any help or a point in the right direction would be much appreciated.

    Read the article

  • Best Design Pattern to Implement while Mapping Actions in MVC

    - by FidEliO
    What could be the best practices of writing the following case: We have a controller which based on what paths users take, take different actions. For example: if user chooses the path /path1/hello it will say hello. If a user chooses /path1/bye?name="Philipp" it will invoke sayGoodBye() and etc. I have written a switch statement inside the controller which is simple, however IMO not efficient. What are the best way to implement this, considering that paths are generally String. private void takeAction() { switch (path[1]) { case "hello": //sayHello(); break; case "bye": //sayBye(); break; case "case3": //Blah(); break; ... } }

    Read the article

  • Design pattern: Polymorphism for list of objects

    - by ziang
    Suppose I have a class A, and A1, A2 inherits from A. There are 2 functions: List<A1> getListA1(){...} List<A2> getListA2(){...} Now I want to do something similar to both A1 and A2 in another function public void process(List<A>){...} If I want to pass the instance of either ListA1 or ListA2, of course the types doesn't match because the compiler doesn't allow the coercion from List< A1 to List< A. I can't do something like this: List<A1> listA1 = getListA1(); List<A> newList = (List<A>)listA1; //this is not allowed. So what is the best approach to the process()? Is there any way to do it in a universal way rather than write the similar code to both List and List?

    Read the article

  • Looking for an appropriate design pattern

    - by user1066015
    I have a game that tracks user stats after every match, such as how far they travelled, how many times they attacked, how far they fell, etc, and my current implementations looks somewhat as follows (simplified version): Class Player{ int id; public Player(){ int id = Math.random()*100000; PlayerData.players.put(id,new PlayerData()); } public void jump(){ //Logic to make the user jump //... //call the playerManager PlayerManager.jump(this); } public void attack(Player target){ //logic to attack the player //... //call the player manager PlayerManager.attack(this,target); } } Class PlayerData{ public static HashMap<int, PlayerData> players = new HashMap<int,PlayerData>(); int id; int timesJumped; int timesAttacked; } public void incrementJumped(){ timesJumped++; } public void incrementAttacked(){ timesAttacked++; } } Class PlayerManager{ public static void jump(Player player){ players.get(player.getId()).incrementJumped(); } public void incrementAttacked(Player player, Player target){ players.get(player.getId()).incrementAttacked(); } } So I have a PlayerData class which holds all of the statistics, and brings it out of the player class because it isn't part of the player logic. Then I have PlayerManager, which would be on the server, and that controls the interactions between players (a lot of the logic that does that is excluded so I could keep this simple). I put the calls to the PlayerData class in the Manager class because sometimes you have to do certain checks between players, for instance if the attack actually hits, then you increment "attackHits". The main problem (in my opinion, correct me if I'm wrong) is that this is not very extensible. I will have to touch the PlayerData class if I want to keep track of a new stat, by adding methods and fields, and then I have to potentially add more methods to my PlayerManager, so it isn't very modulized. If there is an improvement to this that you would recommend, I would be very appreciative. Thanks.

    Read the article

  • callback pattern

    - by robUK
    Hello, gcc 4.4.3 c89 I am creating a client server application and I will need to implement some callback functions. However, I am not too experienced in callbacks. And I am wondering if anyone knowns some good reference material to follow when designing callbacks. Is there any design patterns that are used for c. I did look at some patterns but there where all c++. Many thanks for any suggestions,

    Read the article

  • Decorator Design Pattern Use With Service Objects (wSingleton)

    - by Dustin
    I'm working on a project where I need to add some functionality to a service object and using a decorator to add it in seems like a good fit. However, I've only ever used decorators with simple beans, never on a singleton like a service object. Has anyone ever done this before and what are the pros and cons? In this case I don't think creating a subclass will work so a decorator seems to be a good fit. What are your thoughts on doing this?

    Read the article

  • Design pattern for loading multiple message types

    - by lukem00
    As I was looking through SO I came across a question about handling multiple message types. My concern is - how do I load such a message in a neat way? I decided to have a separate class with a method which loads one message each time it's invoked. This method should create a new instance of a concrete message type (say AlphaMessage, BetaMessage, GammaMessage, etc.) and return it as a Message. class MessageLoader { public Message Load() { // ... } } The code inside the method is something which looks really awful to me and I would very much like to refactor it/get rid of it: Message msg = Message.Load(...); // load yourself from whatever source if (msg.Type == MessageType.Alpha) return new AlphaMessage(msg); if (msg.Type == MessageType.Beta) return new BetaMessage(msg); // ... In fact, if the whole design looks just too messy and you guys have a better solution, I'm ready to restructure the whole thing. If my description is too chaotic, please let me know what it's missing and I shall edit the question. Thank you all.

    Read the article

  • [C#] RegEx search for two pattern strings and cut what's between

    - by gsharp
    I'm trying to write a little SQL Helper. I have a query like this stored in a string: DECLARE @V1 INT --ignore DECLARE @V11 INT DECLARE @V12 INT --endignore DECLARE @V2 INT --ignore SELECT * FROM SampleTable INNER JOIN AnotherSampleTable ...... --endignore SELECT * From Employee ORDER BY LastName My helper method should cut everything what's between --ignore and --endignore The result string should look like: DECLARE @V1 INT DECLARE @V2 INT SELECT * From Employee ORDER BY LastName How can achieve my result with RegEx?

    Read the article

  • Session vs singleton pattern

    - by chobo
    Hi, I have a web application where I would like to pull user settings from a database and store them for Global access. Would it make more sense to store the data in a Singleton, or a Session object? What's the difference between the two? Is it better to store the data as an object reference or break it up into value type objects (ints and strings)? Thanks!

    Read the article

  • Does this singleton pattern make sense?

    - by dontWatchMyProfile
    @implementation MySingletonClass static MySingletonClass *sharedInstance = nil; + (MySingletonClass*)sharedInstance { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [[self alloc] init]; } } return sharedInstance; } + (id)alloc { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [super alloc]; return sharedInstance; } } return nil; } + (id)allocWithZone:(NSZone *)zone { @synchronized(self) { if (sharedInstance == nil) { sharedInstance = [super allocWithZone:zone]; return sharedInstance; } } return nil; } -(id)init { self = [super init]; if (self != nil) { // initialize stuff here } return self; } @end Not sure if it's ok to overwrite both alloc and allocWithZone: like this...?

    Read the article

  • autosave pattern

    - by Mark
    I'm using localstorage to do gmail-style autosave on a webpage. So I basically save every 30 seconds to local, OK. The problem is recovery. I can't detect whether or not a user has crashed or incorrectly exited. So let's say the user crashed and loads up the form again, I can't just continue saving and overwriting the previous autosaves. I need to restore the previous save. But let's say the user didn't crash. He did everything correctly, but then used a different browser to edit the same file, so no new data to the previous browser's localstorage. He then loads up the file in the previous browser. The localstorage should not be restored in that case. Assuming there's no way to compare timestamps, how can I solve this problem? Thanks.

    Read the article

  • MVC + Repository Pattern - Still depends on Data Model?

    - by Jack
    I've started a project for school in which I am using ASP.NET MVC 2 + LINQ2SQL, and a business layer so my UI doesnt interact with the DB directly. My question is this: In my MVC project, when bringing up views and passing around data, I still have to include my Data project for access to the classes in my Linq2Sql project. Is this correct? Example: Controller: ClassesRepository cr = new ClassesRepository(); // this is from my Business project Class classToEdit = cr.GetByClassId(id); // "Class" is from my data project I still have to reference the Class class in my linq2sql data project - shouldn't my UI be completely independent of my data layer? Or maybe I'm going about this all wrong.

    Read the article

  • Sed-replacing a pattern

    - by grails_enthu
    I have below code: <td nowrap="nowrap" width="74"> <p align="center">server1</p> </td> <td nowrap="nowrap" width="74"> <p align="center">server2</p> </td> and so on.I want to get output as: <td nowrap="nowrap" width="74">server1</td> <td nowrap="nowrap" width="74">server2</td> What should be my approach?Say for example the file is server.html I have done something like this: sed "s/<p align="center">*</p>/*/" -i server.html But its not working.

    Read the article

  • Replacing Text which does not match a pattern in Oracle

    - by kutekrish
    I have below text in a CLOB in a table Table Name: tbl1 Columns col1 - number (Primary Key) col2 - clob (as below) Row#1 ----- Col1 = 1 Col2 = 1331882981,ab123456,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqr123223,Some more text... Row#2 ----- Col1 = 2 Col2 = 1331882981,abc333,Some text here which can run multiple lines and have a lot of text... ~1331890329,pqrs23,Some more text... Now I need to know how we can get below output Col1 Value ---- --------------------- 1 1331882981,ab123456 1 1331890329,pqr123223 2 1331882981,abc333 2 1331890329,pqrs23 ([0-9]{10},[a-z 0-9]+.), == This is the regular expression to match "1331890329,pqrs23" and I need to know how can replace which are not matching this regex and then split them into multiple rows

    Read the article

  • Replace String pattern in Java

    - by Hirantha
    I have the following string "value=\"\\d{4}((((0[1-9])|(1[0-2]))((0[1-9])|([12]\\d)|(3[01]))?)?|(\\-(((0[1-9])|(1[0-2]))(\\-((0[1-9])|([12]\\d)|(3[01])))?)?)?)d{4}" There I want to replace all the occurrences of "{" with NCHAR(0x7B) "}" with NCHAR(0x7D). An the content in-between "{ }" should remain unchanged: Ex: \\d{4} after replacing -> NCHAR(0x7B) 4 NCHAR(0x7D). Is there a way to do this using Regular Expressions in Java?. Anyway, this can be done processing the whole string using string operations.

    Read the article

  • design-pattern libraries ready-to-use?

    - by fayer
    symfony has released some of their components free to use outside the framework. i have used the event dispatcher and dependency injection...they are awesome! i wonder if there are other components/libraries (from other frameworks etc) that in the same way help you manage various design patterns? eg. decorator, facade, singleton, chain of commands etc. i think symfony is on the right path, abstracting away the design patterns. are there any other components out there doing the same? thanks

    Read the article

  • License key pattern detection?

    - by Ricket
    This is not a real situation; please ignore legal issues that you might think apply, because they don't. Let's say I have a set of 200 known valid license keys for a hypothetical piece of software's licensing algorithm, and a license key consists of 5 sets of 5 alphanumeric case-insensitive (all uppercase) characters. Example: HXDY6-R3DD7-Y8FRT-UNPVT-JSKON Is it possible (or likely) to extrapolate other possible keys for the system? What if the set was known to be consecutive; how do the methods change for this situation, and what kind of advantage does this give? I have heard of "keygens" before, but I believe they are probably made by decompiling the licensing software rather than examining known valid keys. In this case, I am only given the set of keys and I must determine the algorithm. I'm also told it is an industry standard algorithm, so it's probably not something basic, though the chance is always there I suppose. If you think this doesn't belong in Stack Overflow, please at least suggest an alternate place for me to look or ask the question. I honestly don't know where to begin with a problem like this. I don't even know the terminology for this kind of problem.

    Read the article

  • Regular Expression: Match untill pattern is found

    - by ZafarYousafi
    Hi, I want to extract the status from the string untill I found a timespan. My input is something like "Something in start but not with this keyword of sure. STATUS: My Status Is Here Which can be anything but timespan 23:59:01 and so on. I want to extract the string after STATUS: untill 23:59:01 is found. How can i achieve this through regex. this 23:59:01 is a timespan and it is always in this format hh:mm:ss

    Read the article

  • Does this pattern have a name?

    - by LK7jb
    Disclaimer: I'm trying to learn proper OO programming/design, so I'm pretty new to this stuff. I guess this is a general design patterns question, but I'll base my example on a game engine or something that renders objects to the display. Consider the following: How can this sort of separation between physical objects (e.g., cubes, spheres, etc.) and the rendering mechanism be achieved in an extensible manner? This design is not set in stone, and perhaps I've got something wrong from the start. I'm just curious as to how a problem like this is solved in real world code.

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >