Search Results

Search found 1010 results on 41 pages for 'reuse'.

Page 6/41 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Caching result of SELECT statement for reuse in multiple queries

    - by Andrew
    I have a reasonably complex query to extract the Id field of the results I am interested in based on parameters entered by the user. After extracting the relevant Ids I am using the resulting set of Ids several times, in separate queries, to extract the actual output record sets I want (by joining to other tables, using aggregate functions, etc). I would like to avoid running the initial query separately for every set of results I want to return. I imagine my situation is a common pattern so I am interested in what the best approach is. The database is in MS SQL Server and I am using .NET 3.5.

    Read the article

  • reuse generators

    - by wiso
    I need to check the central limit with dices. Rool D dices. Sum the results. Repeat the same thing for N times. Change D and repeat. There's no need to store random values so I want to use only generators. The problem is that generators are consuming, I can't resuging them more times. Now my code use explicit for and I don't like it. dice_numbers = (1, 2, 10, 100, 1000) repetitions = 10000 for dice_number in dice_numbers: # how many dice to sum sum_container = [] for r in range(repetitions): rool_sum = sum((random.randint(1,6) for _ in range(dice_number))) sum_container.append(rool_sum) plot_histogram(sum_container) I want to create something like for r in repetitions: rools_generator = (random.randint(1,6) for _ in range(dice_number) sum_generator = (sum(rools_generator) for _ in range(r)) but the second time I resuse rools_generator it is condumed. I need to construct generator class?

    Read the article

  • how to reuse a CASE in the WHERE ?

    - by Thibault Witzig
    Hello I'm trying to do a request that looks like this SELECT field1, field2, field3 = CASE WHEN field2 = 'something' THEN 'something' WHEN field1 IS NOT NULL and field2 IS NULL THEN 'somethingElse' ELSE NULL END FROM SomeTable WHERE field3 IS NOT NULL This results in a syntax error. I have to rewrite the CASE in the WHERE instead of just refering to it. Is there a better way to achieve this ? And out of curiosity, why is "WHERE field3 IS NOT NULL" refused while for example "ORDER BY field3" would pass ?

    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

  • Is there a website to lookup common, already written functions?

    - by pinnacler
    I'm sitting here writing a function that I'm positive has been written before, somewhere on earth. It's just too common to have not been attempted, and I'm wondering why I can't just go to a website and search for a function that I can then copy and paste into my project in 2 seconds, instead of wasting my day reinventing the wheel. Sure there are certain libraries you can use, but where do you find these libraries and when they are absent, is there a site like I'm describing? Possibly a wiki of some type that contains free code that anybody can edit and improve?

    Read the article

  • Re-using Buttons in WPF

    - by Alex Marshall
    I have a bunch of different objects that are commonly edited in the same TabControl using different DataTemplates, but I want each DataTemplate to have a common look and feel with Ok and Cancel buttons at the bottom right of each tab that will close the tab or save the content and then close the currently selected tab. What's the best way to place buttons on each tab ? Is there a way to do it without copying and pasting the buttons and stack panel across all of my data templates ?

    Read the article

  • XSLT: Is there a way to "inherit" canned functionality?

    - by Ian Boyd
    i am once again having to cobble together a bit of XSLT into order to turn generated XML into (rather than simply generating HTML). i'm having huge deja-vu this time again. i'm once again having to solve again basic problems, e.g.: how to convert characters into valid html entity references how to preserve whitespace/carriage returns when converting to html how to convert to HTML as opposed to xhtml how to convert dates from xml format into presentable format how to tear apart strings with substring This is all stuff that i've solved many times before. But every time i come back to XSLT i have to start from scratch, re-inventing the wheel every time. If it were a programming language i would have a library of canned functions and procedures i can call. i would have subroutines to perform the commonly repeated tasks. i would inherit from a base class that already implements the ugly boilerplate stuff. Is there any way in XSLT to grow, expand and improve the ecosystem with canned code?

    Read the article

  • Benefits of migrating my work to a new web development framework?

    - by John
    When I first started programming with PHP, I was ignorant of other php frameworks (like code igniter, cake php, etc...). So I fell into the trap of re-inventing wheels, which had the benefit of being "fun" and "educational". Overtime, I discovered other open source products that I found useful, like smarty templating engine, jquery library, tcpdf library, fdf etc...so I started bundling these technologies along with things I've built over the years into a LAMP development framework to make life easier for myself. This pass year, I've been having fun developing on the code igniter framework. It does many of the things I do in my framework. Coding in CI feels natural because the MVC and ORM feels similar to the MVC and ORM of my framework. So now I'm contemplating migrating a lot of the plugins in my framework over to CI. The pros and cons I can think of for such a project are: Pros: benefit from the vast community of CI developers lots of other developers will be familiar with it better documentation Cons: I've built a lot of useful plugins against my own framework, and it will take a lot of time to move even just the essential ones at the moment, I still, work faster against my own framework than CI, just because I'm more familiar with it even if I did migrate to CI, there will always be newer and better frameworks in the near future, and i'll be contemplating this scenario again So my question is the following: perhaps I should leave my old framework as is, and for each new project I receive, I make a decision on whether the requirements are best served by developing with CI or my own framework. Is this the right approach?

    Read the article

  • Is there a website to look up common, already written functions?

    - by pinnacler
    I'm sitting here writing a function that I'm positive has been written before, somewhere on earth. It's just too common to have not been attempted, and I'm wondering why I can't just go to a website and search for a function that I can then copy and paste into my project in 2 seconds, instead of wasting my day reinventing the wheel. Sure there are certain libraries you can use, but where do you find these libraries and when they are absent, is there a site like I'm describing? Possibly a wiki of some type that contains free code that anybody can edit and improve? Edit: I can code things fine, I just don't know HOW to do them. So for example, right now, I'm trying to localize a robot/car/point in space. I KNOW there is a way to do it, just based off of range and distance. Triangulation and Trilateration. How to code that is a different story. A site that could have psuedo code, step by step how to do that would be ridiculously helpful. It would also ensure the optimal solution since everybody can edit it. I'm also writing in Matlab, which I hate because it's quirky, adding to my desire for creating a website like I describe.

    Read the article

  • Content Management Systems for Adaptive Content [closed]

    - by andrewap
    Content management systems (CMS) allow us to easily maintain blogs, news sites, general websites, and so on. Many of them are designed to manage pages of content, and provide tools to organize and customize how that content is displayed on the web. However, as explained by Mark Boulton in his Adaptive Content Management article, and by Karen McGrane in her talk on Adapting Ourselves to Adaptive Content, we are increasingly delivering content not just to the web, but also to other platforms and channels. We need tools to manage pieces of content with meaningful metadata attached. Create once, publish everywhere. The main idea is to store content cleanly, without intertwining it with presentation markup specific to the web. Because pieces of content is compartmentalized semantically, it can easily adapt to fit in different platforms and channels. Hence, it's called adaptive content. Let's look at a quick example to compare: Say I manage news articles and events. To create a news article, I would tell the CMS the type of content I'm creating, and be asked to fill in a form with individual fields tailored to news articles (e.g. headline, subtitle, full text, short snippet, and images). — i.e. pieces of content With a traditional web publishing tool, I would probably have had to create a new page under News, and then type in and format the news article in a blank WYSIWYG text editor. — i.e. pages of content As you can see, the first design allows me to individually specify content in its smallest semantic unit. When I want to display or consume it, the system can easily provide the pieces I need. So here's my question: Is there a CMS that is designed specifically with adaptive content in mind, and that is decoupled with the presentation layer? Note: This is not a discussion about the best CMS, or which CMS I should use. I am asking whether a very specific type of tool — CMS designed for adaptive content — exists for developers to use.

    Read the article

  • Visual Studio: What approach do you use to 'template' plumbing for similiar projects?

    - by Sosh
    When building ASP.NET projects there is a certain amount of boilerplate, or plumbing that needs to be done, which is often identical across projects. This is especially the case with MVC and ALT.NET approaches. [I'm thinking of things such as: IoC, ORM, Solution structure (projects), Session Management, User Management, I18n etc.] I would like to know what approach you find best for 'reusing' this plumbing accross projects? Have a 'master solution' which you duplicate and rename somehow? (I'm using a this to a degree at the moment, but it's fairly messy. Would be interested how people do this 'better') Mainly rely on Shared Library projects? (I find this appropriate for some things, but too restrictive for things that have to be customised) Code generation tools, such as T4? (Similar to the approach used by SharpArchitecture - have not tried this myself) Something else? Thanks for sharing your experiences!

    Read the article

  • Jquery Basic Beginner Question: How do i make my function reusable?

    - by obikodi
    I have spent the last few hours attempting to do this on my own, and using Google to find a solution but to no avail. So if you can help out i would super appreciate it! Basically I have a page which has 3 separate biographies in 'preview mode', which shows only the first paragraph of each bio. When you click on 'read more' for one bio it opens up the 'full mode'. What is happening at the moment, is if i click on one 'read more' link, it opens up the full mode on all 3 bio's. How do i edit the following code so; It only opens the full mode bio of the link i click on Make it reusable so i don't have to duplicate the code 3 times for each bio $("a#btnReadMore").click(function(){ $('.readMoreSlider').slideToggle("fast"); $(this).toggleClass("readMoreSliderActive"); return false; }); Thanks for your help!

    Read the article

  • What does a WinForm application need to be designed for usability, and be robust, clean, and profess

    - by msorens
    One of the principal problems impeding productivity in software implementation is the classic conundrum of “reinventing the wheel”. Of late I am a .NET developer and even the wonderful wizardry of .NET and Visual Studio covers only a portion of this challenging issue. Below I present my initial thoughts both on what is available and what should be available from .NET on a WinForm, focusing on good usability. That is, aspects of an application exposed to the user and making the user experience easier and/or better. (I do include a couple items not visible to the user because I feel strongly about them, such as diagnostics.) I invite you to contribute to these lists. LIST A: Components provided by .NET These are substantially complete components provided by .NET, i.e. those requiring at most trivial coding to use. “About” dialog -- add it with a couple clicks then customize. Persist settings across invocations -- .NET has the support; just use a few lines of code to glue them together. Migrate settings with a new version -- a powerful one, available with one line of code. Tooltips (and infotips) -- .NET includes just plain text tooltips; third-party libraries provide richer ones. Diagnostic support -- TraceSources, TraceListeners, and more are built-in. Internationalization -- support for tailoring your app to languages other than your own. LIST B: Components not provided by .NET These are not supplied at all by .NET or supplied only as rudimentary elements requiring substantial work to be realized. Splash screen -- a small window present during program startup with your logo, loading messages, etc. Tip of the day -- a mini-tutorial presented one bit at a time each time the user starts your app. Check for available updates -- facility to query a server to see if the user is running the latest version of your app, then provide a simple way to upgrade if a new version is found. Maximize to multiple monitors -- the canonical window allows you to maximize to a single monitor only; in my apps I allow maximizing across multiple monitors with a click. Taskbar notifier -- flash the taskbar when your backgrounded app has new info for the user. Options dialogs -- multi-page dialogs letting the user customize the app settings to his/her own preferences. Progress indicator -- for long running operations give the user feedback on how far there is left to go. Memory gauge -- an indicator (either absolute or percentage) of how much memory is used by your app. LIST C: Stylistic and/or tiny bits of functionality This list includes bits of functionality that are too tiny to merit being called a component, along with stylistic concerns (that admittedly do overlap with the Windows User Experience Interaction Guidelines). Design a form for resizing -- unless you are restricting your form to be a fixed size, use anchors and docking so that it does what is reasonable when enlarged or shrunk by the user. Set tab order on a form -- repeated tab presses by the user should advance from field to field in a logical order rather than the default order in which you added fields. Adjust controls to be aware of operating modes -- When starting a background operation with, for example, a “Go” button, disable that “Go” button until the operation completes. Provide access keys for all menu items (per UXGuide). Provide shortcut keys for commonly used menu items (per UXGuide). Set up some (global or important or common) shortcut keys without associating to menu items. Allow some menu items to be invoked with or without modifier keys (shift, control, alt) where the modifier key is useful to vary the operation slightly. Hook up Escape and Enter on child forms to do what is reasonable. Decorate any library classes with documentation-comments and attributes -- this allows Visual Studio to leverage them for Intellisense and property descriptions. Spell check your code! What else would you include?

    Read the article

  • Android: Custom Clock widget Service work-around?

    - by Anthony Forloney
    I was interested in developing a clock widget for the homescreen and upon reading Home Screen Widgets tutorial, is there a pre-existing Service I could reference for updating the current time rather than re-inventing the wheel? I have currently Retro Clock on my android phone and noticed that when I click it, it pops up the Alarm Clock settings, but with the default Google Analog Clock widget, upon click does nothing. Is that because the Retro Clock widget implements the Alarm Clock service? If so, how can I go about referencing that service? Or do I have this all wrong and misunderstood? Any help is appreciated. EDIT: I believe implementing the service to update the clock would drain the battery life tremendously, any ideas on a work around or help shed some light on any performance issues with using Service?

    Read the article

  • Using the same CArchive object for archive and un-archive

    - by bdhar
    Following is a sample code: CFile serFile; serFile.Open(_T("Person.ser"), CFile::modeCreate | CFile::modeWrite); CArchive writer(&serFile, CArchive::store); me.Serialize(writer); writer.Close(); serFile.Close(); serFile.Open(_T("Person.ser"), CFile::modeRead); CArchive reader(&serFile, CArchive::load); CPerson clone; clone.Serialize(reader); reader.Close(); serFile.Close(); Here, I have a writer which archives the object me. Then, I use another CArchive object reader to un-archive it. Is it possible to re-construct or set any property of writer to make it, the reader instead of declaring another CArchive object reader? Thanks.

    Read the article

  • Is there a website to lookup already common code functions?

    - by pinnacler
    I'm sitting here writing a function that I'm positive has been written before, somewhere on earth. It's just too common to have not been attempted, and I'm wondering why I can't just go to a website and search for a function that I can then copy and paste into my project in 2 seconds, instead of wasting my day reinventing the wheel. Sure there are certain libraries you can use, but where do you find these libraries and when they are absent, is there a site like I'm describing?

    Read the article

  • C# Debug.Assert-s use the same error message. Should I promote it to a static variable?

    - by Hamish Grubijan
    I love Asserts but not code duplication, and in several places I use a Debug.Assert which checks for the same condition like so: Debug.Assert(kosherBaconList.SelectedIndex != -1, "An error message along the lines - you should not ever be able to click on edit button without selecting a kosher bacon first."); This is in response to an actual bug, although the actual list does not contain kosher bacon. Anyhow, I can think of two approaches: private static readonly mustSelectKosherBaconBeforeEditAssertMessage = "An error message along the lines - you should not ever be able to " + "click on edit button without selecting a something first."; ... Debug.Assert( kosherBaconList.SelectedIndex != -1, mustSelectKosherBaconBeforeEditAssertMessage) or: if (kosherBaconList.SelectedIndex == -1) { AssertMustSelectKosherBaconBeforeEdit(); } ... [Conditional("DEBUG")] private void AssertMustSelectKosherBaconBeforeEdit() { // Compiler will optimize away this variable. string errorMessage = "An error message along the lines - you should not ever be able to " + "click on edit button without selecting a something first."; Debug.Assert(false, errorMessage); } or is there a third way which sucks less than either one above? Please share. General helpful relevant tips are also welcome.

    Read the article

  • How to use interfaces in exception handling

    - by vikp
    Hi, I'm working on the exception handling layer for my application. I have read few articles on interfaces and generics. I have used inheritance before quite a lot and I'm comfortable with in that area. I have a very brief design that I'm going to implement: public interface IMyExceptionLogger { public void LogException(); // Helper methods for writing into files,db, xml } I'm slightly confused what I should be doing next. public class FooClass: IMyExceptionLogger { // Fields // Constructors } Should I implement LogException() method within FooClass? If yes, than I'm struggling to see how I'm better of using an interface instead of the concrete class... I have a variety of classes that will make a use of that interface, but I don't want to write an implementation of that interface within each class. In the same time If I implement an interface in one class, and then use that class in different layers of the application I will be still using concrete classes instead of interfaces, which is a bad OO design... I hope this makes sense. Any feedback and suggestions are welcome. Please notice that I'm not interested in using net4log or its competitors because I'm doing this to learn. Thank you Edit: Wrote some more code. So I will implement variety of loggers with this interface, i.e. DBExceptionLogger, CSVExceptionLogger, XMLExceptionLogger etc. Than I will still end up with concrete classes that I will have to use in different layers of my application.

    Read the article

  • How to reference a class that implements certain interface?

    - by vikp
    Hi, I have an interface for logging the exceptions, i.e. IExceptionLogger. This interface has 3 implementations: DBExceptionLogger, XMLExceptionLogger, CSVExceptionLogger. I have an application that will make a use of DBExceptionLogger. The application references only IExceptionLogger. How do I create an instance of DBExceptionLogger within the application. I can't reference the DBExceptionLogger directly since it will break the purpose of having IExceptionLogger interface. Thanks

    Read the article

  • Debug.Assert-s use the same error message. Should I promote it to a static variable?

    - by Hamish Grubijan
    I love Asserts and code readability but not code duplication, and in several places I use a Debug.Assert which checks for the same condition like so: Debug.Assert(kosherBaconList.SelectedIndex != -1, "An error message along the lines - you should not ever be able to click on edit button without selecting a kosher bacon first."); This is in response to an actual bug, although the actual list does not contain kosher bacon. Anyhow, I can think of two approaches: private static readonly mustSelectKosherBaconBeforeEditAssertMessage = "An error message along the lines - you should not ever be able to " + "click on edit button without selecting a something first."; ... Debug.Assert( kosherBaconList.SelectedIndex != -1, mustSelectKosherBaconBeforeEditAssertMessage) or: if (kosherBaconList.SelectedIndex == -1) { AssertMustSelectKosherBaconBeforeEdit(); } ... [Conditional("DEBUG")] private void AssertMustSelectKosherBaconBeforeEdit() { // Compiler will optimize away this variable. string errorMessage = "An error message along the lines - you should not ever be able to " + "click on edit button without selecting a something first."; Debug.Assert(false, errorMessage); } or is there a third way which sucks less than either one above? Please share. General helpful relevant tips are also welcome.

    Read the article

  • Using a message class static method taking in an action to wrap Try/Catch

    - by Chris Marisic
    I have a Result object that lets me pass around a List of event messages and I can check whether an action was successful or not. I've realized I've written this code in alot of places Result result; try { //Do Something ... //New result is automatically a success for not having any errors in it result = new Result(); } catch (Exception exception) { //Extension method that returns a Result from the exception result = exception.ToResult(); } if(result.Success) .... What I'm considering is replacing this usage with public static Result CatchException(Action action) { try { action(); return new Result(); } catch (Exception exception) { return exception.ToResult(); } } And then use it like var result = Result.CatchException(() => _model.Save(something)); Does anyone feel there's anything wrong with this or that I'm trading reusability for obscurity?

    Read the article

  • Add Method to Built In Class

    - by Evorlor
    I am pretty sure this is not doable, but I will go ahead and cross my fingers and ask. I am trying to add a method to a built in class. I want this method to be callable by all of the built in class's subclasses. Specifically: I have a JButton, a JTextPane, and other JComponents. I want to be able to pass in a JDom Element instead of a Rectangle to setBounds(). My current solution is to extend each JComponent subclass with the desired methods, but that is a LOT of duplicate code. Is there a way I can write the following method just one time, and have it callable on all JComponent objects? Or is it required that I extend each subclass individually, and copy and paste the method below? public void setBounds(Element element) { this.setBounds(Integer.parseInt(element.getAttribute( "x").toString()), Integer.parseInt(element .getAttribute("y").toString()), Integer .parseInt(element.getAttribute("width").toString()), Integer.parseInt(element.getAttribute("height") .toString())); }

    Read the article

  • Qt Should I derive from QDataStream?

    - by ShaChris23
    I'm currently using QDataStream to serialize my classes. I have quite a few number of my own classes that I serialize often. Should I derive QDataStream to create my own DataStream class? Or is there a better pattern than this? Note that these custom classes are used by many of our projects, so maybe doing so will make coding easier. Another way to phrase this question is: when a framework provides you with a serialization class, how do you handle serializing your own custom-type classes such that you don't have to remember how to serialize them everytime.

    Read the article

  • How do I reuse a state machine in a slightly different way?

    - by JoJo
    Problem I have a big state machine. The design requirements of the project have changed such that I need to re-use this state machine in another place. All the states remain the same in this new place, but a few states run slightly different stuff. What design pattern allows me to reuse this state machine? Motivation I am building a video player. It is modeled by a state machine with these states: stopped, loading, playing, paused, crashed, and some more... This video player needs to be used on two web pages. When the player crashes on the first page, it should show an error message below. If the player crashes on the second page, the error message should appear in the center of the video and pulsate a few times.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >