The use of existing software, or software knowledge, to build new software
Questions tagged [code-reuse]
875 questions
0
votes
2 answers
J2ME class in android project
I copied my port scanner class to my android project without changing anything in source code. Eclipse didn't complain about code, but my code just doesnt seem to work correctly in android. Here is my whole portscanner code.
import…

Rohit Malish
- 3,209
- 12
- 49
- 67
0
votes
1 answer
code reuse with an inline query inside a SP
This below is abstraction. Queries are much more complex. Principle exactly the same.
I have a Stored Procedure that does:
SELECT * FROM T1
WHERE T1.fk IN (SELECT id FROM T2);
In reality this inline query is very complex and is being used in many…

Itay Moav -Malimovka
- 52,579
- 61
- 190
- 278
0
votes
5 answers
Using System.Attribute class
I got myself in a situation where using the System.Attribute class seemed (at first glance) to be a good idea.
I have an object to be printed in my application, and I need a label before each property (or just a string before it). I could put each…

mkato
- 402
- 4
- 11
0
votes
3 answers
Trying to make a C++ (MFC) code snippet easy to reuse . What are the options?
I have found myself repeatedly writing the following function :
// This function will try to find the 'item' in 'array'.
// If successful, it will return 'true' and set the 'index' appropriately.
// Otherwise it will return false.
bool…

Wartin
- 1,965
- 5
- 25
- 40
-1
votes
2 answers
AuthorizeAttribute Reuse
I'm securing my MVC controllers with AuthorizeAttributes. Is there a way to instantiate those classes on its own?
At the moment I have an AuthorizedAdmin and a IsAdmin class which does the same. So ideally the IsAdmin should use the AuthorizedAdmin…

duedl0r
- 9,289
- 3
- 30
- 45
-1
votes
1 answer
Making Re-Usable Code
I have written a game engine in C++, however I would like to package it up in a file so I don't have to re-compile it every time I want to make a game. I read the MSDN articles on writing re-usable code, and putting it into managed Assembly or in a…

The Floating Brain
- 896
- 8
- 24
-1
votes
1 answer
Reactjs Component Reusability
I am working on a project in react. Where most of the data on different tabs have a table. So I design the "TableItems" component and passed the data according to the component. Right now based on params I toggle the table data. Is this the correct…

Hamid Shah
- 31
- 6
-1
votes
1 answer
Reuse function with return type always equal to the struct that is calling that function in golang
I'm trying to do in Golang something that would be easily done in Java with Type. For example:
public class MyClass> {
public Type myMethod() {
// Do something
return (Type) this;
}
}
public class…

Ocimar
- 53
- 1
- 6
-1
votes
2 answers
I've created this simple JS dice game where I run 2 dice
I want to hear suggestions on how to improve this code, there's probably a way that I can call the same function to get 2 different results? When I tried that, I got 2 dices printing the same result. Any other suggestion on how to make this look…

kaiorampz
- 1
- 2
-1
votes
1 answer
How to reuse States in Sparx EA
How would I go about re-using states in Sparx EA State Machine Diagrams?
For my application I have a defined list of States (StateA,StateB,StateC, etc) but different objects may transition between them in different manners,
i.e. ObjectA: StateA--(no…

David Gitz
- 13
- 3
-1
votes
2 answers
How to implement GestureDetector in reuseable class widget?
I am successfully able to make a reusable stateful widget and added text but don't know about how to make reusable gesture detector
class HomeScreen extends StatefulWidget {
final String collectionName;
HomeScreen(this.collectionName);
…

Chirag Chopra
- 132
- 1
- 7
-1
votes
2 answers
How can I remove duplicated code between classes without implements?
I wrote many implementations of a function to compute the Fibonacci number at a given position.
Fibonacci Class: this class helps me to test each implementation without rewrite same test code. I don't want to add "fibonacci(n - 2).add(fibonacci(n -…

Minh Ngo
- 289
- 2
- 9
-1
votes
1 answer
Inflating views dynamically across app
I have a few views used across my app, I am dynamically adding them to fragments.
The type of view is dependednt on server data so I can't use includes for the fragment layouts.
Each fragment can have a different composition of view e.g View 1, View…

AndroidEnthusiast
- 6,557
- 10
- 42
- 56
-1
votes
4 answers
How to write a reusable code in cakePHP?
Can any one provide me some tips to write reusable code in PHP / CakePHP?

RSK
- 17,210
- 13
- 54
- 74
-1
votes
3 answers
In C++, how to reuse the code when object relationship isn't intuitive?
Apologies if this is sort of vague, but I don't know how to go about code reuse in the following situation. I'm using C++.
The program is a simple simulation and it has a few different things in play.
struct StupidBug;
struct SmartBug;
struct…

djscrew
- 57
- 6