Search Results

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

Page 53/263 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • Is implementing an interface defined in a subpackage an anti-pattern?

    - by Michael Kjörling
    Let's say I have the following: package me.my.pkg; public interface Something { /* ... couple of methods go here ... */ } and: package me.my; import me.my.pkg.Something; public class SomeClass implements Something { /* ... implementation of Something goes here ... */ /* ... some more method implementations go here too ... */ } That is, the class implementing an interface lives closer to the package hierarchy root than does the interface it implements but they both belong in the same package hierarchy. The reason for this in the particular case I have in mind is that there is a previously-existing package that groups functionality which the Something interface logically belongs to, and the logical (as in both "the one you'd expect" and "the one where it needs to go given the current architecture") implementation class exists previously and lives one level "up" from the logical placement of the interface. The implementing class does not logically belong anywhere under me.my.pkg. In my particular case, the class in question implements several interfaces, but that feels like it doesn't make any (or at least no significant) difference here. I can't decide if this is an acceptable pattern or not. Is it or is it not, and why?

    Read the article

  • Can observer pattern be represented by cars and traffic lights?

    - by eeerahul
    I wanted to verify with all of you, if I have a correct Observer Pattern analogy. The scenario is as follows: Consider, at a junction, there is a traffic signal, having red, yellow and green lights respectively. There are vehicles facing the traffic signal post. When it shows red, the vehicles stop, when it shows green, the vehicles move on. In case, it is yellow, the driver must decide whether to go or to stop, depending on whether he/she has crossed the stop line or not. At the same time, there are vehicles that do not care about the signal. They would do as they like. The similarities are that, the Traffic Signal happens to be the subject, notifying its states by glowing the appropriate lights. Those looking at it and following the signal are the ones subscribed to it, and behave according to the state of the subject. Those who do not care about it, are sort-of un-subscribed from the traffic signal. Please tell me, if you think this is a correct analogy or not?

    Read the article

  • What is the preferred pattern when attaching a 'runtime object'?

    - by sebf
    In my application I have the following: public class NeatObject { /* lots of static data, and configuration flags */ } public class NeatObjectConsumer { void DoCleverStuffWithObjectOnGPU(NeatObject obj); } Where NeatObject and its consumer are used to control the GPU. The idea being that, the configuration of an instance of NeatObject and its members, define how the consumer instance behaves. The object can be passed around, edited, and most importantly serialised/deserialised by the application, with and without knowledge of NeatObjectConsumer, then provided back to the consumer to do something else. The purpose of this seperation is: The consumer manages hardware resources, which change depending on the computer, and even on the execution of the application, making preserving the state of an object which does everything difficult. Avoids circular references if the assembly that contains the consumer needs to reference one that only needs to know about NeatObject. However, there is a complication in that the consumer creates hardware resources and needs to associate them with NeatObject. These don't need to be preserved, but still need to be retrieved. DoCleverStuffWithObjectOnGPU() will be called many, many times during execution and so any bottleneck is a concern, therefore I would like to avoid dictionary lookups. What is the preferred method of attaching this information to NeatObject? By preferred, I mean intuitive - other coders can see immediately what is going on - and robust - method doesn't invite playing with the resources or present them in such a way as to make them easily corruptible. Essentially, I want to add my own metadata - how should I do it? Try to use 'actual metadata' functionality like Reflection? A member of the type of an abstract class? Unmanaged pointers? If you took on a project that used this pattern, what would you have liked the previous developer to do?

    Read the article

  • What design pattern (in python) to use for properly seperate runtime infos with core code?

    - by user1824372
    I am not sure if this is a clear question. I work on a python project that is based on terminal(console), for which I am planning to implement a GUI. I am not major in CS so I really have no idea about how to effectively design a message system such that: in console, it provide nice look info when runtime. in GUI, it is directed to a certain widget, let's say, a text label, or a bottom bar, or a hide-able frame. Do you have any suggestions? Currently, I am using print function to provide essential informations on stdout during runtime. So a lot of print .... are distributed here and there among the code. I am thinking to use macro-like variables such as 'FILE_NOT_EXTIS_MESSAGE' for printing, and define the variables in one file. Is this a standard way that people always do? How about I introduce a logging system? In sum, I am ask for a pattern that people are commonly using for handling of screen output information with high effectiveness and adaptivity.

    Read the article

  • How to refer to enum values inside nhibernate formula mapping specification?

    - by mark
    Dear ladies and sirs. I have two entities types: RunContainer parent entity type Run child entity type Run has a property Status, which is of type RunStatus, like so: public enum RunStatus { Created, Starting, // ... } public class Run { public int ContainerId { get; private set; } // ... public RunStatus Status { get; private set; } } RunContainer has a calculated property ActiveRunCount, like so: public class RunContainer { public int Id { get; private set; } // ... public int ActiveRunCount { get; private set; } } In the mapping for the RunContainer.ActiveRunCount property, I use the formula specification like so: <property name="ActiveRunCount" formula="(select count(r.Id) from Run r where r.ContainerId = Id and r.Status = 1)"/> My problem is that I refer to the RunStatus enum values in the formula by their respective numeric value, rather than the appropriate symbolic name. Can anyone tell me how can I use the symbolic name instead? Thanks.

    Read the article

  • Question about decorator pattern and the abstract decorator class?

    - by es11
    This question was asked already here, but rather than answering the specific question, descriptions of how the decorator pattern works were given instead. I'd like to ask it again because the answer is not immediately evident to me just by reading how the decorator pattern works (I've read the wikipedia article and the section in the book Head First Design Patterns). Basically, I want to know why an abstract decorator class must be created which implements (or extends) some interface (or abstract class). Why can't all the new "decorated classes" simply implement (or extend) the base abstract object themselves (instead of extending the abstract decorator class)? To make this more concrete I'll use the example from the design patterns book dealing with coffee beverages: There is an abstract component class called Beverage Simple beverage types such as HouseBlend simply extend Beverage To decorate beverage, an abstract CondimentDecorator class is created which extends Beverage and has an instance of Beverage Say we want to add a "milk" condiment, a class Milk is created which extends CondimentDecorator I'd like to understand why we needed the CondimentDecorator class and why the class Milk couldn't have simply extended the Beverage class itself and been passed an instance of Beverage in its constructor. Hopefully this is clear...if not I'd simply like to know why is the abstract decorator class necessary for this pattern? Thanks. Edit: I tried to implement this, omitting the abstract decorator class, and it seems to still work. Is this abstract class present in all descriptions of this pattern simply because it provides a standard interface for all of the new decorated classes?

    Read the article

  • Best Creational Pattern for loggers in a multi-threaded system?

    - by Dipan Mehta
    This is a follow up question on my past questions : Concurrency pattern of logger in multithreaded application As suggested by others, I am putting this question separately. As the learning from the last question. In a multi-threaded environment, the logger should be made thread safe and probably asynchronous (where in messages are queued while a background thread does writing releasing the requesting object thread). The logger could be signleton or it can be a per-group logger which is a generalization of the above. Now, the question that arise is how does logger should be assigned to the object? There are two options I can think of: 1. Object requesting for the logger: Should each of the object call some global API such as get_logger()? Such an API returns "the" singleton or the group logger. However, I feel this involves assumption about the Application environment to implement the logger -which I think is some kind of coupling. If the same object needs to be used by other application - this new application also need to implement such a method. 2. Assign logger through some known API The other alternative approach is to create a kind of virtual class which is implemented by application based on App's own structure and assign the object sometime in the constructor. This is more generalized method. Unfortunately, when there are so many objects - and rather a tree of objects passing on the logger objects to each level is quite messy. My question is there a better way to do this? If you need to pick any one of the above, which approach is would you pick and why? Other questions remain open about how to configure them: How do objects' names or ID are assigned so that will be used for printing on the log messages (as the module names) How do these objects find the appropriate properties (such as log levels, and other such parameters) In the first approach, the central API needs to deal with all this varieties. In the second approach - there needs to be additional work. Hence, I want to understand from the real experience of people, as to how to write logger effectively in such an environment.

    Read the article

  • What is a useful pattern to maintaining an object state in a one to many relationship?

    - by ahenderson
    I am looking for a design for my application, here are the players(classes) involved. struct Transform { // Uses a matrix to transform the position. // Also acts acts as the state of a Dialog. Position transform(Position p); //other methods. }; struct Dialog { // There are multiple dialog for the user to transform the output. Transform& t; void ChangeTranformation(){t.rotate(360);} } struct Algorithm { //gives us a position based on an implementation. For example this can return points on a circle or line. Transform& t; Position m_p; Dialog& d; Position GetCurrentPosition(){ return t.transform(m_p);} //other methods. } Properties I need: Each algorithms has one dialog and each dialog can have many algorithms associated with it. When the user selects an algorithm a dialog associated with that algorithm is displayed. If the user selects a different algorithm then re-selects back the state is restored in the dialog. Basically I want a good design pattern to maintain the state of the dialog given that many algorithms use it and they can be switched back and forth. Does anyone have any suggestions? Here is a use case: Dialog1 has a single edit box to control the radius. Algorithm1 generates points on a unit circle. Algorithm2 is the same as Algorithm1. The user has selected Algorithm1 and entered 2 into the edit box. This will generate points on a circle of radius 2. The user then selects Algorithm2 and enters 10 into the edit box of Dialog1. This will generate points on a circle of radius 10. Finally Algorithm1 is selected again. The edit box of Dialog1 should show 2 and points on a circle of radius 2 should be generated.

    Read the article

  • How can you tell whether to use Composite Pattern or a Tree Structure, or a third implementation?

    - by Aske B.
    I have two client types, an "Observer"-type and a "Subject"-type. They're both associated with a hierarchy of groups. The Observer will receive (calendar) data from the groups it is associated with throughout the different hierarchies. This data is calculated by combining data from 'parent' groups of the group trying to collect data (each group can have only one parent). The Subject will be able to create the data (that the Observers will receive) in the groups they're associated with. When data is created in a group, all 'children' of the group will have the data as well, and they will be able to make their own version of a specific area of the data, but still linked to the original data created (in my specific implementation, the original data will contain time-period(s) and headline, while the subgroups specify the rest of the data for the receivers directly linked to their respective groups). However, when the Subject creates data, it has to check if all affected Observers have any data that conflicts with this, which means a huge recursive function, as far as I can understand. So I think this can be summed up to the fact that I need to be able to have a hierarchy that you can go up and down in, and some places be able to treat them as a whole (recursion, basically). Also, I'm not just aiming at a solution that works. I'm hoping to find a solution that is relatively easy to understand (architecture-wise at least) and also flexible enough to be able to easily receive additional functionality in the future. Is there a design pattern, or a good practice to go by, to solve this problem or similar hierarchy problems? EDIT: Here's the design I have: The "Phoenix"-class is named that way because I didn't think of an appropriate name yet. But besides this I need to be able to hide specific activities for specific observers, even though they are attached to them through the groups. A little Off-topic: Personally, I feel that I should be able to chop this problem down to smaller problems, but it escapes me how. I think it's because it involves multiple recursive functionalities that aren't associated with each other and different client types that needs to get information in different ways. I can't really wrap my head around it. If anyone can guide me in a direction of how to become better at encapsulating hierarchy problems, I'd be very glad to receive that as well.

    Read the article

  • Is there a factory pattern to prevent multiple instances for same object (instance that is Equal) good design?

    - by dsollen
    I have a number of objects storing state. There are essentially two types of fields. The ones that uniquely define what the object is (what node, what edge etc), and the others that store state describing how these things are connected (this node is connected to these edges, this edge is part of these paths) etc. My model is updating the state variables using package methods, so all these objects act as immutable to anyone not in Model scope. All Objects extend one base type. I've toyed with the idea of a Factory approach which accepts a Builder object and constructs the applicable object. However, if an instance of the object already exists (ie would return true if I created the object defined by the builder and passed it to the equal method for the existing instance) the factory returns the current object instead of creating a new instance. Because the Equal method would only compare what uniquely defines the type of object (this is node A to node B) but won't check the dynamic state stuff (node A is currently connected to nodes C and E) this would be a way of ensuring anyone that wants my Node A automatically knows its state connections. More importantly it would prevent aliasing nightmares of someone trying to pass an instance of node A with different state then the node A in my model has. I've never heard of this pattern before, and it's a bit odd. I would have to do some overriding of serialization methods to make it work (ensure that when I read in a serilized object I add it to my facotry list of known instances, and/or return an existing factory in its place), as well as using a weakHashMap as if it was a weakHashSet to know whether an instance exists without worrying about a quasi-memory leak occuring. I don't know if this is too confusing or prone to its own obscure bugs. One thing I know is that plugins interface with lowest level hardware. The plugins have to be able to return state that is different than my memory; to tell my memory when its own state is inconsistent. I believe this is possible despite their fetching objects that exist in my memory; we allow building of objects without checking their consistency with the model until the addToModel is called anyways; and the existing plugins design was written before all this extra state existed and worked fine without ever being aware of it. Should I just be using some other design to avoid this crazyness? (I have another question to that affect that I'm posting).

    Read the article

  • is a factory pattern to prevent multuple instances for same object (instance that is Equal) good design?

    - by dsollen
    I have a number of objects storing state. There are essentially two types of fields. The ones that uniquly define what the object is (what node, what edge etc), and the oens that store state describing how these things are connected (this node is connected to these edges, this edge is part of these paths) etc. My model is updating the state variables using package methdos, so these objects all act as immutable to anyone not in Model scope. All Objects extend one base type. I've toyed with the idea of a Factory approch which accepts a Builder object and construct the applicable object. However, if an instance of the object already exists (ie would return true if I created the object defined by the builder and passed it to the equal method for the existing instance) the factory returns the current object instead of creating a new instance. Because the Equal method would only compare what uniquly defines the type of object (this is node A nto node B) but won't check the dynamic state stuff (node A is currently connected to nodes C and E) this would be a way of ensuring anyone that wants my Node A automatically knows it's state connections. More importantly it would prevent aliasing nightmares of someone trying to pass an instance of node A with different state then the node A in my model has. I've never heard of this pattern before, and it's a bit odd. I would have to do some overiding of serlization methods to make it work (ensure when I read in a serilized object I add it to my facotry list of known instances, and/or return an existing factory in it's place), as well as using a weakHashMap as if it was a weakHashSet to know rather an instance exists without worrying about a quasi-memory leak occuring. I don't know if this is too confusing or prone to it's own obscure bugs. One thing I know is that plugins interface with lowest level hardware. The plugins have to be able to return state taht is different then my memory; to tell my memory when it's own state is inconsistent. I believe this is possible despit their fetching objects that exist in my memory; we allow building of objects without checking their consistency with the model until the addToModel is called anyways; and the existing plugins design was written before all this extra state existed and worked fine without ever being aware of it. Should I just be using some other design to avoid this crazyness? (I have another question to that affect I'm posting).

    Read the article

  • Architecture or Pattern for handling properties with custom setter/getter?

    - by Shelby115
    Current Situation: I'm doing a simple MVC site for keeping journals as a personal project. My concern is I'm trying to keep the interaction between the pages and the classes simplistic. Where I run into issues is the password field. My setter encrypts the password, so the getter retrieves the encrypted password. public class JournalBook { private IEncryptor _encryptor { get; set; } private String _password { get; set; } public Int32 id { get; set; } public String name { get; set; } public String description { get; set; } public String password { get { return this._password; } set { this.setPassword(this._password, value, value); } } public List<Journal> journals { get; set; } public DateTime created { get; set; } public DateTime lastModified { get; set; } public Boolean passwordProtected { get { return this.password != null && this.password != String.Empty; } } ... } I'm currently using model-binding to submit changes or create new JournalBooks (like below). The problem arises that in the code below book.password is always null, I'm pretty sure this is because of the custom setter. [HttpPost] public ActionResult Create(JournalBook book) { // Create the JournalBook if not null. if (book != null) this.JournalBooks.Add(book); return RedirectToAction("Index"); } Question(s): Should I be handling this not in the property's getter/setter? Is there a pattern or architecture that allows for model-binding or another simple method when properties need to have custom getters/setters to manipulate the data? To summarize, how can I handle the password storing with encryption such that I have the following, Robust architecture I don't store the password as plaintext. Submitting a new or modified JournalBook is as easy as default model-binding (or close to it).

    Read the article

  • Can anybody help me in designing my UITableView into MVC Pattern ?

    - by user2877880
    I have written a ViewController in which i get data from the internet and display it in a UItableview using a json parser which uses object for key to identify its objects. What i would like your help in is to convert it into MVC pattern to make it less clumsy instead of including everything in the same controller class. Please try explaining it to me in terms of my code. THANKS IN ADVANCE. The code is as given below #import "ViewController.h" #import "AFNetworking.h" #import "ModelTableArray.h" @implementation ViewController @synthesize tableView = _tableView, activityIndicatorView = _activityIndicatorView, movies = _movies; - (void)viewDidLoad { [super viewDidLoad]; // Setting Up Table View self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStylePlain]; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.tableView.hidden = YES; [self.view addSubview:self.tableView]; // Setting Up Activity Indicator View self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.activityIndicatorView.hidesWhenStopped = YES; self.activityIndicatorView.center = self.view.center; [self.view addSubview:self.activityIndicatorView]; [self.activityIndicatorView startAnimating]; // Initializing Data Source self.movies = [[NSArray alloc] init]; NSURL *url = [[NSURL alloc] initWithString:@"http://itunes.apple.com/search?term=rocky&country=us&entity=movie"]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged]; [self.tableView addSubview:refreshControl]; [refreshControl endRefreshing]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { self.movies = [JSON objectForKey:@"results"]; [self.activityIndicatorView stopAnimating]; [self.tableView setHidden:NO]; [self.tableView reloadData]; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo); }]; [operation start]; } - (void)refresh:(UIRefreshControl *)sender { NSURL *url = [[NSURL alloc] initWithString:@"http://itunes.apple.com/search?term=rambo&country=us&entity=movie"]; NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url]; AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { self.movies = [JSON objectForKey:@"results"]; [self.activityIndicatorView stopAnimating]; [self.tableView setHidden:NO]; [self.tableView reloadData]; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo); }]; [operation start]; [sender endRefreshing]; } - (void)viewDidUnload { [super viewDidUnload]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } // Table View Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (self.movies && self.movies.count) { return self.movies.count; } else { return 0; } } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"Cell Identifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID]; } NSDictionary *movie = [self.movies objectAtIndex:indexPath.row]; cell.textLabel.text = [movie objectForKey:@"trackName"]; cell.detailTextLabel.text = [movie objectForKey:@"artistName"]; NSURL *url = [[NSURL alloc] initWithString:[movie objectForKey:@"artworkUrl100"]]; [cell.imageView setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder"]]; return cell; } @end

    Read the article

  • How to block this URL pattern in Varnish VCL?

    - by iTech
    My website is getting badly hit by spambots and scrappers, I am using Cloudflare but the problem still remains there. The problem is spambots accessing non-existing urls causing a lot of load to my drupal backend which goes all the way and bootstraps db just to serve a 404 error doc. I cant simply dish out non-drupal 404's for all page not found errors, as I need to have drupal catch them. Since, varnish is in front it can check if the bot is acting nice and asking for valid url - if not it servers them a 404 or 403. These bots are causing errors using this pattern : http://www.megaleecher.net/http:/www.megaleecher.net/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_S/Using_iPhone_As_USB_Mass_Storage Now, pls. suggest a regex varnbisg VCL directive which catches this URL pattern and serves a 404 error from varnish, preventing it from reaching apache/drupal ?

    Read the article

  • Is using jquery to call a WCF Data Service from the UI violating the MVC pattern.

    - by Lee Dale
    I'm fairly new to ASP.Net MVC 2 and understand the MVC pattern in itself. But my question is what's the best way to populate dropdownlists in the UI sticking to the MVC pattern. Should I be going through the controller? Every article I've seen to do this shows how to do it using javascript and jquery. I have a test application that I'm re-writing in MVC2 I have my dropdowns working with jquery basically calling a WCF Data Service that returns JSON which populates the dropdowns. Seems to me though that this is bypassing the controller and going straight to the model therefore strictly violating the MVC pattern. Or am I missing something obvious here. You thoughts or best practices would be greatly welcome here. Thanks

    Read the article

  • Should I use the Model-View-ViewModel (MVVM) pattern in Silverlight projects?

    - by Jon Galloway
    One challenge with Silverlight controls is that when properties are bound to code, they're no longer really editable in Blend. For example, if you've got a ListView that's populated from a data feed, there are no elements visible when you edit the control in Blend. I've heard that the MVVM pattern, originated by the WPF development community, can also help with keeping Silverlight controls "blendable". I'm still wrapping my head around it, but here are some explanations: http://www.nikhilk.net/Silverlight-ViewModel-Pattern.aspx http://mark-dot-net.blogspot.com/2008/11/model-view-view-model-mvvm-in.html http://www.ryankeeter.com/silverlight/silverlight-mvvm-pt-1-hello-world-style/ http://jonas.follesoe.no/YouCardRevisitedImplementingTheViewModelPattern.aspx One potential downside is that the pattern requires additional classes, although not necessarily more code (as shown by the second link above). Thoughts?

    Read the article

  • c# RegEx with "|"

    - by WtFudgE
    I need to be able to check for a pattern with | in them. For example an expression like d*|*t should return true for a string like "dtest|test". I'm no regex hero so I just tried a couple of things, like: Regex Pattern = new Regex("s*\|*d"); //unable to build because of single backslash Regex Pattern = new Regex("s*|*d"); //argument exception error Regex Pattern = new Regex(@"s*\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*|*d"); //argument exception error Regex Pattern = new Regex("s*\\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex("s*" + "\\|" + "*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*\\|*d"); //argument exception error I'm a bit out of options, what should I then use? I mean this is pretty basic RegEx i know, but I'm not getting it for some reason.. Thx

    Read the article

  • JavaScript Regex Problem

    - by oraclee
    Hi all; Csharp Regex Pattern: Regex rg = new Regex("(?i)(?<=>)[^<]+(?=</TD>)"); JavaScript Regex Pattern: var pattern = (?i)(?<=>)[^<]+(?=</TD>); var result = str.match(pattern); Csharp Regex pattern work, but javascript regex pattern not work pls help ?

    Read the article

  • regular expression with "|"

    - by WtFudgE
    I need to be able to check for a pattern with | in them. For example an expression like d*|*t should return true for a string like "dtest|test". I'm no regular expression hero so I just tried a couple of things, like: Regex Pattern = new Regex("s*\|*d"); //unable to build because of single backslash Regex Pattern = new Regex("s*|*d"); //argument exception error Regex Pattern = new Regex(@"s*\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*|*d"); //argument exception error Regex Pattern = new Regex("s*\\|*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex("s*" + "\\|" + "*d"); //returns true when I use "dtest" as input, so incorrect Regex Pattern = new Regex(@"s*\\|*d"); //argument exception error I'm a bit out of options, what should I then use? I mean this is a pretty basic regular expression I know, but I'm not getting it for some reason.

    Read the article

  • [VBA] Create a recurrent event in Outlook

    - by CFP
    Hello everyone! I'm trying to create annual, all-day events with VBA in outlook 2007. I use the following code, but no matter which conbination of Start, StartDate, End, etc I use, it won't create a whole-day event. Either it gives it default start/end times, or it remove the all-day attribute... Dim Birthday As Date 'Get the birthday '... Dim BDay As AppointmentItem Dim Pattern As Outlook.RecurrencePattern Set BDay = Application.CreateItem(olAppointmentItem) Set Pattern = BDay.GetRecurrencePattern Pattern.RecurrenceType = olRecursYearly Pattern.DayOfMonth = Day(Birthday) Pattern.MonthOfYear = Month(Birthday) Pattern.PatternStartDate = Birthday Pattern.NoEndDate = True BDay.AllDayEvent = True BDay.Subject = Contact.FullName BDay.Save When created directly in outlook, entries start on the birth day and end 24 hours later. Yet trying to set Start and End this way results in errors. Plus, entries created outlook have no start/end time in the recurrence pattern (well, they are all-day entries...) Ideas, anybody? Thanks!

    Read the article

  • Does my fat-client application belong in the MVC pattern?

    - by boatingcow
    The web-based application I’m currently working on is growing arms and legs! It’s basically an administration system which helps users to keep track of bookings, user accounts, invoicing etc. It can also be accessed via a couple of different websites using a fairly crude API. The fat-client design loosely follows the MVC pattern (or perhaps MVP) with a php/MySQL backend, Front Controller, several dissimilar Page Controllers, a liberal smattering of object-oriented and procedural Models, a confusing bunch of Views and templates, some JavaScripts, CSS files and Flash objects. The programmer in me is a big fan of the principle of “Separation of Concerns” and on that note, I’m currently trying to figure out the best way to separate and combine the various concerns as the project grows and more people contribute to it. The problem we’re facing is that although JavaScript (or Flash with ActionScript) is normally written with the template, hence part of the View and decoupled from the Controller and Model, we find that it actually encompasses the entire MVC pattern... Swap an image with an onmouseover event - that’s Behaviour. Render a datagrid - we’re manipulating the View. Send the result of reordering a list via AJAX - now we’re in Control. Check a form field to see if an email address is in a valid format - we’re consulting the Model. Is it wise to let the database people write up the validation Model with jQuery? Can the php programmers write the necessary Control structures in JavaScript? Can the web designers really write a functional AJAX form for their View? Should there be a JavaScript overlord for every project? If the MVC pattern could be applied to the people instead of the code, we would end up with this: Model - the database boffins - “SELECT * FROM mind WHERE interested IS NULL” Control - pesky programmers - “class Something extends NothingAbstractClass{…}” View - traditionally the domain of the graphic/web designer - “” …and a new layer: Behaviour - interaction and feedback designer - “CSS3 is the new black…” So, we’re refactoring and I’d like to stick to best practice design, but I’m not sure how to proceed. I don’t want to reinvent the wheel, so would anyone have any hints or tips as to what pattern I should be looking at or any code samples from someone who’s already done the dirty work? As the programmer guy, how can I rewrite the app for backend and front end whilst keeping the two separate? And before you ask, yes I’ve looked at Zend, CodeIgnitor, Symfony, etc., and no, they don’t seem to cross the boundary between server logic and client logic!

    Read the article

  • NSScrollView - pattern background - how to start from top-left corner?

    - by dzolanta
    To fill NSScrollview with pattern image I use - (void)setBackgroundColor:(NSColor *)aColor method where aColor is created with + (NSColor *)colorWithPatternImage:(NSImage *)image method. Despite of what isFlipped returns for NSScrollView and its content view, pattern start repeat from bottom-left corner while I want it to start from top-left corner. How can I achieve that?

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >