code-reuse

What is the best way to reuse classes from another Java project in Eclipse?

I have multiple Java projects in Eclipse. I would like to reuse some classes in my new project from my old project. What is the best way to do that in Eclipse? I.e. is it possible to add another "project folder" to the build-path for my new project? ...

How to use interfaces in exception handling

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

How to reference a class that implements certain interface?

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

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

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

How do I reuse code in Zend Framework

I am working on a web application which requires the user to login before they see or do anything. No part of this app should be accessible without being logged in. (Except of course, the login controller) Currently I am using sessions to handle the authentication and I have put code in each controller in the init() function to check i...

WPF style/control template reuse

Hi, I'm new to WPF, and I would like to know how to reuse some annoying xaml I have to avoid duplicating. <Button Cursor="Hand" HorizontalAlignment="Left" Margin="0,0,0,0" x:Name="MyButton" Style="{StaticResource ButtonTemplate}" Width="286" Content="hi!" Focusable="False" IsTabStop="False"/> <Button Cursor="Hand" HorizontalAlignment="L...

Is it possible to reuse GWT UIBinder panels?

I have a layout in Google Web Toolkit using UIBinder involving a TabLayoutPanel. This layout has the superset of all tabs that will be used by my app (think of it as an admin view). I now need to create a new layout, using a subset of these tabs (eg, for regular users). Is it possible to import panels from my admin layout in my user...

resusable function in codeigniter

Almost in all function in most of my controller i have to see to same things. i.e 1.Check if logged in. 2.Check the privilege. I know how to do it. But what is the best way, so that i don't have to re-write the same code everywhere? Is it to make a helper or something? I'm a bit new to codeigniter, all i know is basic php! ...

Reusable jquery ajax requests...

I am developing a web application using asp.net mvc... I am listing out the details of Clients,Staff,Reports via ajax requests using jquery... What i am doing is writing seperate functions(jquery ajax requests) for each actions (ie) view,add,edit,Delete ... //Clients function getClients(currentPage) { $.ajax({ url: "Clients/...

Split string with quotes, reusing method that parses arguments to main

Hi there, in small program I'm writing, I have to parse a line of user input. Basically what needs to be done is to split the line into an array of strings in the same way as is done with the arguments to main(), ie I'm looking for something like this: String[] splitArgs(String cmdLine); I just wonder, if the main methods' arguments ...

How to store reusable code in Visual Studio 2010?

Is there any way I could save my block of code in Visual Studio 2010 and reuse it in my future web applications without having to "Add existing files"? Is there a feature in VS2010 that lets you globally store these blocks of code? Thanks! ...

Measuring code reusability

I am trying to measure how much of the code produced in our organisation is actually reusable and I'd like to set some guidelines. I'd like to have some reference to outer world: How much code is typically reused in a single application ? More specifically - if we consider all the code of a complete end-user product (and eventually excl...

Where to start to build a real codebase from scratch?

Hi, Currently, I have a more or less organized set of projects I work or worked on. Some are refactored, documented and unit-tested, others are not. When I want to reuse a code I've written before, I spend a few minutes searching for the project where I've written this code, than copy-paste this code to a new one, refactoring, document...

Reuse tips for Android

Android resources and their automatically generated references simplify the development of one app a great deal. But they also complicate the reuse of Android activities in multiple projects, and in general of any component that uses resources. Library projects are a limited alternative. A project can depend on many library projects, bu...

Adding features to code bases which are in dire need of refactoring

I am developing on a system that is a bit difficult to work with. It is 99% undocumented, does not follow best practices and is fairly difficult to understand (globals galore, methods spanning 50 lines, eval abuse, etc.). Unfortunately, I am fairly new to the code base and I need to add functionality. I am sure there is code in there th...

Best approach to build reusable C# data integration assemblies

How have you addressed the issues when building a reuseable suite of C# data integration assemblies? We're a Microsoft shop using Sql Server and C#. We're consolidating a lot of our DB integration code into C# assemblies. In doing so we're hitting a number of common problems. 1) We like the source/destination flexibility of SSIS and th...

Organizing, Storing, and Keeping Track of code for reuse

Many moons ago I started storing my music as MP3’s. I downloaded like mad and just dumped them all into a folder. After collecting thousands of songs I had a big mess. After two years of organizing all music in my free time I have made it to “D” section of my library. I am starting to write code on a daily basis and I would like to k...

How to make these 2 blocks of almost identical code reusable?

I need advice on what I need to do to make the following two blocks of code reusable. I have to produce another table of funds and while I'm doing that, I'd like to create FundsTable.ascx partial view that all Views that need to display a fund table can use. // Inherits="System.Web.Mvc.ViewPage<CompanyViewModel> // this is a company <%f...

What is a good strategy for seprating layers for an appication that can be used online and offline?

I have a Java web application that has a 'disconnected' Java Swing desktop app. Using the desktop app users connect to the internet and download data they need from a server. They can disconnect and use the application offline. When they reconnect to the internet they can sync their data back to the server. The server itself is a Java...

Avoid reinventing the wheel, mental process you use to force yourself not to rewrite existing code.

Need help here, I'm a coder who has always felt the weight of a tremendously strong force pushing him to reinvent the wheel. It was so strong that I was nearly trying to reinvent jQuery lately [Note] and this really made me think. I read also these well written articles, but they don't give any practical suggestions to follow in order...