code-reuse

Is there a way to access Visual Studio's CodeSnippet framework to manipulate snippets programmatically?

I'm working on a project that is going to be heavily templated, but the templates I'm creating might also work well in future projects as CodeSnippets for Visual Studio. So, I was wondering, is there a way to access Visual Studio's system of loading, parsing, and displaying the CodeSnippets in any way, shape, or form? For example, it ...

Javascript code as a variable

Ok, this may sound a bit crazy but hear me out :) I would like to do the following in javascript: define START_OF_EVERY_FUNCTION = "try {" define END_OF_EVERY_FUNCTION = "} catch () {}" function TEST () { START_OF_EVERY_FUNCTION // rest of function END_OF_EVERY_FUNCTION } Basically, can I define a list of javascript li...

Wrapping a non-generic Django view

I want to inject one additional variable into the context of a view that belongs to a 3rd-party application without editing the code of that application. Is there a way to do this by wrapping the (non-generic) view? It doesn't accept an extra_context parameter, so the approach described in this SO thread won't work. I know I could create...

Qt Should I derive from QDataStream?

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. An...

Python/Django application with dynamic model name (application reuse)

Hi, excuse me in advance if this is not the right title for the problem but here it is: You have application that works with pre defined model. What happens if you want to use this application one more time in your project but pointing to different model (same structure but differen name). For example - you have a "News" application ...

Re-using Buttons in WPF

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 w...

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

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 w...

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

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()...

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

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 lib...

How can I write reusable Javascript?

I've started to wrap my functions inside of Objects, e.g.: var Search = { carSearch: function(color) { }, peopleSearch: function(name) { }, ... } This helps a lot with readability, but I continue to have issues with reusabilty. To be more specific, the difficulty is in two areas: Receiving parameters. A lot of times I wi...

Decouple a JPA entities jar from persistence.xml in SE environment

Is there a way to reuse a jar with JPA annotated entities in more than one SE applications (as a dependency)? <jar-file> in persistence.xml is not supported in SE environments so is there another way? ...

XSL Reuse? YES! But: Element must not contain an xsl:import element! :-(

I am using a heavy stylesheet with a lot of recurring transformations, so I thought it would be smart to reuse the same chunks of code, so I would not need to make the same changes at a bunch of different places. So I discovered , but -alas- it won't allow me to do it. When trying to run it in Sonic Workbench I get the following error: ...

Reusable view components in HTML

Can you create reusable components in html? Let's say I want to encapsulate some css / html and js into a tidy reusable component. How do web developers do this? I'm coming from the Flex, C# side of the planet. ...

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

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...

Reusable architectural code management

Our code is in Java and Javascript (AJAX libraries). We have wrappers/reusable code around the existing libraries to perform mundane tasks like, db connections, session management, logging, hibernate settings, base structure, some reusable multitenancy code etc.. From the javascript end, we have page initializers, UI layout components, c...

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

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. Su...

Copy Paste vs. Reference

My question is in regard to referencing open source frameworks. There are many of them for many different purposes. I personally leverage several of them in a single project. For example: Unity CAL/Prism ValidationAspects EnterpriseLibrary Logging EnterpriseLibrary Exception Handling EnterpriseLibrary Caching Caliburn All of these fr...

How can I reuse my javascript code between client and server?

I have some javascript code that includes an ANTLR-generated lexer and parser, and some associated syntax tree evaluation functionality. This code runs in the browser in my web app to support users who author code snippets which process scientific data. Now I'd like to do some additional background processing on the server using the sa...

.Net web architecture literature

Hi, Can somebody please advise a very advanced book on the architecture of the web application development, preferably in .Net I'm interested in patterns and designs, code security and re-usability I have studied a variety of books, but they all seem to be for beginner/intermediate levels. ...

Best ways to reuse Java methods

I'm learning Java and OOP, and have been doing the problems at Project Euler for practice (awesome site btw). I find myself doing many of the same things over and over, like: checking if an integer is prime/generating primes generating the Fibonacci series checking if a number is a palindrome What is the best way to store and call...