Search Results

Search found 5579 results on 224 pages for 'behavioral pattern'.

Page 19/224 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Is this class + constructor definition pattern overly redundant?

    - by Protector one
    I often come across a pattern similar to this: class Person { public string firstName, lastName; public Person(string firstName, string lastName) { this.firstName = firstName; this.lastName = lastName; } } This feels overly redundant (I imagine typing "firstName" once, instead of thrice could be enough…), but I can't think of a proper alternative. Any ideas? Maybe I just don't know about a certain design pattern I should be using here? Edit - I think I need to elaborate a little. I'm not asking how to make the example code "better", but rather, "shorter". In its current state, all member names appear 3 times (declaration, initialization, constructor arguments), and it feels rather redundant. So I'm wondering if there is a pattern (or semantic sugar) to get (roughly) the same behavior, but with less bloat. I apologize for being unclear initially.

    Read the article

  • How to apply Abstract Factory Pattern ???

    - by Amit
    I am new to Design Pattern and I have a scenario here... and not sure as how to implement the pattern ... We have multiple vendors Philips, Onida... Each vendor (philips, onida...) may have different type of product i.e. Plasma or Normal TV I want specific product of each vendor using Abstract Factory Pattern... Thanks in advance for any help... My implementation so far... public enum TvType { Samsung = 0,LG = 1,Philips = 2, Sony = 3 } public enum Product { Plasma = 0,NormalTV = 1 } concrete class of each vendor.... that returns each product and also the interface that contains ProductInfo i.e. if Vendor is ... then it must have this product....

    Read the article

  • Dependency Injection & Singleton Design pattern

    - by SysAdmin
    How do we identify when to use dependency injection or singleton pattern. I have read in lot of websites where they say "Use Dependency injection over singleton pattern". But I am not sure if I totally agree with them. For my small or medium scale projects I definitely see the use of singleton pattern straightforward. For example Logger. I could use Logger.GetInstance().Log(...) But, instead of this, why do I need to inject every class I create, with the logger's instance?.

    Read the article

  • How to determine item at a index in pattern

    - by el.gringogrande
    I have the following elements in a list/array a1,a2,a3 and these elements are used to build another list in a predictable pattern example a1,a1,a2,a2,a3,a3,a1,a1,a2,a2,a3,a3... The pattern may change but I will always know how many times each element repeats and all elements repeats the same number of times. And the elements always show up in the same order. so another pattern might be a1,a1,a1,a2,a2,a2,a3,a3,a3,a1,a1,a1,a2,a2,a2,a3,a3,a3... or a1,a2,a3,a1,a2,a3 it will never be a2,a2,a1,a1,a3,a3... or a1,a2,a3,a2,a3,a1 etc How I determine what element is at any index in the list?

    Read the article

  • Java: Extend SimpleDateFormat with new pattern letters

    - by Adam Matan
    Java's SimpleDateFormat is used to format a Date object to a string. The formatter supports various pattern letters, which denote textual representation of a Date field. For example, yy is two-letter year, yyyy is four-letter year, and E is day of week. For example, A SimpleDateFormat initialized with yyyy.MM.dd G 'at' HH:mm:ss z will format a date to something like 2001.07.04 AD at 12:08:56 PDT. I would like to add some pattern letters to SimpleDateFormat. For example, want C to denote Hebrew weekday (??? ?????, ??? ???, ...). What's the right way to extend SimpleDateFormat with these new pattern letters? The only online example I could find seems somewhat complicated. I can live with formatting only, without parsing.

    Read the article

  • Session State Anti-Pattern

    - by Curiosity
    I know the SOLID principles and other design patterns fairly well and have been programming for some time now - seeing many a bit of code throughout the years. Having said that, I'm having trouble coming up with a name to give the pattern, or lack thereof, to bits of code I've been dealing with at a current engagement. The application is an ASP.NET C# WebForms application, backed by a SQL Server/Mainframe backend (more mainframe than backend) and it's riddled with Session State properties being accessed/mutated from multiple pages/classes. Accessing/mutating global variables/application state was usually shunned upon while I was in school. Apparently the creators of this magnificent application didn't think it was such a bad idea. Question: Is there a name for such a pattern/anti-pattern that relies so heavily on Session State? I'd like to call the pig by its name ...

    Read the article

  • tool for creating seamless pattern?

    - by Pennf0lio
    Hi, I'm a designer, that uses Illustrator and Photoshop to create my artworks. Now I know it can be done in photshop and illustrator but the process is kinda time consuming, You have to keep adjusting the position just to achieve seamless pattern. Now if there a software or plugin that will make your life easy, I would definitely would like to know. Thanks!

    Read the article

  • Can I autofill a pattern that changes periodically?

    - by user234479
    I am trying to create an autofill similar to below, essentially requiring excel to realise that every 3 cells down the row number being referenced increases by 10. I have tried but it does not seem to recognise the pattern. Is there any way around this? ='Book1'!$A1:$D17 ='Book1'!$A1:$D17 ='Book1'!$A1:$D17 ='Book1'!$A11:$D17 ='Book1'!$A11:$D17 ='Book1'!$A11:$D17 ='Book1'!$A21:$D17 ='Book1'!$A21:$D17 ='Book1'!$A21:$D17

    Read the article

  • Is this a pattern? Proxy/delegation of interface to existing concrete implementation

    - by Ian Newson
    I occasionally write code like this when I want to replace small parts of an existing implementation: public interface IFoo { void Bar(); } public class Foo : IFoo { public void Bar() { } } public class ProxyFoo : IFoo { private IFoo _Implementation; public ProxyFoo(IFoo implementation) { this._Implementation = implementation; } #region IFoo Members public void Bar() { this._Implementation.Bar(); } #endregion } This is a much smaller example than the real life cases in which I've used this pattern, but if implementing an existing interface or abstract class would require lots of code, most of which is already written, but I need to change a small part of the behaviour, then I will use this pattern. Is this a pattern or an anti pattern? If so, does it have a name and are there any well known pros and cons to this approach? Is there a better way to achieve the same result? Rewriting the interfaces and/or the concrete implementation is not normally an option as it will be provided by a third party library.

    Read the article

  • Relationship between "Task Parallel Library" and "Task-based Asynchronous Pattern"?

    - by Sid
    In the context of C#, .NET 4/4.5 used for an application running on a web-server, what is the relationship between "Task Parallel Library" and "Task-based Asynchronous Pattern"? I understand one is a library and the other is a pattern. But to dig deeper, is it like "The library is used by the pattern to enforce good practices". I'm also not clear if both are supported in .NET 4.0 (with awake and async keywords) Edit: Seems that awake and async are only in .NET 4.5 ...

    Read the article

  • Android Quick Actions UI Pattern

    - by Jeremy Edwards
    I'm interesting in incorporating the Android UI pattern called "Quick Action". Basically, it's a context menu that doesn't cover up the data that is being acted on. I'd like to implement this but I cannot find an API to help me out or some sample code. Note this UI pattern is discussed in the YouTube video, http://www.youtube.com/watch?v=M1ZBjlCRfz0 at time 15:35. Does anyone have an implementation of this or know what google's standard for adding this to an application?

    Read the article

  • Singleton pattern in web applications

    - by ryudice
    I'm using a singleton pattern for the datacontext in my web application so that I dont have to instantiate it every time, however I'm not sure how web applications work, does IIS open a thread for every user connected? if so, what would happend if my singleton is not thread safe? Also, is it OK to use a singleton pattern for the datacontext? Thanks.

    Read the article

  • A pattern matching an expression that doesn't end with specific sequence

    - by patryk
    I need a regex pattern which matches such strings that DO NOT end with such a sequence: \.[A-z0-9]{2,} by which I mean the examined string must not have at its end a sequence of a dot and then two or more alphanumeric characters. For example, a string /home/patryk/www and also /home/patryk/www/ should match desired pattern and /home/patryk/images/DSC002.jpg should not. I suppose this has something to do with lookarounds (look aheads) but still I have no idea how to make it. Any help appreciated.

    Read the article

  • Android: ViewHolder pattern and different types of rows?

    - by tomash
    ViewHolder pattern improves ListView scrolling framerate, as seen in following example: http://developer.android.com/intl/de/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html Is it possible to keep this pattern while using different kind of Views for different rows? In other words, is it possible to do something like: public View getView(int position, View view, ViewGroup parent) { // calculate viewID here if (view == null || *view is not null but was created from different XML than viewID* ) { view = mInflater.inflate(viewId, null);

    Read the article

  • Rosetta Stone: Observer Pattern

    - by Shiftbit
    How is the Observer Pattern expressed in various programming languages? Can you provide a code snippet that illustrates the major differences in each language. This post is intended to demonstrate the differences of this commonly used design pattern. I will start this off with a Java example. Remember to start your answer off with the language being demonstrated.

    Read the article

  • C# - Name the Design Pattern

    - by nettguy
    Using Fluent Interface design here if i call something like dog.Train("Running").Train("Eating").Do("Running").Do("Eating"); what is the name of this pattern ? is it chain-of-responsibility or there any specific design pattern name associated with it?

    Read the article

  • Generating a URL pattern when provided a set of 5 or so URLs

    - by ryan
    Provided with a set of URLs, I need to generate a pattern, For example: http://www.buy.com/prod/disney-s-star-struck/q/loc/109/213724402.html http://www.buy.com/prod/samsung-f2380-23-widescreen-1080p-lcd-monitor-150-000-1-dc-8ms-1920-x/q/loc/101/211249863.html http://www.buy.com/prod/panasonic-nnh765wf-microwave-oven-countertop-1-6-ft-1250w-panasonic/q/loc/66357/202045865.html http://www.buy.com/prod/escape-by-calvin-klein-for-women-3-4-oz-edp-spray/q/loc/66740/211210860.html http://www.buy.com/prod/v-touch-8gb-mp3-mp4-2-8-touch-screen-2mp-camera-expandable-minisd-w/q/loc/111/211402014.html Pattern is http://www.buy.com/prod/[^~]/q/loc/[^~].html

    Read the article

  • view handler design pattern

    - by Mark Roberts
    I'm trying to figure out the origin of the view handler design pattern in software engineering. Many of the design patterns in software engineering were inspired by things which pre-date computers, and I was wondering if anybody had any insights on the origin of this particular pattern.

    Read the article

  • Singleton Pattern for C#

    - by cam
    I need to store a bunch of variables that need to be accessed globally and I'm wondering if a singleton pattern would be applicable. From the examples I've seen, a singleton pattern is just a static class that can't be inherited. But the examples I've seen are overly complex for my needs. What would be the very simplest singleton class? Couldn't I just make a static, sealed class with some variables inside?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >