Questions tagged [code-reuse]

The use of existing software, or software knowledge, to build new software

875 questions
7
votes
4 answers

In PHP how do you create reusable objects?, is there a best practice to this? What do you prefer?

I am creating some reusable objects in php, and I wanted to know whats the best way to build them. Below I have 2 examples of different ways of doing this. Class Uploader{ public $Filename; public $Directory; function upload(){ …
anon
7
votes
4 answers

Does ColdFusion have an answer to ASP.NET's Master Pages?

I'm working on a website that was coded in ColdFusion. I have a CSS/HTML template I would like to apply to the content of every page, without duplicating any more code than necessary. I've gotten kind of spoiled by ASP.NET's master pages, which…
Joshua Carmody
  • 13,410
  • 16
  • 64
  • 83
7
votes
2 answers

How to interpret ObservableHq simple algorithms as reusable code snippets?

The main source of D3js solutions is observableHq.com, but seems impossible (?) to reuse algorithms by copy/paste... Is it? Even checking tutorials like this, there are no simple way (with less plugins or programmer's time-consumtion!) to check and…
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
7
votes
3 answers

Best practices for reusing methods across multiple components in Angular 8

Let's say I have a method that returns the percentage from two numbers: calculatePercentage(a, b) { return (((a - b) / b) * 100 * 2).toFixed(2); } Currently, I have this method on component controller. How do I make it reusable across…
f1vlad
  • 227
  • 3
  • 12
7
votes
1 answer

javascript BEST PRACTICE - managing scripts / code reuse

From reading many articles, such as How do I include a JavaScript file in another JavaScript file? - it is apparently not possible to include one script into another. So here's my question - I'm concerned about JS bloat. or having too much unused…
j-p
  • 3,698
  • 9
  • 50
  • 93
7
votes
9 answers

How to avoid code duplication

I have three C# methods that almost perform identically. More specifically there is a large amount of code repetition but at the end, they perform different functions. This is obviously very inefficient, so what's the best way to cut down on code…
Jonathan
  • 13,947
  • 17
  • 94
  • 123
7
votes
2 answers

How to reuse Core VBA functions (UDFs) across projects, but not show them in cell insert function

I have an Addin with "core" functions and subs that I want to reference and use in different Addins or VBA projects. Because of the code reuse and single update principles. For example, a function, that filters collection members based on criteria…
kolcinx
  • 2,183
  • 1
  • 15
  • 38
7
votes
4 answers

How can I cut a large Rails application into smaller applications that work together?

I have worked a bit with Django and I quite like its project/applications model : you can build a Django project by assembling one or more Django applications. These applications can be autonomous, or some applications can be built on top of other…
MiniQuark
  • 46,633
  • 36
  • 147
  • 183
7
votes
7 answers

How to organise large code files?

I am increasingly aware that my code in any single file can often span hundreds of lines quite easily and although I know the implementation might be sound, it still feels messy and unorganised. I understand that there are situations where a lot of…
Nobody
  • 4,731
  • 7
  • 36
  • 65
7
votes
4 answers

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”…
ubiquibacon
  • 10,451
  • 28
  • 109
  • 179
7
votes
2 answers

General frameworks for preparing training data?

As a student of computational linguistics, I frequently do machine learning experiments where I have to prepare training data from all kinds of different resources like raw or annotated text corpora or syntactic tree banks. For every new task and…
ferdystschenko
  • 1,527
  • 1
  • 9
  • 18
7
votes
3 answers

How do I deal with multiple common user interfaces?

I'm working on a python application that runs on 2 different platforms, namely regular desktop linux and Maemo 4. We use PyGTK on both platforms but on Maemo there are a bunch of little tweaks to make it look nice which are implemented as…
nikosapi
  • 71
  • 1
7
votes
3 answers

How can I reuse HTML/JSP within a page?

I'm new to JSP, and I'm trying to reduce a massive amount of cut-and-pasted code. On each page in the project, there are around 25 lines of mixed JSP,Struts tags,JSTL tags, and HTML, which have been cut and pasted at various points in the page.…
T.R.
  • 7,442
  • 6
  • 30
  • 34
7
votes
4 answers

C++ internal code reuse: compile everything or share the library / dynamic library?

General question: For unmanaged C++, what's better for internal code sharing? Reuse code by sharing the actual source code? OR Reuse code by sharing the library / dynamic library (+ all the header files) Whichever it is: what's your strategy for…
sivabudh
  • 31,807
  • 63
  • 162
  • 228
7
votes
3 answers

Html reuse without code

I am creating some static html pages outside a .net and outside a ruby-on-rails environment. I created a menu I want to share between several pages, but I'm wondering how this is done using regular html constructs (i.e. without .net's master pages…
Daniel
  • 16,026
  • 18
  • 65
  • 89