code-duplication

Java, loop through 2d array in any direction

Deadly 提交于 2019-12-24 12:51:59
问题 I'm trying to shift elements in an 2d array in any direction specified. By shift I mean, if left is pressed, each element of the array is moved as far to the left as it can. so this (0 indicated an empty space), 1 0 2 0 0 3 0 1 1 0 6 9 1 0 0 0 would become 1 2 0 0 3 1 0 0 1 6 9 0 1 0 0 0 This is sudo code of what I have for if 'up' is pressed; for col = 0 to SIZE for i = 0 to SIZE - 1 if array[i][col] == 0 for j = i to SIZE if array[j][col] != 0 array[i][col] = array[row][j] array[j][col] = 0

How to simultaneously scroll two windows?

蓝咒 提交于 2019-12-22 18:13:00
问题 I want to simultaneously scroll two windows, but the hotkey input method requires me to duplicate it multiple times. My idea is to use Function Hotkeys and A_ThisHotKey variable, but the WheelDown is disable in the program if using this script: WheelDown:: ScrollKey := A_ThisHotKey SetTitleMatchMode, 2 IfWinActive, Writer { CoordMode, Mouse, Screen WinGet, active_id, ID, A IfWinExist, Sumatra { Send {ScrollKey} WinActivate ; Automatically uses the window found above. Send {ScrollKey} Send

Getting session and SFTP channel in Java using JSch library

萝らか妹 提交于 2019-12-22 14:00:28
问题 I am using JSch library for SFTP. I need to do several operations on SFTP server like move remote files in other directory, pull files, etc. For all these operations I need Session and from it I get Channel an then cast it to ChannelSftp . This is redundant step. So I thought of abstracting it into a private method. private ChannelSftp getChannelSftp() throws JSchException { java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); JSch jsch = new

What duplication detection threshold do you use? [closed]

可紊 提交于 2019-12-21 20:52:45
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . We all agree that duplication is evil and should be avoid (Don't Repeat Yourself principle). To ensure that, static analysis code

How do I put some code into multiple namespaces without duplicating this code?

╄→гoц情女王★ 提交于 2019-12-21 06:59:14
问题 Assume I have the method defined in the two different namespaces: namespace foo { void print() { //do work... } } namespace bar { void print() { //do work... } } The foo::print() and the bar::print() functions are absolutely equal. My project uses the numerous calls of these functions. Is there a way to remove one of the print() definitions without changing the calls of these function ? I mean something like the following (of course, C++ language doesn't allow this construction, it's just an

Any tools to check for duplicate VB.NET code?

谁都会走 提交于 2019-12-20 18:26:10
问题 I wish to get a quick feeling for how much “copy and paste” coding we have, there are many tools for C# / Java to check for this type of thing. Are there any such tools that work well with VB.NET? (I have seen what looks like lots of repeated code, but wish to get some number to help me make a case for sorting it out) Update on progress. I have just tried Simian. It does not seem to be able to produce a nicely formatted report I can sent by email It does not cope when the names of local

generic code duplication detection tool

久未见 提交于 2019-12-20 17:16:09
问题 I'm looking for a code duplication tool that is language agnostic. It's easy to find language specific code duplication tools (for Java, C, PHP, ...), but I'd like to run some code duplication analysis on a templates in a custom syntax. I don't care about advanced parsing of the syntax, just straight line based raw string comparison is fine. Whitespace insensitive matching would be a plus, but not required. (It's not that hard to normalize/eliminate whitespace myself.) Does anybody know a

Any valid reason for code duplication? [closed]

不羁的心 提交于 2019-12-19 05:05:02
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I'm currently reviewing a very old C++ project and see lots of code duplication there. For example,

Duplicated using directives in multiple files

ε祈祈猫儿з 提交于 2019-12-18 08:27:13
问题 I have got 5 C# files that have 20 using directives in common. I want to get rid of this code duplication, especially because these 20 using directives belong logically together. In C or C++ I would have created an extra header file containing these 20 include files. This extra header file acts as a layer then to include the 20 other files in one go. Unfortunately I don't know how to do this in C#. Any suggestions? 回答1: You can't do this in C# since C# does not have a preprocessor, and the C#

Is duplicated code more tolerable in unit tests?

China☆狼群 提交于 2019-12-17 15:44:15
问题 I ruined several unit tests some time ago when I went through and refactored them to make them more DRY--the intent of each test was no longer clear. It seems there is a trade-off between tests' readability and maintainability. If I leave duplicated code in unit tests, they're more readable, but then if I change the SUT, I'll have to track down and change each copy of the duplicated code. Do you agree that this trade-off exists? If so, do you prefer your tests to be readable, or maintainable?